BIG update
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@210 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
cd07971ba2
commit
528a149107
27 changed files with 1891 additions and 344 deletions
|
|
@ -17,7 +17,9 @@
|
|||
#include <moeoComparator.h>
|
||||
#include <moeoFitnessAssignment.h>
|
||||
#include <moeoDiversityAssignment.h>
|
||||
|
||||
///////////////////////////////////////
|
||||
#include <eoRemoveDoubles.h>
|
||||
///////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Elitist replacement strategy for multi-objective optimization.
|
||||
|
|
@ -35,8 +37,8 @@ public:
|
|||
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
|
||||
|
|
@ -49,7 +51,8 @@ public:
|
|||
moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator;
|
||||
comparator = fitThenDivComparator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor without moeoDiversityAssignement. A dummy diversity is used as default.
|
||||
* @param _evalFitness the fitness assignment strategy
|
||||
|
|
@ -62,7 +65,8 @@ public:
|
|||
moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment;
|
||||
evalDiversity = dummyDiversityAssignment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor without moeoDiversityAssignement nor moeoComparator.
|
||||
* A moeoFitThenDivComparator and a dummy diversity are used as default.
|
||||
|
|
@ -78,6 +82,7 @@ public:
|
|||
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)
|
||||
|
|
@ -89,16 +94,20 @@ public:
|
|||
// merges offspring and parents into a global population
|
||||
_parents.reserve (_parents.size () + _offspring.size ());
|
||||
copy (_offspring.begin (), _offspring.end (), back_inserter (_parents));
|
||||
|
||||
//remove the doubles in the whole pop
|
||||
/****************************************************************************/
|
||||
eoRemoveDoubles < MOEOT > r;
|
||||
r(_parents);
|
||||
/****************************************************************************/
|
||||
|
||||
// evaluates the fitness and the diversity of this global population
|
||||
evalFitness (_parents);
|
||||
evalDiversity (_parents);
|
||||
|
||||
// sorts the whole population according to the comparator
|
||||
|
||||
/*************************************************************************/
|
||||
moeoFitnessThenDiversityComparator < MOEOT > comp;
|
||||
std::sort (_parents.begin (), _parents.end (), comp);
|
||||
/*************************************************************************/
|
||||
|
||||
Cmp cmp(comparator);
|
||||
std::sort(_parents.begin(), _parents.end(), cmp);
|
||||
// finally, resize this global population
|
||||
_parents.resize (sz);
|
||||
// and clear the offspring population
|
||||
|
|
@ -115,6 +124,18 @@ protected:
|
|||
/** the comparator (used to compare 2 individuals) */
|
||||
moeoComparator < MOEOT > & comparator;
|
||||
|
||||
class Cmp
|
||||
{
|
||||
public:
|
||||
Cmp(moeoComparator < MOEOT > & _comparator) : comparator(_comparator) {}
|
||||
bool operator()(const MOEOT & a, const MOEOT & b)
|
||||
{
|
||||
return comparator(a,b);
|
||||
}
|
||||
private:
|
||||
moeoComparator < MOEOT > & comparator;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOELITISTREPLACEMENT_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue