rm fit and div, replace constructors and indent
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@217 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
337b09950f
commit
3298fadc1e
1 changed files with 34 additions and 72 deletions
|
|
@ -24,75 +24,41 @@ template < class MOEOT >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* Full Ctor
|
|
||||||
* @param _evalFitness the population fitness assignment
|
|
||||||
* @param _evalDiversity the population diversity assignment
|
|
||||||
* @param _comparator the comparator to compare the individuals
|
|
||||||
* @param _total
|
|
||||||
*/
|
|
||||||
moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > &_comparator, double _total=1 ):evalFitness (_evalFitness), evalDiversity (_evalDiversity),
|
|
||||||
comparator (_comparator), total (_total) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
|
* Full Ctor.
|
||||||
* @param _evalFitness the population fitness assignment
|
* @param _comparator the comparator (used to compare 2 individuals)
|
||||||
* @param _evalDiversity the population diversity assignment
|
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||||
* @param _total
|
*/
|
||||||
*/
|
moeoRouletteSelect (moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):
|
||||||
moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity)
|
comparator (_comparator), tSize (_tSize)
|
||||||
:evalFitness (_evalFitness), evalDiversity (_evalDiversity)
|
{
|
||||||
|
// consistency check
|
||||||
{
|
if (tSize < 2)
|
||||||
// a moeoFitThenDivComparator is used as default
|
{
|
||||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
std::
|
||||||
comparator = fitThenDivComparator;
|
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||||
}
|
tSize = 2;
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* Ctor without diversity assignment. A dummy diversity assignment is used.
|
|
||||||
* @param _evalFitness the population fitness assignment
|
|
||||||
* @param _comparator the comparator to compare the individuals
|
|
||||||
* @param _total
|
|
||||||
*/
|
|
||||||
moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > &_comparator, double _total=1):evalFitness (_evalFitness), comparator (_comparator),
|
|
||||||
total
|
|
||||||
(_total)
|
|
||||||
{
|
|
||||||
// a dummy diversity is used as default
|
|
||||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
|
||||||
evalDiversity = dummyDiversityAssignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ctor without diversity assignment nor comparator. A moeoDummyDiversityAssignment and a moeoFitnessThenDiversityComparator are used as default.
|
* Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
|
||||||
* @param _evalFitness the population fitness assignment
|
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||||
* @param _total
|
*/
|
||||||
*/
|
moeoRouletteSelect (unsigned _tSize = 2):
|
||||||
moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _total=1):evalFitness (_evalFitness),
|
comparator (*(new moeoFitnessThenDiversityComparator < MOEOT > ())),
|
||||||
total (_total)
|
tSize (_tSize)
|
||||||
{
|
{
|
||||||
// a dummy diversity is used as default
|
// consistency check
|
||||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
if (tSize < 2)
|
||||||
evalDiversity = dummyDiversityAssignment;
|
{
|
||||||
|
std::
|
||||||
// a moeoFitThenDivComparator is used as default
|
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
tSize = 2;
|
||||||
comparator = fitThenDivComparator;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Evaluate the fitness and the diversity of each individual of the population.
|
|
||||||
*/
|
|
||||||
void setup (eoPop<MOEOT>& _pop)
|
|
||||||
{
|
|
||||||
// eval fitness
|
|
||||||
evalFitness(_pop);
|
|
||||||
|
|
||||||
// eval diversity
|
|
||||||
evalDiversity(_pop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the tournament to the given population
|
* Apply the tournament to the given population
|
||||||
|
|
@ -106,13 +72,9 @@ moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _total
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
moeoFitnessAssignment < MOEOT > &evalFitness;
|
|
||||||
|
|
||||||
moeoDiversityAssignment < MOEOT > &evalDiversity;
|
|
||||||
|
|
||||||
moeoComparator < MOEOT > &comparator;
|
moeoComparator < MOEOT > &comparator;
|
||||||
|
|
||||||
double total;
|
double & total;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue