doc added

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1208 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2008-06-26 10:05:07 +00:00
commit d229324172
3 changed files with 92 additions and 56 deletions

View file

@ -50,78 +50,94 @@
#include <utils/moeoDominanceMatrix.h>
/**
* moeoDominanceCountFitnessAssignment is a fitness assignment which count for each moeot the others moeot it dominates.
* Fitness assignment sheme that computes how many solutions does each solution dominate.
*/
template < class MOEOT >
class moeoDominanceCountFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor
* @param _nocopy boolean to move away copies
* @param _nocopy boolean to move away clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy)
moeoDominanceCountFitnessAssignment(bool _nocopy=false) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own archive
* @param _archive the archive used
* @param _nocopy boolean to move away copies
* @param _archive an archive to be included in the fitness assignment process
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), matrix(_nocopy)
moeoDominanceCountFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=false) : comparator(paretoComparator), archive(_archive), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
* @param _nocopy boolean to move away copies
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy)
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=false) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy)
{}
/**
* Ctor where you can choose your own archive and your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
* @param _archive the archive used
* @param _nocopy boolean to move away copies
* @param _archive an archive to be included in the fitness assignment process
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy)
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=false) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy)
{}
/**
* Sets the fitness values for every solution contained in the population _pop and in archive
* Sets the fitness values for every solution contained in the population _pop (and in the archive)
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop) {
void operator()(eoPop < MOEOT > & _pop)
{
unsigned int j= _pop.size();
unsigned int i= archive.size();
matrix(archive,_pop);
for (unsigned int k=0; k<i; k++)
archive[k].fitness(matrix.count(k));
archive[k].fitness(matrix.count(k));
for (unsigned int k=i; k<i+j; k++)
_pop[k-i].fitness(matrix.count(k));
_pop[k-i].fitness(matrix.count(k));
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
//not yet implemented
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountFitnessAssignment" << std::endl;
}
private:
/** Functor to compare two objective vectors */
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** Archive */
/** Archive to be included in the fitness assignment process */
moeoArchive < MOEOT > & archive;
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** Dominance Matrix */
moeoDominanceMatrix < MOEOT > matrix;
};
#endif /*MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_*/

View file

@ -51,16 +51,21 @@
#include <utils/moeoDominanceMatrix.h>
/**
* moeoDominanceCountRankingFitnessAssignment is a rank fitness assignment with value determine by a count fitness assignment.
* Fitness assignment sheme that sum-up the ranks of all solutions dominated by each solution.
* This strategy is used, for instance, in SPEA2.
* 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 moeoDominanceCountRankingFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor
* @param _nocopy boolean to move away copies
@ -68,6 +73,7 @@ public:
moeoDominanceCountRankingFitnessAssignment(bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own archive
* @param _archive the archive used
@ -76,6 +82,7 @@ public:
moeoDominanceCountRankingFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
@ -84,6 +91,7 @@ public:
moeoDominanceCountRankingFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy)
{}
/**
* Ctor where you can choose your own archive and your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
@ -95,57 +103,55 @@ public:
/**
* Sets the fitness values for every solution contained in the population _pop and in archive
* Sets the fitness values for every solution contained in the population _pop (and in the archive)
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
/*std::cout <<"\n\n";
for(unsigned k=0;k<_pop.size();k++){
std::cout << "pop " << k << " :\n";
for(unsigned l=0 ; l<2 ; l++)
std::cout << "\tobjVec " << l << " : " << _pop[k].objectiveVector()[l] << "\n";
}
for(unsigned k=0;k<archive.size();k++){
std::cout << "archive " << k << " :\n";
for(unsigned l=0 ; l<2 ; l++)
std::cout << "\tobjVec " << l << " : " << archive[k].objectiveVector()[l] << "\n";
}*/
unsigned int i= _pop.size();
unsigned int j= archive.size();
matrix(archive,_pop);
for (unsigned int k=0; k<j; k++)
archive[k].fitness(countRanking(k));
for (unsigned int k=j; k<i+j; k++)
_pop[k-j].fitness(countRanking(k));
_pop[k-j].fitness(countRanking(k));
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
//not yet implemented
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountRankingFitnessAssignment" << std::endl;
}
private:
/** Functor to compare two objective vectors */
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** Archive */
/** Archive to be included in the fitness assignment process */
moeoArchive < MOEOT > & archive;
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** Dominance Matrix*/
/** Dominance Matrix */
moeoDominanceMatrix <MOEOT> matrix;
double countRanking(unsigned int _i) {
/**
*
* @param _i
*/
double countRanking(unsigned int _i)
{
double res=0;
for (unsigned int k=0; k<matrix.size(); k++) {
for (unsigned int k=0; k<matrix.size(); k++)
{
if (matrix[k][_i])
res+=matrix.count(k);
}

View file

@ -49,54 +49,60 @@
#include <utils/moeoDominanceMatrix.h>
/**
* moeoDominanceRankFitnessAssignment is a fitness assignment which count for each moeot how many others dominates it.
* Fitness assignment sheme that computes how many solutions each solution is dominated by.
*/
template < class MOEOT >
class moeoDominanceRankFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor
* @param _start a start value used to determine the fitness (default _start = 1.0)
* @param _nocopy boolean to move away copies
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceRankFitnessAssignment(double _start=1.0, bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), start(_start), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own archive
* @param _archive the archive used
* @param _archive an archive to be included in the fitness assignment process
* @param _start a start value used to determine the fitness (default _start = 1.0)
* @param _nocopy boolean to move away copies
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceRankFitnessAssignment(moeoArchive < MOEOT > & _archive, double _start=1.0, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), start(_start), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
* @param _start a start value used to determine the fitness (default _start = 1.0)
* @param _nocopy boolean to move away copies
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceRankFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, double _start=1.0, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), start(_start), matrix(_comparator, _nocopy)
{}
/**
* Ctor where you can choose your own archive and your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
* @param _archive the archive used
* @param _archive an archive to be included in the fitness assignment process
* @param _start a start value used to determine the fitness (default _start = 1.0)
* @param _nocopy boolean to move away copies
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceRankFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, double _start=1.0, bool _nocopy=true) : comparator(_comparator), archive(_archive), start(_start), matrix(_comparator, _nocopy)
{}
/**
* Sets the fitness values for every solution contained in the population _pop and in archive
* Sets the fitness values for every solution contained in the population _pop (and in the archive)
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
@ -105,28 +111,36 @@ public:
unsigned int j= _pop.size();
matrix(archive, _pop);
for (unsigned int k=0; k<i; k++)
archive[k].fitness(-(matrix.rank(k)+start));
archive[k].fitness(-(matrix.rank(k)+start));
for (unsigned int k=i; k<i+j; k++)
_pop[k-i].fitness(-(matrix.rank(k)+start));
_pop[k-i].fitness(-(matrix.rank(k)+start));
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
//not yet implemented
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceRankFitnessAssignment" << std::endl;
}
private:
/** Functor to compare two objective vectors */
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** Archive*/
/** Archive to be included in the fitness assignment process */
moeoArchive < MOEOT > & archive;
/** Default archive*/
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** start value*/
/** Start value */
double start;
/** Dominance Matrix*/
/** Dominance Matrix */
moeoDominanceMatrix < MOEOT > matrix;
};