GPLIB++
BinaryTournamentSelect.h
Go to the documentation of this file.
1 #ifndef CBINARYTOURNAMENTSELECT_H_
2 #define CBINARYTOURNAMENTSELECT_H_
3 
4 #include "GeneralSelect.h"
5 #include "GeneralRNG.h"
6 namespace gplib
7  {
8  /** \addtogroup gainv Genetic algorithm optimization */
9  /* @{ */
10 
11  //! Implements binary tournament selection for genetic algorithms
13  {
14  private:
15  //! The number of members that have been selected because of the crowding distance, purely for monitoring
16  size_t distancecount;
17  //! Storage for shuffled indices of the population, set up during DoInit and used to get pairs of member in DoGetOne
18  std::vector<unsigned int> PopulationIndex;
19  //! Local storage for the probabilities of the population
20  tprobabilityv localprobabilities;
21  //! Local storage for the crowding distance
22  tcrowddistv localdistances;
23  //! The random number generator to shuffle the population
24  GeneralRNG &Random;
25  //! Pointer to a function that returns the probabilities of the population
26  tProbabilityFunction ProbabilityFunction;
27  //! Pointer to a function that returns the crowding distances of the population
28  tDistanceFunction DistanceFunction;
29  //! The current index within the population
30  int ReturnIndex;
31  //! Initialize PopulationIndex and the local storage fields
32  virtual void DoInit();
33  //! Return the index to a population member
34  virtual size_t DoGetOne();
35  public:
36  //! The constructor requires a random number generator and access functions for probabilities and crowding distances
39  virtual ~BinaryTournamentSelect();
40  };
41  /* @} */
42  }
43 #endif /*CBINARYTOURNAMENTSELECT_H_*/
boost::function< const tprobabilityv &()> tProbabilityFunction
Definition: gentypes.h:29
ublas::vector< double > tprobabilityv
Definition: gentypes.h:17
Implements binary tournament selection for genetic algorithms.
GeneralSelect is the abstract base class for any selection mechanism in genetic algorithms.
Definition: GeneralSelect.h:16
BinaryTournamentSelect(GeneralRNG &LocalRandom, tProbabilityFunction myPF, tDistanceFunction myDF)
The constructor requires a random number generator and access functions for probabilities and crowdin...
boost::function< const tcrowddistv &()> tDistanceFunction
Definition: gentypes.h:30
The base class for all random number generators, defines the basic interface.
Definition: GeneralRNG.h:9
ublas::vector< double > tcrowddistv
Definition: gentypes.h:20