New style for MOEO

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@788 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2007-11-16 11:29:25 +00:00
commit 39709d3d12
103 changed files with 2607 additions and 2521 deletions

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoAchievementFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -47,8 +47,8 @@
*/
template < class MOEOT >
class moeoAchievementFitnessAssignment : public moeoScalarFitnessAssignment < MOEOT >
{
public:
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -62,11 +62,11 @@ public:
*/
moeoAchievementFitnessAssignment(ObjectiveVector & _reference, std::vector < double > & _lambdas, double _spn=0.0001) : reference(_reference), lambdas(_lambdas), spn(_spn)
{
// consistency check
if ((spn < 0.0) || (spn > 1.0))
// consistency check
if ((spn < 0.0) || (spn > 1.0))
{
std::cout << "Warning, the arbitrary small positive number should be > 0 and <<1, adjusted to 0.0001\n";
spn = 0.0001;
std::cout << "Warning, the arbitrary small positive number should be > 0 and <<1, adjusted to 0.0001\n";
spn = 0.0001;
}
}
@ -78,17 +78,17 @@ public:
*/
moeoAchievementFitnessAssignment(ObjectiveVector & _reference, double _spn=0.0001) : reference(_reference), spn(_spn)
{
// compute the default values for lambdas
lambdas = std::vector < double > (ObjectiveVector::nObjectives());
for (unsigned int i=0 ; i<lambdas.size(); i++)
// compute the default values for lambdas
lambdas = std::vector < double > (ObjectiveVector::nObjectives());
for (unsigned int i=0 ; i<lambdas.size(); i++)
{
lambdas[i] = 1.0 / ObjectiveVector::nObjectives();
lambdas[i] = 1.0 / ObjectiveVector::nObjectives();
}
// consistency check
if ((spn < 0.0) || (spn > 1.0))
// consistency check
if ((spn < 0.0) || (spn > 1.0))
{
std::cout << "Warning, the arbitrary small positive number should be > 0 and <<1, adjusted to 0.0001\n";
spn = 0.0001;
std::cout << "Warning, the arbitrary small positive number should be > 0 and <<1, adjusted to 0.0001\n";
spn = 0.0001;
}
}
@ -99,9 +99,9 @@ public:
*/
virtual void operator()(eoPop < MOEOT > & _pop)
{
for (unsigned int i=0; i<_pop.size() ; i++)
for (unsigned int i=0; i<_pop.size() ; i++)
{
compute(_pop[i]);
compute(_pop[i]);
}
}
@ -113,7 +113,7 @@ public:
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
// nothing to do ;-)
// nothing to do ;-)
}
@ -123,11 +123,11 @@ public:
*/
void setReference(const ObjectiveVector & _reference)
{
reference = _reference;
reference = _reference;
}
private:
private:
/** the reference point */
ObjectiveVector reference;
@ -141,9 +141,9 @@ private:
* Returns a big value (regarded as infinite)
*/
double inf() const
{
{
return std::numeric_limits<double>::max();
}
}
/**
@ -152,19 +152,19 @@ private:
*/
void compute(MOEOT & _moeo)
{
unsigned int nobj = MOEOT::ObjectiveVector::nObjectives();
double temp;
double min = inf();
double sum = 0;
for (unsigned int obj=0; obj<nobj; obj++)
unsigned int nobj = MOEOT::ObjectiveVector::nObjectives();
double temp;
double min = inf();
double sum = 0;
for (unsigned int obj=0; obj<nobj; obj++)
{
temp = lambdas[obj] * (reference[obj] - _moeo.objectiveVector()[obj]);
min = std::min(min, temp);
sum += temp;
temp = lambdas[obj] * (reference[obj] - _moeo.objectiveVector()[obj]);
min = std::min(min, temp);
sum += temp;
}
_moeo.fitness(min + spn*sum);
_moeo.fitness(min + spn*sum);
}
};
};
#endif /*MOEOACHIEVEMENTFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoBinaryIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT >
class moeoBinaryIndicatorBasedFitnessAssignment : public moeoIndicatorBasedFitnessAssignment < MOEOT >
{
public:
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -60,6 +60,6 @@ public:
*/
virtual double updateByAdding(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) = 0;
};
};
#endif /*MOEOINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoCriterionBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,6 +44,7 @@
* moeoCriterionBasedFitnessAssignment is a moeoFitnessAssignment for criterion-based strategies.
*/
template < class MOEOT >
class moeoCriterionBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT > {};
class moeoCriterionBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOCRITERIONBASEDFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoDummyFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT >
class moeoDummyFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{
public:
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -58,12 +58,12 @@ public:
*/
void operator () (eoPop < MOEOT > & _pop)
{
for (unsigned int idx = 0; idx<_pop.size (); idx++)
for (unsigned int idx = 0; idx<_pop.size (); idx++)
{
if (_pop[idx].invalidFitness())
if (_pop[idx].invalidFitness())
{
// set the diversity to 0
_pop[idx].fitness(0.0);
// set the diversity to 0
_pop[idx].fitness(0.0);
}
}
}
@ -76,9 +76,9 @@ public:
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
// nothing to do... ;-)
// nothing to do... ;-)
}
};
};
#endif /*MOEODUMMYFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoExpBinaryIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -52,8 +52,8 @@
*/
template < class MOEOT >
class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >
{
public:
{
public:
/** The type of objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -74,12 +74,12 @@ public:
*/
void operator()(eoPop < MOEOT > & _pop)
{
// 1 - setting of the bounds
setup(_pop);
// 2 - computing every indicator values
computeValues(_pop);
// 3 - setting fitnesses
setFitnesses(_pop);
// 1 - setting of the bounds
setup(_pop);
// 2 - computing every indicator values
computeValues(_pop);
// 3 - setting fitnesses
setFitnesses(_pop);
}
@ -90,15 +90,15 @@ public:
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::vector < double > v;
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
std::vector < double > v;
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
v[i] = metric(_objVec, _pop[i].objectiveVector());
v[i] = metric(_objVec, _pop[i].objectiveVector());
}
for (unsigned int i=0; i<_pop.size(); i++)
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness( _pop[i].fitness() + exp(-v[i]/kappa) );
_pop[i].fitness( _pop[i].fitness() + exp(-v[i]/kappa) );
}
}
@ -111,34 +111,34 @@ public:
*/
double updateByAdding(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::vector < double > v;
// update every fitness values to take the new individual into account
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
std::vector < double > v;
// update every fitness values to take the new individual into account
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
v[i] = metric(_objVec, _pop[i].objectiveVector());
v[i] = metric(_objVec, _pop[i].objectiveVector());
}
for (unsigned int i=0; i<_pop.size(); i++)
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness( _pop[i].fitness() - exp(-v[i]/kappa) );
_pop[i].fitness( _pop[i].fitness() - exp(-v[i]/kappa) );
}
// compute the fitness of the new individual
v.clear();
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
// compute the fitness of the new individual
v.clear();
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
v[i] = metric(_pop[i].objectiveVector(), _objVec);
v[i] = metric(_pop[i].objectiveVector(), _objVec);
}
double result = 0;
for (unsigned int i=0; i<v.size(); i++)
double result = 0;
for (unsigned int i=0; i<v.size(); i++)
{
result -= exp(-v[i]/kappa);
result -= exp(-v[i]/kappa);
}
return result;
return result;
}
protected:
protected:
/** the quality indicator */
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & metric;
@ -154,18 +154,18 @@ protected:
*/
void setup(const eoPop < MOEOT > & _pop)
{
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
min = _pop[0].objectiveVector()[i];
max = _pop[0].objectiveVector()[i];
for (unsigned int j=1; j<_pop.size(); j++)
min = _pop[0].objectiveVector()[i];
max = _pop[0].objectiveVector()[i];
for (unsigned int j=1; j<_pop.size(); j++)
{
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
}
// setting of the bounds for the objective i
metric.setup(min, max, i);
// setting of the bounds for the objective i
metric.setup(min, max, i);
}
}
@ -176,16 +176,16 @@ protected:
*/
void computeValues(const eoPop < MOEOT > & _pop)
{
values.clear();
values.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
values.clear();
values.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
values[i].resize(_pop.size());
for (unsigned int j=0; j<_pop.size(); j++)
values[i].resize(_pop.size());
for (unsigned int j=0; j<_pop.size(); j++)
{
if (i != j)
if (i != j)
{
values[i][j] = metric(_pop[i].objectiveVector(), _pop[j].objectiveVector());
values[i][j] = metric(_pop[i].objectiveVector(), _pop[j].objectiveVector());
}
}
}
@ -198,9 +198,9 @@ protected:
*/
void setFitnesses(eoPop < MOEOT > & _pop)
{
for (unsigned int i=0; i<_pop.size(); i++)
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness(computeFitness(i));
_pop[i].fitness(computeFitness(i));
}
}
@ -211,17 +211,17 @@ protected:
*/
double computeFitness(const unsigned int _idx)
{
double result = 0;
for (unsigned int i=0; i<values.size(); i++)
double result = 0;
for (unsigned int i=0; i<values.size(); i++)
{
if (i != _idx)
if (i != _idx)
{
result -= exp(-values[i][_idx]/kappa);
result -= exp(-values[i][_idx]/kappa);
}
}
return result;
return result;
}
};
};
#endif /*MOEOEXPBINARYINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoFastNonDominatedSortingFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -55,8 +55,8 @@
*/
template < class MOEOT >
class moeoFastNonDominatedSortingFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
{
public:
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -83,37 +83,37 @@ public:
*/
void operator()(eoPop < MOEOT > & _pop)
{
// number of objectives for the problem under consideration
unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives();
if (nObjectives == 1)
// number of objectives for the problem under consideration
unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives();
if (nObjectives == 1)
{
// one objective
oneObjective(_pop);
// one objective
oneObjective(_pop);
}
else if (nObjectives == 2)
else if (nObjectives == 2)
{
// two objectives (the two objectives function is still to implement)
mObjectives(_pop);
// two objectives (the two objectives function is still to implement)
mObjectives(_pop);
}
else if (nObjectives > 2)
else if (nObjectives > 2)
{
// more than two objectives
mObjectives(_pop);
// more than two objectives
mObjectives(_pop);
}
else
else
{
// problem with the number of objectives
throw std::runtime_error("Problem with the number of objectives in moeoNonDominatedSortingFitnessAssignment");
// problem with the number of objectives
throw std::runtime_error("Problem with the number of objectives in moeoNonDominatedSortingFitnessAssignment");
}
// a higher fitness is better, so the values need to be inverted
double max = _pop[0].fitness();
for (unsigned int i=1 ; i<_pop.size() ; i++)
// a higher fitness is better, so the values need to be inverted
double max = _pop[0].fitness();
for (unsigned int i=1 ; i<_pop.size() ; i++)
{
max = std::max(max, _pop[i].fitness());
max = std::max(max, _pop[i].fitness());
}
for (unsigned int i=0 ; i<_pop.size() ; i++)
for (unsigned int i=0 ; i<_pop.size() ; i++)
{
_pop[i].fitness(max - _pop[i].fitness());
_pop[i].fitness(max - _pop[i].fitness());
}
}
@ -125,40 +125,41 @@ public:
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
for (unsigned int i=0; i<_pop.size(); i++)
for (unsigned int i=0; i<_pop.size(); i++)
{
// if _pop[i] is dominated by _objVec
if ( comparator(_pop[i].objectiveVector(), _objVec) )
// if _pop[i] is dominated by _objVec
if ( comparator(_pop[i].objectiveVector(), _objVec) )
{
_pop[i].fitness(_pop[i].fitness()+1);
_pop[i].fitness(_pop[i].fitness()+1);
}
}
}
private:
private:
/** Functor to compare two objective vectors */
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** Functor allowing to compare two solutions according to their first objective value, then their second, and so on. */
class ObjectiveComparator : public moeoComparator < MOEOT >
{
public:
/**
* Returns true if _moeo1 < _moeo2 on the first objective, then on the second, and so on
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector());
}
private:
/** the corresponding comparator for objective vectors */
moeoObjectiveObjectiveVectorComparator < ObjectiveVector > cmp;
} objComparator;
class ObjectiveComparator : public moeoComparator < MOEOT >
{
public:
/**
* Returns true if _moeo1 < _moeo2 on the first objective, then on the second, and so on
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector());
}
private:
/** the corresponding comparator for objective vectors */
moeoObjectiveObjectiveVectorComparator < ObjectiveVector > cmp;
}
objComparator;
/**
@ -167,18 +168,18 @@ private:
*/
void oneObjective (eoPop < MOEOT > & _pop)
{
// sorts the population in the ascending order
std::sort(_pop.begin(), _pop.end(), objComparator);
// assign fitness values
unsigned int rank = 1;
_pop[_pop.size()-1].fitness(rank);
for (unsigned int i=_pop.size()-2; i>=0; i--)
// sorts the population in the ascending order
std::sort(_pop.begin(), _pop.end(), objComparator);
// assign fitness values
unsigned int rank = 1;
_pop[_pop.size()-1].fitness(rank);
for (unsigned int i=_pop.size()-2; i>=0; i--)
{
if (_pop[i].objectiveVector() != _pop[i+1].objectiveVector())
if (_pop[i].objectiveVector() != _pop[i+1].objectiveVector())
{
rank++;
rank++;
}
_pop[i].fitness(rank);
_pop[i].fitness(rank);
}
}
@ -189,7 +190,7 @@ private:
*/
void twoObjectives (eoPop < MOEOT > & _pop)
{
//... TO DO !
//... TO DO !
}
@ -199,66 +200,66 @@ private:
*/
void mObjectives (eoPop < MOEOT > & _pop)
{
// S[i] = indexes of the individuals dominated by _pop[i]
std::vector < std::vector<unsigned int> > S(_pop.size());
// n[i] = number of individuals that dominate the individual _pop[i]
std::vector < unsigned int > n(_pop.size(), 0);
// fronts: F[i] = indexes of the individuals contained in the ith front
std::vector < std::vector<unsigned int> > F(_pop.size()+2);
// used to store the number of the first front
F[1].reserve(_pop.size());
for (unsigned int p=0; p<_pop.size(); p++)
// S[i] = indexes of the individuals dominated by _pop[i]
std::vector < std::vector<unsigned int> > S(_pop.size());
// n[i] = number of individuals that dominate the individual _pop[i]
std::vector < unsigned int > n(_pop.size(), 0);
// fronts: F[i] = indexes of the individuals contained in the ith front
std::vector < std::vector<unsigned int> > F(_pop.size()+2);
// used to store the number of the first front
F[1].reserve(_pop.size());
for (unsigned int p=0; p<_pop.size(); p++)
{
for (unsigned int q=0; q<_pop.size(); q++)
for (unsigned int q=0; q<_pop.size(); q++)
{
// if q is dominated by p
if ( comparator(_pop[q].objectiveVector(), _pop[p].objectiveVector()) )
// if q is dominated by p
if ( comparator(_pop[q].objectiveVector(), _pop[p].objectiveVector()) )
{
// add q to the set of solutions dominated by p
S[p].push_back(q);
// add q to the set of solutions dominated by p
S[p].push_back(q);
}
// if p is dominated by q
else if ( comparator(_pop[p].objectiveVector(), _pop[q].objectiveVector()) )
// if p is dominated by q
else if ( comparator(_pop[p].objectiveVector(), _pop[q].objectiveVector()) )
{
// increment the domination counter of p
n[p]++;
// increment the domination counter of p
n[p]++;
}
}
// if no individual dominates p
if (n[p] == 0)
// if no individual dominates p
if (n[p] == 0)
{
// p belongs to the first front
_pop[p].fitness(1);
F[1].push_back(p);
// p belongs to the first front
_pop[p].fitness(1);
F[1].push_back(p);
}
}
// front counter
unsigned int counter=1;
unsigned int p,q;
while (! F[counter].empty())
// front counter
unsigned int counter=1;
unsigned int p,q;
while (! F[counter].empty())
{
// used to store the number of the next front
F[counter+1].reserve(_pop.size());
for (unsigned int i=0; i<F[counter].size(); i++)
// used to store the number of the next front
F[counter+1].reserve(_pop.size());
for (unsigned int i=0; i<F[counter].size(); i++)
{
p = F[counter][i];
for (unsigned int j=0; j<S[p].size(); j++)
p = F[counter][i];
for (unsigned int j=0; j<S[p].size(); j++)
{
q = S[p][j];
n[q]--;
// if no individual dominates q anymore
if (n[q] == 0)
q = S[p][j];
n[q]--;
// if no individual dominates q anymore
if (n[q] == 0)
{
// q belongs to the next front
_pop[q].fitness(counter+1);
F[counter+1].push_back(q);
// q belongs to the next front
_pop[q].fitness(counter+1);
F[counter+1].push_back(q);
}
}
}
counter++;
counter++;
}
}
};
};
#endif /*MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -46,8 +46,8 @@
*/
template < class MOEOT >
class moeoFitnessAssignment : public eoUF < eoPop < MOEOT > &, void >
{
public:
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -68,9 +68,9 @@ public:
*/
void updateByDeleting(eoPop < MOEOT > & _pop, MOEOT & _moeo)
{
updateByDeleting(_pop, _moeo.objectiveVector());
updateByDeleting(_pop, _moeo.objectiveVector());
}
};
};
#endif /*MOEOFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,6 +44,7 @@
* moeoIndicatorBasedFitnessAssignment is a moeoFitnessAssignment for Indicator-based strategies.
*/
template < class MOEOT >
class moeoIndicatorBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT > {};
class moeoIndicatorBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoParetoBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,6 +44,7 @@
* moeoParetoBasedFitnessAssignment is a moeoFitnessAssignment for Pareto-based strategies.
*/
template < class MOEOT >
class moeoParetoBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT > {};
class moeoParetoBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOPARETOBASEDFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoReferencePointIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -48,8 +48,8 @@
*/
template < class MOEOT >
class moeoReferencePointIndicatorBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{
public:
{
public:
/** The type of objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -60,7 +60,7 @@ public:
* @param _metric the quality indicator
*/
moeoReferencePointIndicatorBasedFitnessAssignment (ObjectiveVector & _refPoint, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric) :
refPoint(_refPoint), metric(_metric)
refPoint(_refPoint), metric(_metric)
{}
@ -70,10 +70,10 @@ public:
*/
void operator()(eoPop < MOEOT > & _pop)
{
// 1 - setting of the bounds
setup(_pop);
// 2 - setting fitnesses
setFitnesses(_pop);
// 1 - setting of the bounds
setup(_pop);
// 2 - setting fitnesses
setFitnesses(_pop);
}
@ -84,11 +84,11 @@ public:
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
// nothing to do ;-)
// nothing to do ;-)
}
protected:
protected:
/** the reference point */
ObjectiveVector & refPoint;
@ -102,18 +102,18 @@ protected:
*/
void setup(const eoPop < MOEOT > & _pop)
{
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
min = refPoint[i];
max = refPoint[i];
for (unsigned int j=0; j<_pop.size(); j++)
min = refPoint[i];
max = refPoint[i];
for (unsigned int j=0; j<_pop.size(); j++)
{
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
}
// setting of the bounds for the objective i
metric.setup(min, max, i);
// setting of the bounds for the objective i
metric.setup(min, max, i);
}
}
@ -123,12 +123,12 @@ protected:
*/
void setFitnesses(eoPop < MOEOT > & _pop)
{
for (unsigned int i=0; i<_pop.size(); i++)
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness(- metric(_pop[i].objectiveVector(), refPoint) );
_pop[i].fitness(- metric(_pop[i].objectiveVector(), refPoint) );
}
}
};
};
#endif /*MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoScalarFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,6 +44,7 @@
* moeoScalarFitnessAssignment is a moeoFitnessAssignment for scalar strategies.
*/
template < class MOEOT >
class moeoScalarFitnessAssignment : public moeoFitnessAssignment < MOEOT > {};
class moeoScalarFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOSCALARFITNESSASSIGNMENT_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoUnaryIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,6 +44,7 @@
* moeoIndicatorBasedFitnessAssignment for unary indicators.
*/
template < class MOEOT >
class moeoUnaryIndicatorBasedFitnessAssignment : public moeoIndicatorBasedFitnessAssignment < MOEOT > {};
class moeoUnaryIndicatorBasedFitnessAssignment : public moeoIndicatorBasedFitnessAssignment < MOEOT >
{};
#endif /*MOEOINDICATORBASEDFITNESSASSIGNMENT_H_*/