doc added

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1209 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2008-06-26 12:08:31 +00:00
commit 61f5d010b0

View file

@ -41,6 +41,7 @@
#define MOEOSPEA2_H_ #define MOEOSPEA2_H_
#include <eoBreed.h> #include <eoBreed.h>
#include <eoCloneOps.h>
#include <eoContinue.h> #include <eoContinue.h>
#include <eoEvalFunc.h> #include <eoEvalFunc.h>
#include <eoGenContinue.h> #include <eoGenContinue.h>
@ -57,8 +58,12 @@
#include <archive/moeoFixedSizeArchive.h> #include <archive/moeoFixedSizeArchive.h>
#include <distance/moeoEuclideanDistance.h> #include <distance/moeoEuclideanDistance.h>
#include <selection/moeoSelectFromPopAndArch.h> #include <selection/moeoSelectFromPopAndArch.h>
#include <eoCloneOps.h>
/**
* 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 > template < class MOEOT >
class moeoSPEA2: public moeoEA < 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) 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. * Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria * @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) 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. * Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria * @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) 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. * Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria * @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) 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. * Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria * @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) 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. * Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria * @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) 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. * Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria * @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) 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. * Apply a few generation of evolution to the population _pop until the stopping criteria is verified.
* @param _pop the population * @param _pop the population
@ -182,57 +194,46 @@ public:
fitnessAssignment(_pop); //a first fitness assignment of _pop fitnessAssignment(_pop); //a first fitness assignment of _pop
diversityAssignment(_pop);//a first diversity assignment of _pop diversityAssignment(_pop);//a first diversity assignment of _pop
archive(_pop);//a first filling of archive archive(_pop);//a first filling of archive
while (continuator (_pop))
while (continuator (_pop)) { {
// generate offspring, worths are recalculated if necessary // generate offspring, worths are recalculated if necessary
breed (_pop, offspring); breed (_pop, offspring);
popEval (_pop, offspring); // eval of offspring popEval (_pop, offspring); // eval of offspring
// after replace, the new pop is in _pop. Worths are recalculated if necessary // after replace, the new pop is in _pop. Worths are recalculated if necessary
replace (_pop, offspring); replace (_pop, offspring);
fitnessAssignment(_pop); //fitness assignment of _pop fitnessAssignment(_pop); //fitness assignment of _pop
diversityAssignment(_pop); //diversity assignment of _pop diversityAssignment(_pop); //diversity assignment of _pop
archive(_pop); //control of archive archive(_pop); //control of archive
} }
std::cout << "Final Archive\n";
archive.sortedPrintOn (std::cout);
std::cout << "\n";
} }
protected: protected:
/** Dummy Evaluation Function class*/ /** dummy evaluation */
class eoDummyEval : public eoEvalFunc< MOEOT > class eoDummyEval : public eoEvalFunc< MOEOT >
{ {
public: public:
void operator()(MOEOT &) void operator()(MOEOT &) {}
{}
} }
dummyEval; dummyEval;
/** dummy transform */
class eoDummyTransform : public eoTransform<MOEOT> class eoDummyTransform : public eoTransform<MOEOT>
{ {
public : public :
void operator()(eoPop<MOEOT>&) void operator()(eoPop<MOEOT>&) {}
{}
} }
dummyTransform; dummyTransform;
/** a continuator based on the number of generations (used as default) */ /** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator; eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */ /** stopping criteria */
eoContinue < MOEOT > & continuator; eoContinue < MOEOT > & continuator;
/** evaluation function */ /** evaluation function */
eoEvalFunc < MOEOT >& eval; eoEvalFunc < MOEOT > & eval;
/** loop eval */ /** loop eval */
eoPopLoopEval < MOEOT > loopEval; eoPopLoopEval < MOEOT > loopEval;
/** evaluation function used to evaluate the whole population */ /** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT >& popEval; eoPopEvalFunc < MOEOT > & popEval;
/** selectMany */ /** selectMany */
eoSelectMany <MOEOT> selectMany; eoSelectMany <MOEOT> selectMany;
/** select Transform*/ /** select Transform*/
@ -261,6 +262,7 @@ protected:
moeoEuclideanDistance < MOEOT > dist; moeoEuclideanDistance < MOEOT > dist;
/**archive*/ /**archive*/
moeoArchive < MOEOT >& archive; moeoArchive < MOEOT >& archive;
}; };
#endif /*MOEOSPEA2_H_*/ #endif /*MOEOSPEA2_H_*/