moeoNSGA.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // moeoNSGA.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 MOEONSGA_H_
00014 #define MOEONSGA_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/moeoFrontByFrontSharingDiversityAssignment.h>
00026 #include <fitness/moeoFastNonDominatedSortingFitnessAssignment.h>
00027 #include <replacement/moeoElitistReplacement.h>
00028 #include <selection/moeoDetTournamentSelect.h>
00029 
00036 template < class MOEOT >
00037 class moeoNSGA: public moeoEA < MOEOT >
00038 {
00039 public:
00040 
00048     moeoNSGA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, double _nicheSize = 0.5) :
00049             defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select(2),
00050             diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00051     {}
00052 
00053 
00061     moeoNSGA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op, double _nicheSize = 0.5) :
00062             defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select(2),
00063             diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00064     {}
00065 
00066 
00077     moeoNSGA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, double _nicheSize = 0.5) :
00078             defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select (2),
00079             diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment),
00080             defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed)
00081     {}
00082 
00083 
00091     moeoNSGA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, double _nicheSize = 0.5) :
00092             continuator(_continuator), popEval(_eval), select(2),
00093             diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00094     {}
00095 
00096 
00104     moeoNSGA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op, double _nicheSize = 0.5) :
00105             continuator(_continuator), popEval(_eval), select(2),
00106             diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment), genBreed(select, _op), breed(genBreed)
00107     {}
00108 
00109 
00114     virtual void operator () (eoPop < MOEOT > &_pop)
00115     {
00116         eoPop < MOEOT > offspring, empty_pop;
00117         popEval (empty_pop, _pop);      // a first eval of _pop
00118         // evaluate fitness and diversity
00119         fitnessAssignment(_pop);
00120         diversityAssignment(_pop);
00121         do
00122         {
00123             // generate offspring, worths are recalculated if necessary
00124             breed (_pop, offspring);
00125             // eval of offspring
00126             popEval (_pop, offspring);
00127             // after replace, the new pop is in _pop. Worths are recalculated if necessary
00128             replace (_pop, offspring);
00129         } while (continuator (_pop));
00130     }
00131 
00132 
00133 protected:
00134 
00136     eoGenContinue < MOEOT > defaultGenContinuator;
00138     eoContinue < MOEOT > & continuator;
00140     eoPopLoopEval < MOEOT > popEval;
00142     moeoDetTournamentSelect < MOEOT > select;
00144     moeoFastNonDominatedSortingFitnessAssignment < MOEOT > fitnessAssignment;
00146     moeoFrontByFrontSharingDiversityAssignment  < MOEOT > diversityAssignment;
00148     moeoElitistReplacement < MOEOT > replace;
00150     eoSGAGenOp < MOEOT > defaultSGAGenOp;
00152     eoGeneralBreeder < MOEOT > genBreed;
00154     eoBreed < MOEOT > & breed;
00155 
00156 };
00157 
00158 #endif /*MOEONSGAII_H_*/

Generated on Mon Jul 2 16:05:01 2007 for ParadisEO-MOEO by  doxygen 1.4.7