GPLIB++
GeneralSelect.h
Go to the documentation of this file.
1 #ifndef CGENERALSELECT_H
2 #define CGENERALSELECT_H
3 #include "gentypes.h"
4 namespace gplib
5  {
6  /** \addtogroup gainv Genetic algorithm optimization */
7  /* @{ */
8 
9  //!GeneralSelect is the abstract base class for any selection mechanism in genetic algorithms
10  /*!GeneralSelect defines to abstract functions: Init and GetOne. Init has to be called once per iteration
11  * and sets all the necessary parameters depending on probabilities and crowding distance
12  * GetOne then returns the index of a selected population member and is called every time a population
13  * member has to be selected by a selection operator.
14  * There is no default implementation ! */
15 
17  {
18  private:
19  bool initialized;
20  //! The abstract definition of the Init function, has to overriden
21  virtual void DoInit()= 0;
22  //! The abstract definition of GetOne, has to be overriden
23  virtual size_t DoGetOne()=0;
24  public:
25  void Init()
26  {
27  DoInit();
28  initialized = true;
29  }
30  size_t GetOne();
31  GeneralSelect();
32  virtual ~GeneralSelect();
33  };
34  /* @} */
35  }
36 #endif // CGENERALSELECT_H
GeneralSelect is the abstract base class for any selection mechanism in genetic algorithms.
Definition: GeneralSelect.h:16