GPLIB++
AnnealingGA.h
Go to the documentation of this file.
1 #ifndef CANNEALINGGA_H
2 #define CANNEALINGGA_H
3 #include <vector>
4 #include "GeneralGA.h"
5 #include "VecMat.h"
6 
7 namespace gplib
8  {
9  /** \addtogroup gainv Genetic algorithm optimization */
10  /* @{ */
11  //! AnnealingGA implements a genetic algorithm with an annealing style objective function
12  /*! For the first AnnealingGeneration iterations the objective function is kept constant
13  * after that the misfit is stretched with an exponential annealing function to focus on the minimum
14  */
15  class AnnealingGA: public GeneralGA
16  {
17  private:
18  //! The initial "Temperature" for the Annealing function
19  double InitTemperature;
20  //! Before AnnealingGeneration iterations the objective function stays constant
21  int AnnealingGeneration;
22  //! The ratio by which the temperature is decreased
23  double AnnealingRatio;
24  protected:
25  //! The implementation of Elitism for the AnnealingGA, in this case this function has no effect
26  void virtual Elitism(const int iterationnumber);
27  public:
28  //! The index of the best population member
29  int GetBestIndex();
30  //! Set the parameters for the annealing process
31  void SetParams(const double InitT, const int AnnealG,
32  const double AnnealR);
33  //! How many best models exist in this iteration, for this GA it is always 1
34  unsigned int virtual GetNBestmodels()
35  {
36  return 1;
37  } // there is one best model in each iteration
38  //! Return the vector containing the best indices, here it has always one component equal to GetBestIndex
39  std::vector<int> virtual GetBestModelIndices()
40  {
41  return std::vector<int>(1, GetBestIndex());
42  }
43  //! Calculate the selection probabilities given the iterationnumber, misfit and population to store the results
44  void virtual CalcProbabilities(const int iterationnumber,
45  gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation);
46  //! The constructor only passes on the parameters to GeneralGA
47  AnnealingGA(GeneralPropagation* const LocalPropagation,
48  GeneralPopulation* const LocalPopulation,
49  GeneralTranscribe* const LocalTranscribe,
50  const tObjectiveVector &IndObjective, const int nthreads = 1);
51  virtual ~AnnealingGA();
52  };
53  /* @} */
54  }
55 #endif // CANNEALINGGA_H
The base class for the population of a genetic algorithm, implements storage and access functions...
AnnealingGA implements a genetic algorithm with an annealing style objective function.
Definition: AnnealingGA.h:15
virtual void CalcProbabilities(const int iterationnumber, gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation)
Calculate the selection probabilities given the iterationnumber, misfit and population to store the r...
Definition: AnnealingGA.cpp:43
The base class for genetic algorithm propagation methods.
virtual std::vector< int > GetBestModelIndices()
Return the vector containing the best indices, here it has always one component equal to GetBestIndex...
Definition: AnnealingGA.h:39
General Transcribe base class for genetic algorithm parameter transcription.
virtual void Elitism(const int iterationnumber)
The implementation of Elitism for the AnnealingGA, in this case this function has no effect...
Definition: AnnealingGA.cpp:69
General genetic algorithm class.
Definition: GeneralGA.h:25
int GetBestIndex()
The index of the best population member.
Definition: AnnealingGA.cpp:28
virtual ~AnnealingGA()
Definition: AnnealingGA.cpp:24
void SetParams(const double InitT, const int AnnealG, const double AnnealR)
Set the parameters for the annealing process.
Definition: AnnealingGA.cpp:35
std::vector< boost::shared_ptr< GeneralObjective > > tObjectiveVector
Definition: GeneralGA.h:31
AnnealingGA(GeneralPropagation *const LocalPropagation, GeneralPopulation *const LocalPopulation, GeneralTranscribe *const LocalTranscribe, const tObjectiveVector &IndObjective, const int nthreads=1)
The constructor only passes on the parameters to GeneralGA.
Definition: AnnealingGA.cpp:14
unsigned virtual int GetNBestmodels()
How many best models exist in this iteration, for this GA it is always 1.
Definition: AnnealingGA.h:34