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 <eoGeneralBreeder.h>
00017 #include <eoBreed.h>
00018 #include <eoContinue.h>
00019 #include <eoEvalFunc.h>
00020 #include <eoGenContinue.h>
00021 #include <eoGenOp.h>
00022 #include <eoPopEvalFunc.h>
00023 #include <eoSGAGenOp.h>
00024 #include <moeoCrowdingDistanceDiversityAssignment.h>
00025 #include <moeoDetTournamentSelect.h>
00026 #include <moeoElitistReplacement.h>
00027 #include <moeoFastNonDominatedSortingFitnessAssignment.h>
00028 
00035 template < class MOEOT >
00036 class moeoNSGAII: public moeoEA < MOEOT >
00037 {
00038 public:
00039 
00046     moeoNSGAII (unsigned _max_gen, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > &_op) :
00047             continuator (*(new eoGenContinue < MOEOT > (_max_gen))), eval (_eval), loopEval (_eval), popEval (loopEval), select (2),    // binary tournament selection
00048             replace (fitnessAssignment, diversityAssignment), genBreed (select, _op), breed (genBreed)
00049     {}
00050 
00051 
00061     moeoNSGAII (unsigned _max_gen, eoEvalFunc < MOEOT > &_eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut) :
00062             continuator (*(new eoGenContinue < MOEOT > (_max_gen))), eval (_eval), loopEval (_eval), popEval (loopEval), select (2),    // binary tournament selection
00063             replace (fitnessAssignment, diversityAssignment), genBreed (select, *new eoSGAGenOp < MOEOT > (_crossover, _pCross, _mutation, _pMut)), breed (genBreed)
00064     {}
00065 
00066 
00073     moeoNSGAII (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op) :
00074             continuator (_continuator), eval (_eval), loopEval (_eval), popEval (loopEval), select (2), // binary tournament selection
00075             replace (fitnessAssignment, diversityAssignment), genBreed (select, _op), breed (genBreed)
00076     {}
00077 
00078 
00083     virtual void operator () (eoPop < MOEOT > &_pop)
00084     {
00085         eoPop < MOEOT > offspring, empty_pop;
00086         popEval (empty_pop, _pop);      // a first eval of _pop
00087         // evaluate fitness and diversity
00088         fitnessAssignment(_pop);
00089         diversityAssignment(_pop);
00090         do
00091         {
00092             // generate offspring, worths are recalculated if necessary
00093             breed (_pop, offspring);
00094             // eval of offspring
00095             popEval (_pop, offspring);
00096             // after replace, the new pop is in _pop. Worths are recalculated if necessary
00097             replace (_pop, offspring);
00098         } while (continuator (_pop));
00099     }
00100 
00101 
00102 protected:
00103 
00105     eoContinue < MOEOT > & continuator;
00107     eoEvalFunc < MOEOT > & eval;
00109     eoPopLoopEval < MOEOT > loopEval;
00111     eoPopEvalFunc < MOEOT > & popEval;
00113     moeoDetTournamentSelect < MOEOT > select;
00115     moeoElitistReplacement < MOEOT > replace;
00117     eoGeneralBreeder < MOEOT > genBreed;
00119     eoBreed < MOEOT > & breed;
00121     moeoFastNonDominatedSortingFitnessAssignment < MOEOT > fitnessAssignment;
00123     moeoCrowdingDistanceDiversityAssignment  < MOEOT > diversityAssignment;
00124 
00125 };
00126 
00127 #endif /*MOEONSGAII_H_*/

Generated on Tue Apr 17 16:53:21 2007 for ParadisEO-MOEO by  doxygen 1.5.1