add front by front scheme + update doc

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@344 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-06-21 14:28:17 +00:00
commit e9cae8bdae

View file

@ -20,7 +20,6 @@
/**
* Diversity assignment sheme based on crowding distance proposed in:
* K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
* This strategy is, for instance, used in NSGA-II.
*/
template < class MOEOT >
class moeoCrowdingDistanceDiversityAssignment : public moeoDiversityAssignment < MOEOT >
@ -82,8 +81,78 @@ public:
}
protected:
/**
* Sets the distance values
* @param _pop the population
*/
virtual void setDistances (eoPop < MOEOT > & _pop)
{
double min, max, distance;
unsigned nObjectives = MOEOT::ObjectiveVector::nObjectives();
// set diversity to 0
for (unsigned i=0; i<_pop.size(); i++)
{
_pop[i].diversity(0);
}
// for each objective
for (unsigned obj=0; obj<nObjectives; obj++)
{
// comparator
moeoOneObjectiveComparator < MOEOT > comp(obj);
// sort
std::sort(_pop.begin(), _pop.end(), comp);
// min & max
min = _pop[0].objectiveVector()[obj];
max = _pop[_pop.size()-1].objectiveVector()[obj];
// set the diversity value to infiny for min and max
_pop[0].diversity(inf());
_pop[_pop.size()-1].diversity(inf());
for (unsigned i=1; i<_pop.size()-1; i++)
{
distance = (_pop[i+1].objectiveVector()[obj] - _pop[i-1].objectiveVector()[obj]) / (max-min);
_pop[i].diversity(_pop[i].diversity() + distance);
}
}
}
};
/**
* Diversity assignment sheme based on crowding distance proposed in:
* K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
* Tis strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II.
*/
template < class MOEOT >
class moeoFrontByFrontCrowdingDistanceDiversityAssignment : public moeoCrowdingDistanceDiversityAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* @warning NOT IMPLEMENTED, DO NOTHING !
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << endl;
}
private:
using moeoCrowdingDistanceDiversityAssignment < MOEOT >::inf;
using moeoCrowdingDistanceDiversityAssignment < MOEOT >::tiny;
/**
* Sets the distance values
* @param _pop the population
@ -106,7 +175,7 @@ private:
while (a < _pop.size())
{
b = lastIndex(_pop,a); // the front ends at b
// if there is 2 or less individuals in the front...
// if there is less than 2 individuals in the front...
if ((b-a) < 2)
{
for (unsigned i=a; i<=b; i++)
@ -164,7 +233,6 @@ private:
return i;
}
};
#endif /*MOEOCROWDINGDISTANCEDIVERSITYASSIGNMENT_H_*/