00001 #ifndef CANNEALINGGA_H 00002 #define CANNEALINGGA_H 00003 #include <vector> 00004 #include "GeneralGA.h" 00005 #include "VecMat.h" 00006 00007 /** \addtogroup gainv Genetic algorithm optimization */ 00008 /* @{ */ 00009 //! AnnealingGA implements a genetic algorithm with an annealing style objective function 00010 /*! For the first AnnealingGeneration iterations the objective function is kept constant 00011 * after that the misfit is stretched with an exponential annealing function to focus on the minimum 00012 */ 00013 class AnnealingGA : public GeneralGA{ 00014 private: 00015 //! The initial "Temperature" for the Annealing function 00016 double InitTemperature; 00017 //! Before AnnealingGeneration iterations the objective function stays constant 00018 int AnnealingGeneration; 00019 //! The ratio by which the temperature is decreased 00020 double AnnealingRatio; 00021 protected: 00022 //! The implementation of Elitism for the AnnealingGA, in this case this function has no effect 00023 void virtual Elitism(const int iterationnumber); 00024 public: 00025 //! The index of the best population member 00026 int GetBestIndex(); 00027 //! Set the parameters for the annealing process 00028 void SetParams(const double InitT, const int AnnealG, const double AnnealR); 00029 //! How many best models exist in this iteration, for this GA it is always 1 00030 unsigned int virtual GetNBestmodels(){return 1;} // there is one best model in each iteration 00031 //! Return the vector containing the best indices, here it has always one component equal to GetBestIndex 00032 std::vector<int> virtual GetBestModelIndices(){return std::vector<int>(1,GetBestIndex());} 00033 //! Calculate the selection probabilities given the iterationnumber, misfit and population to store the results 00034 void virtual CalcProbabilities(const int iterationnumber, gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation); 00035 //! The constructor only passes on the parameters to GeneralGA 00036 AnnealingGA(GeneralPropagation* const LocalPropagation, GeneralPopulation* const LocalPopulation, 00037 GeneralTranscribe* const LocalTranscribe, const tObjectiveVector &IndObjective); 00038 virtual ~AnnealingGA(); 00039 }; 00040 /* @} */ 00041 #endif // CANNEALINGGA_H
1.5.5