diff --git a/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h b/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h index 175972352..179ec9be7 100644 --- a/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h +++ b/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h @@ -41,6 +41,7 @@ #define MOEOSPEA2_H_ #include +#include #include #include #include @@ -57,8 +58,12 @@ #include #include #include -#include +/** + * SPEA2 algorithm. + * E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the Strength Pareto Evolutionary Algorithm. Technical Report 103, + * Computer Engineering and Networks Laboratory (TIK), ETH Zurich, Zurich, Switzerland, 2001. + */ template < class MOEOT > class moeoSPEA2: public moeoEA < MOEOT > { @@ -81,6 +86,7 @@ public: genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k) {} + /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria @@ -98,6 +104,7 @@ public: genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k) {} + /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria @@ -115,6 +122,7 @@ public: genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k) {} + /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria @@ -129,6 +137,7 @@ public: genBreed(select, _op),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k) {} + /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria @@ -143,6 +152,7 @@ public: genBreed(defaultSelect, defaultSGAGenOp),selectMany(select,1.0), selectTransform(selectMany, _op), breed(selectTransform), diversityAssignment(dist,_archive, _k) {} + /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria @@ -157,6 +167,7 @@ public: genBreed(select, _op),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k) {} + /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria @@ -171,6 +182,7 @@ public: genBreed(defaultSelect, defaultSGAGenOp),selectMany(select,1.0), selectTransform(selectMany, _op), breed(selectTransform), diversityAssignment(dist,_archive, _k) {} + /** * Apply a few generation of evolution to the population _pop until the stopping criteria is verified. * @param _pop the population @@ -182,57 +194,46 @@ public: fitnessAssignment(_pop); //a first fitness assignment of _pop diversityAssignment(_pop);//a first diversity assignment of _pop archive(_pop);//a first filling of archive - - while (continuator (_pop)) { - - + while (continuator (_pop)) + { // generate offspring, worths are recalculated if necessary breed (_pop, offspring); - popEval (_pop, offspring); // eval of offspring - // after replace, the new pop is in _pop. Worths are recalculated if necessary replace (_pop, offspring); - fitnessAssignment(_pop); //fitness assignment of _pop diversityAssignment(_pop); //diversity assignment of _pop archive(_pop); //control of archive - } - std::cout << "Final Archive\n"; - archive.sortedPrintOn (std::cout); - std::cout << "\n"; } + protected: - /** Dummy Evaluation Function class*/ - class eoDummyEval : public eoEvalFunc< MOEOT > + /** dummy evaluation */ +class eoDummyEval : public eoEvalFunc< MOEOT > { public: - void operator()(MOEOT &) - {} + void operator()(MOEOT &) {} } dummyEval; - - class eoDummyTransform : public eoTransform + /** dummy transform */ +class eoDummyTransform : public eoTransform { public : - void operator()(eoPop&) - {} + void operator()(eoPop&) {} } dummyTransform; - /** a continuator based on the number of generations (used as default) */ eoGenContinue < MOEOT > defaultGenContinuator; /** stopping criteria */ eoContinue < MOEOT > & continuator; /** evaluation function */ - eoEvalFunc < MOEOT >& eval; + eoEvalFunc < MOEOT > & eval; /** loop eval */ eoPopLoopEval < MOEOT > loopEval; /** evaluation function used to evaluate the whole population */ - eoPopEvalFunc < MOEOT >& popEval; + eoPopEvalFunc < MOEOT > & popEval; /** selectMany */ eoSelectMany selectMany; /** select Transform*/ @@ -261,6 +262,7 @@ protected: moeoEuclideanDistance < MOEOT > dist; /**archive*/ moeoArchive < MOEOT >& archive; + }; #endif /*MOEOSPEA2_H_*/