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
|
|
@ -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_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue