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:
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param _evalFitness the population fitness assignment
|
||||
* @param _evalDiversity the population diversity assignment
|
||||
* @param _total
|
||||
*/
|
||||
moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity)
|
||||
:evalFitness (_evalFitness), evalDiversity (_evalDiversity)
|
||||
|
||||
{
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
* Full Ctor.
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
*/
|
||||
moeoRouletteSelect (moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):
|
||||
comparator (_comparator), tSize (_tSize)
|
||||
{
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
std::
|
||||
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ctor without diversity assignment nor comparator. A moeoDummyDiversityAssignment and a moeoFitnessThenDiversityComparator are used as default.
|
||||
* @param _evalFitness the population fitness assignment
|
||||
* @param _total
|
||||
*/
|
||||
moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _total=1):evalFitness (_evalFitness),
|
||||
total (_total)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
*/
|
||||
moeoRouletteSelect (unsigned _tSize = 2):
|
||||
comparator (*(new moeoFitnessThenDiversityComparator < MOEOT > ())),
|
||||
tSize (_tSize)
|
||||
{
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
std::
|
||||
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the tournament to the given population
|
||||
|
|
@ -106,13 +72,9 @@ moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _total
|
|||
|
||||
protected:
|
||||
|
||||
moeoFitnessAssignment < MOEOT > &evalFitness;
|
||||
|
||||
moeoDiversityAssignment < MOEOT > &evalDiversity;
|
||||
|
||||
moeoComparator < MOEOT > &comparator;
|
||||
|
||||
double total;
|
||||
double & total;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue