00001 #ifndef CSIMPLESELECT_H 00002 #define CSIMPLESELECT_H 00003 00004 #include "GeneralSelect.h" 00005 #include "GeneralRNG.h" 00006 #include <boost/function.hpp> 00007 00008 namespace gplib 00009 { 00010 /** \addtogroup gainv Genetic algorithm optimization */ 00011 /* @{ */ 00012 //! This is a relatively simple selection scheme for the genetic algorithms 00013 /*! This class implements a relatively simple, but efficient selection scheme. 00014 * Each member is assigned the expected count from the probabilities returned by 00015 * the Probability function rounded to full integers. The difference between the 00016 * assigned count and the expected count without rounding is used as a probability 00017 * to have an additional member in the new population. 00018 */ 00019 class SimpleSelect: public GeneralSelect 00020 { 00021 private: 00022 //! The vector of indices for the new population member 00023 tindexv indices; 00024 //! The random number generator 00025 GeneralRNG &Random; 00026 int remain; 00027 //! A pointer to a function that returns a vector of probabilities 00028 tProbabilityFunction ProbabilityFunction; 00029 virtual void DoInit(); 00030 virtual size_t DoGetOne(); 00031 public: 00032 //! The constructor needs a random number generator and a function that returns probabilities 00033 /*! The constructor takes two parameters 00034 * @param LocalRandom A random number generator based on GeneralRNG 00035 * @param myPF A pointer to a function that returns a vector with probabilities for each population member 00036 */ 00037 SimpleSelect(GeneralRNG &LocalRandom, tProbabilityFunction myPF); 00038 virtual ~SimpleSelect(); 00039 }; 00040 /* @} */ 00041 } 00042 #endif // CSIMPLESELECT_H
1.5.8