moeoNSGAII.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // moeoNSGAII.h
00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
00006 /*
00007     This library...
00008 
00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
00010  */
00011 //-----------------------------------------------------------------------------
00012 
00013 #ifndef MOEONSGAII_H_
00014 #define MOEONSGAII_H_
00015 
00016 #include <eoBreed.h>
00017 #include <eoContinue.h>
00018 #include <eoEvalFunc.h>
00019 #include <eoGenContinue.h>
00020 #include <eoGeneralBreeder.h>
00021 #include <eoGenOp.h>
00022 #include <eoPopEvalFunc.h>
00023 #include <eoSGAGenOp.h>
00024 #include <algo/moeoEA.h>
00025 #include <diversity/moeoFrontByFrontCrowdingDiversityAssignment.h>
00026 #include <fitness/moeoFastNonDominatedSortingFitnessAssignment.h>
00027 #include <replacement/moeoElitistReplacement.h>
00028 #include <selection/moeoDetTournamentSelect.h>
00029 
00036 template < class MOEOT >
00037 class moeoNSGAII: public moeoEA < MOEOT >
00038 {
00039 public:
00040 
00047     moeoNSGAII (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op) :
00048             defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select(2),
00049             replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00050     {}
00051 
00052 
00059     moeoNSGAII (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op) :
00060             defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select(2),
00061             replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00062     {}
00063 
00064 
00074     moeoNSGAII (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut) :
00075             defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select (2),
00076             replace (fitnessAssignment, diversityAssignment), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut),
00077             genBreed (select, defaultSGAGenOp), breed (genBreed)
00078     {}
00079 
00080 
00087     moeoNSGAII (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op) :
00088             continuator(_continuator), popEval(_eval), select(2),
00089             replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00090     {}
00091 
00092 
00099     moeoNSGAII (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op) :
00100             continuator(_continuator), popEval(_eval), select(2),
00101             replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00102     {}
00103 
00104 
00109     virtual void operator () (eoPop < MOEOT > &_pop)
00110     {
00111         eoPop < MOEOT > offspring, empty_pop;
00112         popEval (empty_pop, _pop);      // a first eval of _pop
00113         // evaluate fitness and diversity
00114         fitnessAssignment(_pop);
00115         diversityAssignment(_pop);
00116         do
00117         {
00118             // generate offspring, worths are recalculated if necessary
00119             breed (_pop, offspring);
00120             // eval of offspring
00121             popEval (_pop, offspring);
00122             // after replace, the new pop is in _pop. Worths are recalculated if necessary
00123             replace (_pop, offspring);
00124         } while (continuator (_pop));
00125     }
00126 
00127 
00128 protected:
00129 
00131     eoGenContinue < MOEOT > defaultGenContinuator;
00133     eoContinue < MOEOT > & continuator;
00135     eoPopLoopEval < MOEOT > popEval;
00137     moeoDetTournamentSelect < MOEOT > select;
00139     moeoFastNonDominatedSortingFitnessAssignment < MOEOT > fitnessAssignment;
00141     moeoFrontByFrontCrowdingDiversityAssignment  < MOEOT > diversityAssignment;
00143     moeoElitistReplacement < MOEOT > replace;
00145     eoSGAGenOp < MOEOT > defaultSGAGenOp;
00147     eoGeneralBreeder < MOEOT > genBreed;
00149     eoBreed < MOEOT > & breed;
00150 
00151 };
00152 
00153 #endif /*MOEONSGAII_H_*/

Generated on Fri Jul 6 09:41:04 2007 for ParadisEO-MOEO by  doxygen 1.4.7