update doc
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@198 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
2ade1412c6
commit
ebd175c05b
5 changed files with 220 additions and 225 deletions
|
|
@ -17,141 +17,133 @@
|
|||
#include <moeoSelectors.h>
|
||||
|
||||
/**
|
||||
* moeoDetTournamentSelect: a selection method that selects ONE individual by
|
||||
* deterministic tournament
|
||||
* Selection strategy that selects ONE individual by deterministic tournament.
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoDetTournamentSelect:public moeoSelectOne <MOEOT>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Full Ctor
|
||||
* @param _evalFitness the population fitness assignment
|
||||
* @param _evalDiversity the population diversity assignment
|
||||
* @param _comparator the comparator to compare the individuals$
|
||||
* Full Ctor.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _evalDiversity the diversity assignment strategy
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
*/
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):evalFitness (_evalFitness), evalDiversity (_evalDiversity),
|
||||
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 comparator. A moeoFitnessThenDiversityComparator is used as default.
|
||||
* @param _evalFitness the population fitness assignment
|
||||
* @param _evalDiversity the population diversity assignme
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > & _evalFitness, moeoDiversityAssignment < MOEOT > & _evalDiversity, moeoComparator < MOEOT > & _comparator, unsigned _tSize = 2) :
|
||||
evalFitness (_evalFitness), evalDiversity (_evalDiversity), comparator (_comparator), tSize (_tSize)
|
||||
{
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _evalDiversity the diversity assignment strategy
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
*/
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, unsigned _tSize = 2)
|
||||
:evalFitness (_evalFitness),evalDiversity(_evalDiversity),tSize(_tSize)
|
||||
{
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, unsigned _tSize = 2) :
|
||||
evalFitness (_evalFitness),evalDiversity(_evalDiversity),tSize(_tSize)
|
||||
{
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
|
||||
moeoFitnessThenDiversityComparator < MOEOT > & fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
std::
|
||||
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
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 _evalFitness the fitness assignment strategy
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
*/
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):evalFitness (_evalFitness), comparator (_comparator),
|
||||
tSize
|
||||
(_tSize)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
|
||||
// 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
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > & _evalFitness, moeoComparator < MOEOT > & _comparator, unsigned _tSize = 2) :
|
||||
evalFitness (_evalFitness), comparator (_comparator), tSize (_tSize)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
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 fitness assignment strategy
|
||||
* @param _tSize the number of individuals in the tournament (default: 2)
|
||||
*/
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, unsigned _tSize = 2):evalFitness (_evalFitness),
|
||||
tSize
|
||||
(_tSize)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
std::
|
||||
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Evaluate the fitness and the diversity of each individual of the population.
|
||||
*/
|
||||
moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > & _evalFitness, unsigned _tSize = 2) :
|
||||
evalFitness (_evalFitness), tSize (_tSize)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
// consistency check
|
||||
if (tSize < 2)
|
||||
{
|
||||
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
|
||||
tSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Evaluate the fitness and the diversity of each individual of the population _pop.
|
||||
* @param _pop the population
|
||||
*/
|
||||
void setup (eoPop<MOEOT>& _pop)
|
||||
{
|
||||
// eval fitness
|
||||
evalFitness(_pop);
|
||||
|
||||
// eval diversity
|
||||
evalDiversity(_pop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the tournament to the given population
|
||||
*/
|
||||
const MOEOT & operator () (const eoPop < MOEOT > &_pop)
|
||||
{
|
||||
// use the selector
|
||||
return mo_deterministic_tournament(_pop,tSize,comparator);
|
||||
}
|
||||
|
||||
{
|
||||
// eval fitness
|
||||
evalFitness(_pop);
|
||||
// eval diversity
|
||||
evalDiversity(_pop);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply the tournament to the given population
|
||||
* @param _pop the population
|
||||
*/
|
||||
const MOEOT & operator () (const eoPop < MOEOT > &_pop)
|
||||
{
|
||||
// use the selector
|
||||
return mo_deterministic_tournament(_pop,tSize,comparator);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
moeoFitnessAssignment < MOEOT > &evalFitness;
|
||||
|
||||
moeoDiversityAssignment < MOEOT > &evalDiversity;
|
||||
|
||||
moeoComparator < MOEOT > &comparator;
|
||||
|
||||
|
||||
/** the fitness assignment strategy */
|
||||
moeoFitnessAssignment < MOEOT > & evalFitness;
|
||||
/** the diversity assignment strategy */
|
||||
moeoDiversityAssignment < MOEOT > & evalDiversity;
|
||||
/** the comparator (used to compare 2 individuals) */
|
||||
moeoComparator < MOEOT > & comparator;
|
||||
/** the number of individuals in the tournament */
|
||||
unsigned tSize;
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEODETTOURNAMENTSELECT_H_ */
|
||||
#endif /*MOEODETTOURNAMENTSELECT_H_*/
|
||||
|
|
|
|||
|
|
@ -10,105 +10,106 @@
|
|||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MOEOELITISTREPLACEMENT_H_
|
||||
#define MOEOELITISTREPLACEMENT_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <moeoReplacement.h>
|
||||
#include <moeoComparator.h>
|
||||
#include <moeoFitnessAssignment.h>
|
||||
#include <moeoDiversityAssignment.h>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Elitist replacement strategy for multi-objective optimization.
|
||||
*/
|
||||
template < class MOEOT > class moeoElitistReplacement:public moeoReplacement <
|
||||
MOEOT >
|
||||
template < class MOEOT > class moeoElitistReplacement:public moeoReplacement < MOEOT >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** Full constructor */
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > _comparator):evalFitness (_evalFitness), evalDiversity (_evalDiversity),
|
||||
comparator
|
||||
(_comparator)
|
||||
{
|
||||
}
|
||||
|
||||
/** constructor without comparator */
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity)
|
||||
:evalFitness (_evalFitness), evalDiversity (_evalDiversity)
|
||||
|
||||
{
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
/**
|
||||
* Full constructor.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _evalDiversity the diversity assignment strategy
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
*/
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _evalFitness, moeoDiversityAssignment < MOEOT > & _evalDiversity, moeoComparator < MOEOT > _comparator) :
|
||||
evalFitness (_evalFitness), evalDiversity (_evalDiversity), comparator (_comparator)
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor without comparator. A moeoFitThenDivComparator is used as default.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _evalDiversity the diversity assignment strategy
|
||||
*/
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _evalFitness, moeoDiversityAssignment < MOEOT > & _evalDiversity) :
|
||||
evalFitness (_evalFitness), evalDiversity (_evalDiversity)
|
||||
{
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor without moeoDiversityAssignement. A dummy diversity is used as default.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
*/
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _evalFitness, moeoComparator < MOEOT > _comparator) :
|
||||
evalFitness (_evalFitness), comparator (_comparator)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor without moeoDiversityAssignement nor moeoComparator.
|
||||
* A moeoFitThenDivComparator and a dummy diversity are used as default.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
*/
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _evalFitness) : evalFitness (_evalFitness)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the first population by adding the individuals of the second one, sorting with a moeoComparator and resizing the whole population obtained.
|
||||
* @param _parents the population composed of the parents (the population you want to replace)
|
||||
* @param _offspring the offspring population
|
||||
*/
|
||||
void operator () (eoPop < MOEOT > &_parents, eoPop < MOEOT > &_offspring)
|
||||
{
|
||||
unsigned sz = _parents.size ();
|
||||
// merges offspring and parents into a global population
|
||||
_parents.reserve (_parents.size () + _offspring.size ());
|
||||
copy (_offspring.begin (), _offspring.end (), back_inserter (_parents));
|
||||
// evaluates the fitness and the diversity of this global population
|
||||
evalFitness (_parents);
|
||||
evalDiversity (_parents);
|
||||
// sorts the whole population according to the comparator
|
||||
std::sort (_parents.begin (), _parents.end (), comparator);
|
||||
// finally, resize this global population
|
||||
_parents.resize (sz);
|
||||
// and clear the offspring population
|
||||
_offspring.clear ();
|
||||
}
|
||||
|
||||
/** Constructor without moeoDiversityAssignement */
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > _comparator):evalFitness (_evalFitness),
|
||||
comparator
|
||||
(_comparator)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
}
|
||||
|
||||
|
||||
/** Constructor without moeoDiversityAssignement nor moeoComparator */
|
||||
moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness):evalFitness
|
||||
(_evalFitness)
|
||||
{
|
||||
// a dummy diversity is used as default
|
||||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace the first population by adding the individuals of the second one, sorting with a moeoComparator and resizing the whole population obtained.
|
||||
* @param _parents the population composed of the parents (the population you want to replace)
|
||||
* @param _offspring
|
||||
*/
|
||||
void operator () (eoPop < MOEOT > &_parents, eoPop < MOEOT > &_offspring)
|
||||
{
|
||||
unsigned sz = _parents.size ();
|
||||
|
||||
// merge offspring and parents into a global population ...
|
||||
_parents.reserve (_parents.size () + _offspring.size ());
|
||||
copy (_offspring.begin (), _offspring.end (), back_inserter (_parents));
|
||||
|
||||
// evaluate the fitness and the diversity of this global population
|
||||
evalFitness (_parents);
|
||||
evalDiversity (_parents);
|
||||
|
||||
// ... that we sort according to the comparator
|
||||
std::sort (_parents.begin (), _parents.end (), comparator);
|
||||
|
||||
// finally, resize this global population
|
||||
_parents.resize (sz);
|
||||
|
||||
_offspring.clear ();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
moeoFitnessAssignment < MOEOT > &evalFitness;
|
||||
/** the fitness assignment strategy */
|
||||
moeoFitnessAssignment < MOEOT > &evalFitness;
|
||||
/** the diversity assignment strategy */
|
||||
moeoDiversityAssignment < MOEOT > &evalDiversity;
|
||||
/** the comparator (used to compare 2 individuals) */
|
||||
moeoComparator < MOEOT > &comparator;.
|
||||
|
||||
moeoDiversityAssignment < MOEOT > &evalDiversity;
|
||||
|
||||
moeoComparator < MOEOT > &comparator;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /*MOEOELITISTREPLACEMENT_H_ */
|
||||
|
|
|
|||
|
|
@ -24,24 +24,23 @@ template < class MOEOT > class moeoRandomSelect:public moeoSelectOne < MOEOT >,
|
|||
public:
|
||||
|
||||
/**
|
||||
* CTor.
|
||||
* Ctor.
|
||||
*/
|
||||
moeoRandomSelect(){}
|
||||
|
||||
/*
|
||||
* Do nothing: we don't need to evaluate the fitness and the diversity; we only select one individual at random.
|
||||
/**
|
||||
* Do nothing: we don't need to evaluate the fitness and the diversity; we only select one individual randomly.
|
||||
*/
|
||||
void setup (eoPop < MOEOT > &_pop)
|
||||
{
|
||||
// do nothing
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* Return one individual at random. // Need to have a "const" pop ?
|
||||
* Return one individual at random.
|
||||
*/
|
||||
const MOEOT & operator () (const eoPop < MOEOT > &_pop)
|
||||
{
|
||||
|
||||
eoRandomSelect < MOEOT >::operator ()(_pop);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
#include <moeoSelectors.h>
|
||||
|
||||
/**
|
||||
* moeoRouletteSelect: a selection method that selects ONE individual by
|
||||
* using roulette wheel process
|
||||
* Selection strategy that selects ONE individual by using roulette wheel process.
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoRouletteSelect:public moeoSelectOne <MOEOT>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Full Ctor
|
||||
* @param _evalFitness the population fitness assignment
|
||||
|
|
|
|||
|
|
@ -17,22 +17,22 @@
|
|||
#include <moeoSelectors.h>
|
||||
|
||||
/**
|
||||
* ???
|
||||
* Selection strategy that selects ONE individual by stochastic tournament.
|
||||
*/
|
||||
template < class MOEOT > class moeoStochTournamentSelect:public moeoSelectOne <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 _evalFitness the fitness assignment strategy
|
||||
* @param _evalDiversity the diversity assignment strategy
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
* @param _tRate the tournament rate
|
||||
*/
|
||||
moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > &_comparator, double _tRate = 1.0):evalFitness (_evalFitness), evalDiversity (_evalDiversity),
|
||||
comparator (_comparator),
|
||||
tRate (_tRate)
|
||||
{
|
||||
moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > & _evalFitness, moeoDiversityAssignment < MOEOT > & _evalDiversity, moeoComparator < MOEOT > & _comparator, double _tRate = 1.0) :
|
||||
evalFitness (_evalFitness), evalDiversity (_evalDiversity), comparator (_comparator), tRate (_tRate)
|
||||
{
|
||||
// consistency checks
|
||||
if (tRate < 0.5)
|
||||
{
|
||||
|
|
@ -51,12 +51,12 @@ moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDi
|
|||
|
||||
/**
|
||||
* Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
|
||||
* @param _evalFitness the population fitness assignment
|
||||
* @param _evalDiversity the population diversity assignment
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _evalDiversity the diversity assignment strategy
|
||||
* @param _tRate the tournament rate
|
||||
*/
|
||||
moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity)
|
||||
:evalFitness (_evalFitness), evalDiversity (_evalDiversity)
|
||||
moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, double _tRate = 1.0)
|
||||
:evalFitness (_evalFitness), evalDiversity (_evalDiversity), tRate (_tRate)
|
||||
|
||||
{
|
||||
// a moeoFitThenDivComparator is used as default
|
||||
|
|
@ -67,8 +67,9 @@ moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDi
|
|||
|
||||
/**
|
||||
* 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 _evalFitness the fitness assignment strategy
|
||||
* @param _comparator the comparator (used to compare 2 individuals)
|
||||
* @param _tRate the tournament rate
|
||||
*/
|
||||
moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > &_comparator, double _tRate = 1.0):evalFitness (_evalFitness), comparator (_comparator),
|
||||
tRate
|
||||
|
|
@ -97,7 +98,8 @@ moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoCo
|
|||
|
||||
/**
|
||||
* Ctor without diversity assignment nor comparator. A moeoDummyDiversityAssignment and a moeoFitnessThenDiversityComparator are used as default.
|
||||
* @param _evalFitness the population fitness assignment
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
* @param _tRate the tournament rate
|
||||
*/
|
||||
moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _tRate = 1.0):evalFitness (_evalFitness),
|
||||
tRate
|
||||
|
|
@ -128,20 +130,21 @@ moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* Evaluate the fitness and the diversity of each individual of the population.
|
||||
* @param _pop the population
|
||||
*/
|
||||
void setup (eoPop<MOEOT>& _pop)
|
||||
{
|
||||
// eval fitness
|
||||
evalFitness(_pop);
|
||||
|
||||
evalFitness(_pop);
|
||||
// eval diversity
|
||||
evalDiversity(_pop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the tournament to the given population
|
||||
* @param _pop the population
|
||||
*/
|
||||
const MOEOT & operator() (const eoPop < MOEOT > &_pop)
|
||||
{
|
||||
|
|
@ -152,15 +155,15 @@ moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double
|
|||
|
||||
|
||||
protected:
|
||||
/** the fitness assignment strategy */
|
||||
moeoFitnessAssignment < MOEOT > & evalFitness;
|
||||
/** the diversity assignment strategy */
|
||||
moeoDiversityAssignment < MOEOT > & evalDiversity;
|
||||
/** the diversity assignment strategy */
|
||||
moeoComparator < MOEOT > & comparator;
|
||||
/** the tournament rate */
|
||||
double tRate;
|
||||
|
||||
moeoFitnessAssignment < MOEOT > &evalFitness;
|
||||
|
||||
moeoDiversityAssignment < MOEOT > &evalDiversity;
|
||||
|
||||
moeoComparator < MOEOT > &comparator;
|
||||
|
||||
double tRate;
|
||||
};
|
||||
|
||||
|
||||
#endif /*MOEOSTOCHTOURNAMENTSELECT_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue