ParetoGA.h

Go to the documentation of this file.
00001 #ifndef CPARETOGA_H
00002 #define CPARETOGA_H
00003 
00004 #include "GeneralGA.h"
00005 #include <iostream>
00006 #include <vector>
00007 #include "VecMat.h"
00008 
00009 namespace gplib
00010   {
00011     /** \addtogroup gainv Genetic algorithm optimization */
00012     /* @{ */
00013     //! Implements a genetic algorithm based on the concept of pareto-optimality, best suited for multi-objective problems
00014     /*! The class ParetoGA implements a variant of NSGA-II by Deb et al.:
00015      * Deb, K., Pratap. A, Agarwal, S., and Meyarivan, T. (2002). A fast and elitist multi-objective genetic algorithm: NSGA-II. IEEE Transaction on Evolutionary Computation, 6(2), 181-197.
00016      */
00017     class ParetoGA: public GeneralGA
00018       {
00019     private:
00020       typedef ublas::matrix_row<gplib::rmat>::const_iterator tMisfitIterator;
00021       void CalcCrowdingDistance(gplib::rmat &LocalMisFit,
00022           GeneralPopulation &LocalPopulation);
00023       std::vector<std::vector<int> > Ranks;
00024       int MaxRanks;
00025     protected:
00026       //! The function Elitism ensures that the best models are preserved after mutation and crossover
00027       void virtual Elitism(const int iterationnumber);
00028     public:
00029       //! Return the size of the pareto-optimal front
00030       unsigned int virtual GetNBestmodels()
00031         {
00032           return Ranks.front().size();
00033         }
00034       //! Get the indices of the models within the Pareto front
00035       std::vector<int> virtual GetBestModelIndices()
00036         {
00037           return Ranks.front();
00038         }
00039       //! Calculate the probabilities of reproduction by ranking the population
00040       void virtual CalcProbabilities(const int iterationnumber,
00041           gplib::rmat &LocalMisFit, GeneralPopulation &LocalPopulation);
00042       //! Write the population by ranks to the stream output
00043       void PrintRanks(std::ostream &output);
00044       //! Write the models in the pareto-optimal front to stream output
00045       void PrintFront(std::ostream &output);
00046       //! The constructor needs other classes that determine the behaviour of the GA
00047       ParetoGA(GeneralPropagation* const LocalPropagation,
00048           GeneralPopulation* const LocalPopulation,
00049           GeneralTranscribe* const LocalTranscribe,
00050           const tObjectiveVector &IndObjective, const int nthreads = 1) :
00051         GeneralGA(LocalPropagation, LocalPopulation, LocalTranscribe,
00052             IndObjective, nthreads)
00053         {
00054         }
00055       virtual ~ParetoGA();
00056       };
00057   /* @} */
00058   }
00059 #endif // CPARETOGA_H

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8