GPLIB++
SimpleSelect.h
Go to the documentation of this file.
1 #ifndef CSIMPLESELECT_H
2 #define CSIMPLESELECT_H
3 
4 #include "GeneralSelect.h"
5 #include "GeneralRNG.h"
6 #include <boost/function.hpp>
7 
8 namespace gplib
9  {
10  /** \addtogroup gainv Genetic algorithm optimization */
11  /* @{ */
12  //! This is a relatively simple selection scheme for the genetic algorithms
13  /*! This class implements a relatively simple, but efficient selection scheme.
14  * Each member is assigned the expected count from the probabilities returned by
15  * the Probability function rounded to full integers. The difference between the
16  * assigned count and the expected count without rounding is used as a probability
17  * to have an additional member in the new population.
18  */
20  {
21  private:
22  //! The vector of indices for the new population member
23  tindexv indices;
24  //! The random number generator
25  GeneralRNG &Random;
26  int remain;
27  //! A pointer to a function that returns a vector of probabilities
28  tProbabilityFunction ProbabilityFunction;
29  virtual void DoInit();
30  virtual size_t DoGetOne();
31  public:
32  //! The constructor needs a random number generator and a function that returns probabilities
33  /*! The constructor takes two parameters
34  * @param LocalRandom A random number generator based on GeneralRNG
35  * @param myPF A pointer to a function that returns a vector with probabilities for each population member
36  */
37  SimpleSelect(GeneralRNG &LocalRandom, tProbabilityFunction myPF);
38  virtual ~SimpleSelect();
39  };
40  /* @} */
41  }
42 #endif // CSIMPLESELECT_H
boost::function< const tprobabilityv &()> tProbabilityFunction
Definition: gentypes.h:29
SimpleSelect(GeneralRNG &LocalRandom, tProbabilityFunction myPF)
The constructor needs a random number generator and a function that returns probabilities.
Definition: SimpleSelect.cpp:8
GeneralSelect is the abstract base class for any selection mechanism in genetic algorithms.
Definition: GeneralSelect.h:16
std::vector< int > tindexv
Definition: gentypes.h:26
The base class for all random number generators, defines the basic interface.
Definition: GeneralRNG.h:9
This is a relatively simple selection scheme for the genetic algorithms.
Definition: SimpleSelect.h:19