rename old
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@153 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
4c21c72510
commit
36ce33bd74
5 changed files with 0 additions and 1344 deletions
|
|
@ -1,420 +0,0 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "eoBinaryQualityIndicator.h"
|
||||
|
||||
// (c) OPAC Team, LIFL, June 2006
|
||||
|
||||
/* This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Arnaud.Liefooghe@lifl.fr
|
||||
*/
|
||||
|
||||
#ifndef _eoBinaryQualityIndicator_h
|
||||
#define _eoBinaryQualityIndicator_h
|
||||
|
||||
// for std::exceptions
|
||||
#include <stdexcept>
|
||||
// for eoBF
|
||||
#include <eoFunctor.h>
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* Binary quality indicator
|
||||
* Binary performance measure to use in the replacement selection process of IBEA (Indicator-Based Evolutionary Algorithm)
|
||||
* Of course, EOFitness needs to be an eoParetoFitness object
|
||||
*/
|
||||
template < class EOFitness > class eoBinaryQualityIndicator:public eoBF < const EOFitness &, const EOFitness &,
|
||||
double >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
eoBinaryQualityIndicator ():eoBF < const EOFitness &, const EOFitness &,
|
||||
double >()
|
||||
{
|
||||
bounds.reserve (traits::nObjectives ());
|
||||
bounds.resize (traits::nObjectives ());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the bounds for objective _iObj
|
||||
* @param unsigned _iObj the index of the objective
|
||||
* @param double _min the minimum value
|
||||
* @param double _max the maximum value
|
||||
*/
|
||||
void setBounds (const unsigned _iObj, const double _min, const double _max)
|
||||
{
|
||||
bounds[_iObj] = Range (_min, _max);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Private class to represent the bounds
|
||||
*/
|
||||
class Range
|
||||
{
|
||||
public:
|
||||
Range ()
|
||||
{
|
||||
min = 0;
|
||||
max = 0;
|
||||
r = 0;
|
||||
}
|
||||
Range (const double _min, const double _max)
|
||||
{
|
||||
min = _min;
|
||||
max = _max;
|
||||
r = max - min;
|
||||
if (r < 0)
|
||||
throw std::logic_error ("Negative range in eoBinaryQualityIndicator");
|
||||
}
|
||||
double minimum ()
|
||||
{
|
||||
return min;
|
||||
}
|
||||
double maximum ()
|
||||
{
|
||||
return max;
|
||||
}
|
||||
double range ()
|
||||
{
|
||||
return r;
|
||||
}
|
||||
private:
|
||||
double min, max, r;
|
||||
};
|
||||
|
||||
|
||||
/** range (min and max double value) for each objective */
|
||||
std::vector < Range > bounds;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** fitness traits */
|
||||
typedef typename EOFitness::fitness_traits traits;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* Additive binary epsilon indicator for eoParetoFitness
|
||||
*/
|
||||
template < class EOFitness > class eoAdditiveBinaryEpsilonIndicator:public eoBinaryQualityIndicator <
|
||||
EOFitness
|
||||
>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
eoAdditiveBinaryEpsilonIndicator ():eoBinaryQualityIndicator < EOFitness >
|
||||
()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation of the maximum epsilon value by which individual _eo1 must be
|
||||
* decreased in all objectives such that individual _eo2 is weakly dominated
|
||||
* (do not forget to set the bounds before the call of this function)
|
||||
* @param EOFitness & _fitness_eo1 the fitness of the first individual
|
||||
* @param EOFitness & _fitness_eo2 the fitness of the second individual
|
||||
*/
|
||||
double operator () (const EOFitness & _fitness_eo1,
|
||||
const EOFitness & _fitness_eo2)
|
||||
{
|
||||
double epsilon, tmp;
|
||||
// computation of the epsilon value for the first objective
|
||||
epsilon = epsilonValue (_fitness_eo1, _fitness_eo2, 0);
|
||||
// computation of the epsilon value for other objectives
|
||||
for (unsigned i = 1; i < traits::nObjectives (); i++)
|
||||
{
|
||||
tmp = epsilonValue (_fitness_eo1, _fitness_eo2, i);
|
||||
epsilon = std::max (epsilon, tmp);
|
||||
}
|
||||
// the maximum epsilon value
|
||||
return epsilon;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** fitness traits */
|
||||
typedef typename EOFitness::fitness_traits traits;
|
||||
/** bounds */
|
||||
using eoAdditiveBinaryEpsilonIndicator < EOFitness >::bounds;
|
||||
|
||||
|
||||
/**
|
||||
* computation of the epsilon value by which individual _eo1 must be
|
||||
* decreased in the objective _iObj such that individual _eo2 is weakly dominated
|
||||
* @param EOFitness & _fitness_eo1 the fitness of the first individual
|
||||
* @param EOFitness & _fitness_eo2 the fitness of the second individual
|
||||
* @param unsigned _iObj the index of the objective
|
||||
*/
|
||||
double epsilonValue (const EOFitness & _fitness_eo1,
|
||||
const EOFitness & _fitness_eo2, const unsigned _iObj)
|
||||
{
|
||||
double result;
|
||||
if (bounds[_iObj].range () == 0)
|
||||
{
|
||||
// min==max => every individuals has the same value for this objective
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// computation of the epsilon value for the objective _iObj (in case of a minimization)
|
||||
result =
|
||||
(_fitness_eo1[_iObj] -
|
||||
bounds[_iObj].minimum ()) / bounds[_iObj].range ();
|
||||
result -=
|
||||
(_fitness_eo2[_iObj] -
|
||||
bounds[_iObj].minimum ()) / bounds[_iObj].range ();
|
||||
// if we are maximizing, invert the value
|
||||
if (traits::maximizing (_iObj))
|
||||
result = -result;
|
||||
}
|
||||
// the espilon value
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* Binary hypervolume indicator for eoParetoFitness
|
||||
*/
|
||||
template < class EOFitness > class eoBinaryHypervolumeIndicator:public eoBinaryQualityIndicator <
|
||||
EOFitness >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param double _rho reference point for the hypervolume calculation (rho must not be smaller than 1)
|
||||
*/
|
||||
eoBinaryHypervolumeIndicator (double _rho):eoBinaryQualityIndicator < EOFitness >
|
||||
()
|
||||
{
|
||||
rho = _rho;
|
||||
// consistency check
|
||||
if (rho < 1)
|
||||
{
|
||||
cout <<
|
||||
"Warning, reference point rho for the hypervolume calculation must not be smaller than 1"
|
||||
<< endl;
|
||||
cout << "Adjusted to 1" << endl;
|
||||
rho = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* indicator value of the hypervolume of the portion of the objective space
|
||||
* that is dominated by individual _eo1 but not by individual _eo2
|
||||
* (don't forget to set the bounds before the call of this function)
|
||||
* @param EOFitness & _fitness_eo1 the fitness of the first individual
|
||||
* @param EOFitness & _fitness_eo2 the fitness of the second individual
|
||||
*/
|
||||
double operator () (const EOFitness & _fitness_eo1,
|
||||
const EOFitness & _fitness_eo2)
|
||||
{
|
||||
double result;
|
||||
if (_fitness_eo1.dominates (_fitness_eo2))
|
||||
result =
|
||||
-hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
traits::nObjectives ());
|
||||
else
|
||||
result =
|
||||
hypervolumeIndicatorValue (_fitness_eo2, _fitness_eo1,
|
||||
traits::nObjectives ());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** fitness traits */
|
||||
typedef typename EOFitness::fitness_traits traits;
|
||||
/** bounds */
|
||||
using eoBinaryHypervolumeIndicator < EOFitness >::bounds;
|
||||
|
||||
/** reference point for the hypervolume calculation */
|
||||
double rho;
|
||||
|
||||
|
||||
/**
|
||||
* computation of the hypervolume of the portion of the objective space
|
||||
* that is dominated by individual _eo1 but not by individual _eo2
|
||||
* @param EOFitness & _fitness_eo1 the fitness of the first individual
|
||||
* @param EOFitness & _fitness_eo2 the fitness of the second individual
|
||||
* @param unsigned _iObj number of objectives (used for iteration)
|
||||
* @param bool _flag = false (only used for iteration)
|
||||
*/
|
||||
double hypervolumeIndicatorValue (const EOFitness & _fitness_eo1,
|
||||
const EOFitness & _fitness_eo2,
|
||||
const unsigned _iObj, const bool _flag =
|
||||
false)
|
||||
{
|
||||
double result;
|
||||
if (bounds[_iObj - 1].range () == 0)
|
||||
{
|
||||
// min==max => every individuals as the same value for this objective
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (traits::maximizing (_iObj - 1)) // maximizing
|
||||
result =
|
||||
hypervolumeIndicatorValueMax (_fitness_eo1, _fitness_eo2, _iObj,
|
||||
_flag);
|
||||
else // minimizing
|
||||
result =
|
||||
hypervolumeIndicatorValueMin (_fitness_eo1, _fitness_eo2, _iObj,
|
||||
_flag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation of the hypervolume of the portion of the objective space
|
||||
* that is dominated by individual _eo1 but not by individual _eo2
|
||||
* in case of a minimization on the objective _iObj
|
||||
* @param EOFitness & _fitness_eo1 the fitness of the first individual
|
||||
* @param EOFitness & _fitness_eo2 the fitness of the second individual
|
||||
* @param unsigned _iObj index of the objective
|
||||
* @param bool _flag (only used for iteration)
|
||||
*/
|
||||
double hypervolumeIndicatorValueMin (const EOFitness & _fitness_eo1,
|
||||
const EOFitness & _fitness_eo2,
|
||||
const unsigned _iObj, const bool _flag)
|
||||
{
|
||||
double result;
|
||||
double r = rho * bounds[_iObj - 1].range ();
|
||||
double max = bounds[_iObj - 1].minimum () + r;
|
||||
// fitness of individuals _eo1 and _eo2 for the objective _iObj (if flag==true, _eo2 is not taken into account)
|
||||
double fitness_eo1 = _fitness_eo1[_iObj - 1];
|
||||
double fitness_eo2;
|
||||
if (_flag)
|
||||
fitness_eo2 = max;
|
||||
else
|
||||
fitness_eo2 = _fitness_eo2[_iObj - 1];
|
||||
// computation of the volume
|
||||
if (_iObj == 1)
|
||||
{
|
||||
if (fitness_eo1 < fitness_eo2)
|
||||
result = (fitness_eo2 - fitness_eo1) / r;
|
||||
else
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fitness_eo1 < fitness_eo2)
|
||||
{
|
||||
result =
|
||||
hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
_iObj - 1) * (max - fitness_eo2) / r;
|
||||
result +=
|
||||
hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
_iObj - 1,
|
||||
true) * (fitness_eo2 -
|
||||
fitness_eo1) / r;
|
||||
}
|
||||
else
|
||||
result =
|
||||
hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
_iObj - 1) * (max - fitness_eo2) / r;
|
||||
}
|
||||
// the volume
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation of the hypervolume of the portion of the objective space
|
||||
* that is dominated by individual _eo1 but not by individual _eo2
|
||||
* in case of a maximization on the objective _iObj
|
||||
* @param EOFitness & _fitness_eo1 the fitness of the first individual
|
||||
* @param EOFitness & _fitness_eo2 the fitness of the second individual
|
||||
* @param unsigned _iObj index of the objective
|
||||
* @param bool _flag (only used for iteration)
|
||||
*/
|
||||
double hypervolumeIndicatorValueMax (const EOFitness & _fitness_eo1,
|
||||
const EOFitness & _fitness_eo2,
|
||||
const unsigned _iObj, const bool _flag)
|
||||
{
|
||||
double result;
|
||||
double r = rho * bounds[_iObj - 1].range ();
|
||||
double min = bounds[_iObj - 1].maximum () - r;
|
||||
// fitness of individuals _eo1 and _eo2 for the objective _iObj (if flag==true, _eo2 is not taken into account)
|
||||
double fitness_eo1 = _fitness_eo1[_iObj - 1];
|
||||
double fitness_eo2;
|
||||
if (_flag)
|
||||
fitness_eo2 = min;
|
||||
else
|
||||
fitness_eo2 = _fitness_eo2[_iObj - 1];
|
||||
// computation of the volume
|
||||
if (_iObj == 1)
|
||||
{
|
||||
if (fitness_eo1 > fitness_eo2)
|
||||
result = (fitness_eo1 - fitness_eo2) / r;
|
||||
else
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fitness_eo1 > fitness_eo2)
|
||||
{
|
||||
result =
|
||||
hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
_iObj - 1) * (fitness_eo2 - min) / r;
|
||||
result +=
|
||||
hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
_iObj - 1,
|
||||
true) * (fitness_eo1 -
|
||||
fitness_eo2) / r;
|
||||
}
|
||||
else
|
||||
result =
|
||||
hypervolumeIndicatorValue (_fitness_eo1, _fitness_eo2,
|
||||
_iObj - 1) * (fitness_eo2 - min) / r;
|
||||
}
|
||||
// the volume
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,490 +0,0 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "eoIBEA.h"
|
||||
|
||||
// (c) OPAC Team, LIFL, June 2006
|
||||
|
||||
/* This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Arnaud.Liefooghe@lifl.fr
|
||||
*/
|
||||
|
||||
#ifndef _eoIBEASorting_h
|
||||
#define _eoIBEASorting_h
|
||||
|
||||
#include <math.h>
|
||||
#include <list>
|
||||
#include <eoPop.h>
|
||||
#include <eoPerf2Worth.h>
|
||||
#include "eoBinaryQualityIndicator.h"
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* The sorting phase of IBEA (Indicator-Based Evolutionary Algorithm)
|
||||
*/
|
||||
template < class EOT, class Fitness > class eoIBEA:public eoPerf2WorthCached < EOT,
|
||||
double >
|
||||
{
|
||||
|
||||
public:
|
||||
/** values */
|
||||
using eoIBEA < EOT, Fitness >::value;
|
||||
|
||||
eoIBEA (eoBinaryQualityIndicator < Fitness > *_I)
|
||||
{
|
||||
I = _I;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mapping
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void calculate_worths (const eoPop < EOT > &_pop)
|
||||
{
|
||||
/* resizing the worths beforehand */
|
||||
value ().resize (_pop.size ());
|
||||
|
||||
/* computation and setting of the bounds for each objective */
|
||||
setBounds (_pop);
|
||||
|
||||
/* computation of the fitness for each individual */
|
||||
fitnesses (_pop);
|
||||
|
||||
// higher is better, so invert the value
|
||||
double max = *std::max_element (value ().begin (), value ().end ());
|
||||
for (unsigned i = 0; i < value ().size (); i++)
|
||||
value ()[i] = max - value ()[i];
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** binary quality indicator to use in the selection process */
|
||||
eoBinaryQualityIndicator < Fitness > *I;
|
||||
|
||||
virtual void setBounds (const eoPop < EOT > &_pop) = 0;
|
||||
virtual void fitnesses (const eoPop < EOT > &_pop) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* The sorting phase of IBEA (Indicator-Based Evolutionary Algorithm) without uncertainty
|
||||
* Adapted from the Zitzler and Künzli paper "Indicator-Based Selection in Multiobjective Search" (2004)
|
||||
* Of course, Fitness needs to be an eoParetoFitness object
|
||||
*/
|
||||
template < class EOT, class Fitness = typename EOT::Fitness > class eoIBEASorting:public eoIBEA < EOT,
|
||||
Fitness
|
||||
>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param eoBinaryQualityIndicator<EOT>* _I the binary quality indicator to use in the selection process
|
||||
* @param double _kappa scaling factor kappa
|
||||
*/
|
||||
eoIBEASorting (eoBinaryQualityIndicator < Fitness > *_I,
|
||||
const double _kappa):
|
||||
eoIBEA <
|
||||
EOT,
|
||||
Fitness > (_I)
|
||||
{
|
||||
kappa = _kappa;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** quality indicator */
|
||||
using eoIBEASorting < EOT, Fitness >::I;
|
||||
/** values */
|
||||
using
|
||||
eoIBEA <
|
||||
EOT,
|
||||
Fitness >::value;
|
||||
/** scaling factor kappa */
|
||||
double
|
||||
kappa;
|
||||
|
||||
|
||||
/**
|
||||
* computation and setting of the bounds for each objective
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void
|
||||
setBounds (const eoPop < EOT > &_pop)
|
||||
{
|
||||
typedef typename
|
||||
EOT::Fitness::fitness_traits
|
||||
traits;
|
||||
double
|
||||
min,
|
||||
max;
|
||||
for (unsigned i = 0; i < traits::nObjectives (); i++)
|
||||
{
|
||||
min = _pop[0].fitness ()[i];
|
||||
max = _pop[0].fitness ()[i];
|
||||
for (unsigned j = 1; j < _pop.size (); j++)
|
||||
{
|
||||
min = std::min (min, _pop[j].fitness ()[i]);
|
||||
max = std::max (max, _pop[j].fitness ()[i]);
|
||||
}
|
||||
// setting of the bounds for the objective i
|
||||
I->setBounds (i, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation and setting of the fitness for each individual of the population
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void
|
||||
fitnesses (const eoPop < EOT > &_pop)
|
||||
{
|
||||
// reprsentation of the fitness components
|
||||
std::vector < std::vector < double > >
|
||||
fitComponents (_pop.size (), _pop.size ());
|
||||
// the maximum absolute indicator value
|
||||
double
|
||||
maxAbsoluteIndicatorValue = 0;
|
||||
|
||||
// computation of the indicator values and of the maximum absolute indicator value
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
for (unsigned j = 0; j < _pop.size (); j++)
|
||||
if (i != j)
|
||||
{
|
||||
fitComponents[i][j] =
|
||||
(*I) (_pop[i].fitness (), _pop[j].fitness ());
|
||||
maxAbsoluteIndicatorValue =
|
||||
std::max (maxAbsoluteIndicatorValue,
|
||||
fabs (fitComponents[i][j]));
|
||||
}
|
||||
|
||||
// computation of the fitness components for each pair of individuals
|
||||
// if maxAbsoluteIndicatorValue==0, every individuals have the same fitness values for all objectives (already = 0)
|
||||
if (maxAbsoluteIndicatorValue != 0)
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
for (unsigned j = 0; j < _pop.size (); j++)
|
||||
if (i != j)
|
||||
fitComponents[i][j] =
|
||||
exp (-fitComponents[i][j] /
|
||||
(maxAbsoluteIndicatorValue * kappa));
|
||||
|
||||
// computation of the fitness for each individual
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
{
|
||||
value ()[i] = 0;
|
||||
for (unsigned j = 0; j < _pop.size (); j++)
|
||||
if (i != j)
|
||||
value ()[i] += fitComponents[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* The sorting phase of IBEA (Indicator-Based Evolutionary Algorithm) under uncertainty
|
||||
* Adapted from the Basseur and Zitzler paper "Handling Uncertainty in Indicator-Based Multiobjective Optimization" (2006)
|
||||
* Of course, the fitness of an individual needs to be an eoStochasticParetoFitness object
|
||||
*/
|
||||
template < class EOT, class FitnessEval = typename EOT::Fitness::FitnessEval > class eoIBEAStochSorting:public eoIBEA < EOT,
|
||||
FitnessEval
|
||||
>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param eoBinaryQualityIndicator<EOT>* _I the binary quality indicator to use in the selection process
|
||||
*/
|
||||
eoIBEAStochSorting (eoBinaryQualityIndicator < FitnessEval > *_I):eoIBEA < EOT,
|
||||
FitnessEval >
|
||||
(_I)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** quality indicator */
|
||||
using eoIBEAStochSorting < EOT, FitnessEval >::I;
|
||||
/** values */
|
||||
using
|
||||
eoIBEAStochSorting <
|
||||
EOT,
|
||||
FitnessEval >::value;
|
||||
|
||||
|
||||
/**
|
||||
* approximated zero value
|
||||
*/
|
||||
static double
|
||||
zero ()
|
||||
{
|
||||
return 1e-7;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation and setting of the bounds for each objective
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void
|
||||
setBounds (const eoPop < EOT > &_pop)
|
||||
{
|
||||
typedef typename
|
||||
EOT::Fitness::FitnessTraits
|
||||
traits;
|
||||
double
|
||||
min,
|
||||
max;
|
||||
for (unsigned i = 0; i < traits::nObjectives (); i++)
|
||||
{
|
||||
min = _pop[0].fitness ().minimum (i);
|
||||
max = _pop[0].fitness ().maximum (i);
|
||||
for (unsigned j = 1; j < _pop.size (); j++)
|
||||
{
|
||||
min = std::min (min, _pop[j].fitness ().minimum (i));
|
||||
max = std::max (max, _pop[j].fitness ().maximum (i));
|
||||
}
|
||||
// setting of the bounds for the ith objective
|
||||
I->setBounds (i, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation and setting of the fitness for each individual of the population
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void
|
||||
fitnesses (const eoPop < EOT > &_pop)
|
||||
{
|
||||
typedef typename
|
||||
EOT::Fitness::FitnessTraits
|
||||
traits;
|
||||
unsigned
|
||||
nEval = traits::nEvaluations ();
|
||||
unsigned
|
||||
index;
|
||||
double
|
||||
eiv,
|
||||
p,
|
||||
sumP,
|
||||
iValue;
|
||||
std::list < std::pair < double, unsigned > > l;
|
||||
std::vector < unsigned >
|
||||
n (_pop.size ());
|
||||
|
||||
for (unsigned ind = 0; ind < _pop.size (); ind++)
|
||||
{
|
||||
value ()[ind] = 0.0; // fitness value for the individual ind
|
||||
for (unsigned eval = 0; eval < nEval; eval++)
|
||||
{
|
||||
|
||||
// I-values computation for the evaluation eval of the individual ind
|
||||
l.clear ();
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
{
|
||||
if (i != ind)
|
||||
{
|
||||
for (unsigned j = 0; j < nEval; j++)
|
||||
{
|
||||
std::pair < double, unsigned >
|
||||
pa;
|
||||
// I-value
|
||||
pa.first =
|
||||
(*I) (_pop[ind].fitness ()[eval],
|
||||
_pop[i].fitness ()[j]);
|
||||
// index of the individual
|
||||
pa.second = i;
|
||||
// append this to the list
|
||||
l.push_back (pa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sorting of the I-values (in decreasing order)
|
||||
l.sort ();
|
||||
|
||||
// computation of the Expected Indicator Value (eiv) for the evaluation eval of the individual ind
|
||||
eiv = 0.0;
|
||||
n.assign (n.size (), 0); // n[i]==0 for all i
|
||||
sumP = 0.0;
|
||||
while (((1 - sumP) > zero ()) && (l.size () > 0))
|
||||
{
|
||||
// we use the last element of the list (the greatest one)
|
||||
iValue = l.back ().first;
|
||||
index = l.back ().second;
|
||||
// computation of the probability to appear
|
||||
p = (1.0 / (nEval - n[index])) * (1.0 - sumP);
|
||||
// eiv update
|
||||
eiv += p * iValue;
|
||||
// update of the number of elements for individual index
|
||||
n[index]++;
|
||||
// removing the last element of the list
|
||||
l.pop_back ();
|
||||
// sum of p update
|
||||
sumP += p;
|
||||
}
|
||||
value ()[ind] += eiv / nEval;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functor
|
||||
* The sorting phase of IBEA (Indicator-Based Evolutionary Algorithm) under uncertainty using averaged values for each objective
|
||||
* Follow the idea presented in the Deb & Gupta paper "Searching for Robust Pareto-Optimal Solutions in Multi-Objective Optimization", 2005
|
||||
* Of course, the fitness of an individual needs to be an eoStochasticParetoFitness object
|
||||
*/
|
||||
template < class EOT, class FitnessEval = typename EOT::Fitness::FitnessEval > class eoIBEAAvgSorting:public eoIBEA < EOT,
|
||||
FitnessEval
|
||||
>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param eoBinaryQualityIndicator<EOT>* _I the binary quality indicator to use in the selection process
|
||||
* @param double _kappa scaling factor kappa
|
||||
*/
|
||||
eoIBEAAvgSorting (eoBinaryQualityIndicator < FitnessEval > *_I,
|
||||
const double _kappa):
|
||||
eoIBEA <
|
||||
EOT,
|
||||
FitnessEval > (_I)
|
||||
{
|
||||
kappa = _kappa;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** quality indicator */
|
||||
using eoIBEAAvgSorting < EOT, FitnessEval >::I;
|
||||
/** values */
|
||||
using
|
||||
eoIBEAAvgSorting <
|
||||
EOT,
|
||||
FitnessEval >::value;
|
||||
/** scaling factor kappa */
|
||||
double
|
||||
kappa;
|
||||
|
||||
|
||||
/**
|
||||
* computation and setting of the bounds for each objective
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void
|
||||
setBounds (const eoPop < EOT > &_pop)
|
||||
{
|
||||
typedef typename
|
||||
EOT::Fitness::FitnessTraits
|
||||
traits;
|
||||
double
|
||||
min,
|
||||
max;
|
||||
for (unsigned i = 0; i < traits::nObjectives (); i++)
|
||||
{
|
||||
min = _pop[0].fitness ().averagedParetoFitnessObject ()[i];
|
||||
max = _pop[0].fitness ().averagedParetoFitnessObject ()[i];
|
||||
for (unsigned j = 1; j < _pop.size (); j++)
|
||||
{
|
||||
min =
|
||||
std::min (min,
|
||||
_pop[j].fitness ().averagedParetoFitnessObject ()[i]);
|
||||
max =
|
||||
std::max (max,
|
||||
_pop[j].fitness ().averagedParetoFitnessObject ()[i]);
|
||||
}
|
||||
// setting of the bounds for the objective i
|
||||
I->setBounds (i, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* computation and setting of the fitness for each individual of the population
|
||||
* @param const eoPop<EOT>& _pop the population
|
||||
*/
|
||||
void
|
||||
fitnesses (const eoPop < EOT > &_pop)
|
||||
{
|
||||
// reprsentation of the fitness components
|
||||
std::vector < std::vector < double > >
|
||||
fitComponents (_pop.size (), _pop.size ());
|
||||
// the maximum absolute indicator value
|
||||
double
|
||||
maxAbsoluteIndicatorValue = 0;
|
||||
|
||||
// computation of the indicator values and of the maximum absolute indicator value
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
for (unsigned j = 0; j < _pop.size (); j++)
|
||||
if (i != j)
|
||||
{
|
||||
fitComponents[i][j] =
|
||||
(*I) (_pop[i].fitness ().averagedParetoFitnessObject (),
|
||||
_pop[j].fitness ().averagedParetoFitnessObject ());
|
||||
maxAbsoluteIndicatorValue =
|
||||
std::max (maxAbsoluteIndicatorValue,
|
||||
fabs (fitComponents[i][j]));
|
||||
}
|
||||
|
||||
// computation of the fitness components for each pair of individuals
|
||||
// if maxAbsoluteIndicatorValue==0, every individuals have the same fitness values for all objectives (already = 0)
|
||||
if (maxAbsoluteIndicatorValue != 0)
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
for (unsigned j = 0; j < _pop.size (); j++)
|
||||
if (i != j)
|
||||
fitComponents[i][j] =
|
||||
exp (-fitComponents[i][j] /
|
||||
(maxAbsoluteIndicatorValue * kappa));
|
||||
|
||||
// computation of the fitness for each individual
|
||||
for (unsigned i = 0; i < _pop.size (); i++)
|
||||
{
|
||||
value ()[i] = 0;
|
||||
for (unsigned j = 0; j < _pop.size (); j++)
|
||||
if (i != j)
|
||||
value ()[i] += fitComponents[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#include<eoParetoFitness.h>
|
||||
|
||||
template < class EOT, class DistType > class eoParetoPhenDist
|
||||
{
|
||||
public:
|
||||
virtual DistType operator ()(const EOT & eopf1, const EOT & eopf2) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//Euclidien distance
|
||||
|
||||
template < class EOT, class DistType =
|
||||
double >class eoParetoEuclidDist:public eoParetoPhenDist < EOT, DistType >
|
||||
{
|
||||
|
||||
public:
|
||||
DistType operator () (const EOT & eopf1, const EOT & eopf2)
|
||||
{
|
||||
double res = 0.0;
|
||||
double max = 0.0;
|
||||
double temp;
|
||||
for (unsigned i = 0; i < eopf1.fitness ().size (); ++i)
|
||||
{
|
||||
temp =
|
||||
(eopf1.fitness ().operator[](i) -
|
||||
eopf2.fitness ().operator[](i)) * (eopf1.fitness ().operator[](i) -
|
||||
eopf2.fitness ().operator[](i));
|
||||
if (temp > max)
|
||||
max = temp; /* for normalization */
|
||||
res = res + temp;
|
||||
}
|
||||
return sqrt (res / max);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
// -*- C++ -*-
|
||||
|
||||
#include <EO.h>
|
||||
#include <eoPerf2Worth.h>
|
||||
#include <old/eoParetoPhenDist.h>
|
||||
#include <eoParetoRanking.h>
|
||||
|
||||
template < class EOT, class worthT =
|
||||
double >class eoParetoSharing:public eoPerf2Worth < EOT, worthT >
|
||||
{
|
||||
public:
|
||||
|
||||
eoParetoSharing (double _nicheSize):eoPerf2Worth < EOT,
|
||||
worthT > ("ParetoSharing"), nicheSize (_nicheSize), dist (euc_dist),
|
||||
Dmax (_nicheSize)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eoParetoSharing (double _nicheSize, eoParetoPhenDist < EOT,
|
||||
worthT > &_dist):eoPerf2Worth < EOT,
|
||||
worthT > ("ParetoSharing"), nicheSize (_nicheSize), dist (_dist),
|
||||
Dmax (_nicheSize)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void operator () /*calculate_worths */ (const eoPop < EOT > &_pop)
|
||||
{
|
||||
|
||||
unsigned i, j, pSize = _pop.size ();
|
||||
//cout<<"**************************************************************************************\n";
|
||||
// std :: cout << "psize = " << pSize << std :: endl ;
|
||||
if (pSize <= 1)
|
||||
throw std::
|
||||
runtime_error ("Apptempt to do sharing with population of size 1");
|
||||
eoPerf2Worth < EOT, worthT >::value ().resize (pSize);
|
||||
std::vector < double >sim (pSize); // to hold the similarities
|
||||
|
||||
dMatrix distMatrix (pSize);
|
||||
|
||||
// compute the distance
|
||||
distMatrix[0][0] = 0;
|
||||
for (i = 1; i < pSize; i++)
|
||||
{
|
||||
distMatrix[i][i] = 0;
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
//if
|
||||
distMatrix[i][j] = distMatrix[j][i] = dist (_pop[i], _pop[j]);
|
||||
//cout<<" "<<distMatrix[j][i]<<" "<<dist(_pop[i],_pop[j])<<"\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//compute the similarities
|
||||
for (i = 0; i < pSize; i++)
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (j = 0; j < pSize; j++)
|
||||
|
||||
sum += sh (distMatrix[i][j], Dmax);
|
||||
sim[i] = sum;
|
||||
|
||||
//cout<<"\n i ----->"<<sim[i]<<"\n";
|
||||
}
|
||||
|
||||
eoDominanceMap < EOT > Dmap1;
|
||||
Dmap1.setup (_pop);
|
||||
|
||||
eoParetoRanking < EOT > rnk1 (Dmap1);
|
||||
rnk1.calculate_worths (_pop);
|
||||
// now set the worthes values
|
||||
for (i = 0; i < pSize; ++i)
|
||||
{
|
||||
typename EOT::Fitness v;
|
||||
|
||||
|
||||
|
||||
//cout<<"voila: "<<
|
||||
//rnk1.value().operator[](i);
|
||||
|
||||
//vector<double> v;
|
||||
//v.resize(_pop[i].fitness().size());
|
||||
//for(unsigned k=0;k<_pop[i].fitness().size();++k)
|
||||
//v[k]=_pop[i].fitness().operator[](k)/sim[i];
|
||||
//_pop[i].fitness(v);//.operator[](k)=0;//_pop[i].fitness().operator[](k)/sim[i];
|
||||
eoPerf2Worth < EOT, worthT >::value ()[i] = rnk1.value ().operator[](i) / sim[i]; //*_pop[i].fitness().operator[](1)*_pop[i].fitness().operator[](1));
|
||||
//cout<<"\n__________"<<pSize<<" "<<value()[i]<<" "<<i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class dMatrix:public std::vector < std::vector < double > >
|
||||
{
|
||||
public:
|
||||
dMatrix (unsigned _s):rSize (_s)
|
||||
{
|
||||
this->resize (_s);
|
||||
for (unsigned i = 0; i < _s; ++i)
|
||||
this->operator[] (i).resize (_s);
|
||||
}
|
||||
|
||||
void printOn (std::ostream & _os)
|
||||
{
|
||||
for (unsigned i = 0; i < rSize; i++)
|
||||
for (unsigned j = 0; j < rSize; ++j)
|
||||
{
|
||||
_os << this->operator[](i)[j] << " ";
|
||||
_os << endl;
|
||||
}
|
||||
_os << endl;
|
||||
}
|
||||
//public:
|
||||
//std::vector<double>v;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned rSize;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
;
|
||||
|
||||
double sh (double dist, double Dmax)
|
||||
{
|
||||
if (dist < Dmax)
|
||||
return (1.0 - dist / Dmax);
|
||||
else
|
||||
return (0.0);
|
||||
}
|
||||
|
||||
double nicheSize;
|
||||
eoParetoPhenDist < EOT, worthT > &dist;
|
||||
eoParetoEuclidDist < EOT > euc_dist;
|
||||
double Dmax;
|
||||
|
||||
};
|
||||
|
|
@ -1,250 +0,0 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_algo_MOEO.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_algo_MOEO_h
|
||||
#define _make_algo_MOEO_h
|
||||
|
||||
// the parser and parameter includes
|
||||
#include "utils/eoParser.h"
|
||||
#include "utils/eoState.h"
|
||||
// selections
|
||||
#include "eoNDSorting.h"
|
||||
#include "old/moeoIBEA.h"
|
||||
#include "old/moeoBinaryQualityIndicator.h"
|
||||
#include "eoParetoRanking.h"
|
||||
#include "moeoParetoSharing.h"
|
||||
#include "eoSelectFromWorth.h"
|
||||
#include "moeoSelectOneFromPopAndArch.h"
|
||||
// replacements
|
||||
#include "eoReplacement.h"
|
||||
#include "moeoReplacement.h"
|
||||
// breeders
|
||||
#include "eoGeneralBreeder.h"
|
||||
// the algorithm
|
||||
#include "eoEasyEA.h"
|
||||
|
||||
/*
|
||||
* This function builds the algorithm (i.e. selection and replacement) from existing continue (or checkpoint) and operators
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)
|
||||
*
|
||||
* NB: this function is almost cut-and-pasted from EO/make_algo_pareto.h and integrates MOEO features
|
||||
*/
|
||||
template < class EOT >
|
||||
eoAlgo < EOT > &do_make_algo_MOEO (eoParser & _parser, eoState & _state,
|
||||
eoEvalFunc < EOT > &_eval,
|
||||
eoContinue < EOT > &_continue,
|
||||
eoGenOp < EOT > &_op,
|
||||
moeoArchive < EOT > &_arch)
|
||||
{
|
||||
|
||||
// the fitness of an EOT object
|
||||
typedef typename EOT::Fitness EOFitness;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* the selection criteria */
|
||||
string & selStr = _parser.createParam (string ("NSGA-II"), "selCrit",
|
||||
"Multi-objective selection criterion: NSGA, NSGA-II, IBEA, ParetoRanking, ParetoSharing",
|
||||
'S', "Evolution Engine").value ();
|
||||
double nicheSize = _parser.createParam (1.0, "nicheSize",
|
||||
"Size of niche for NSGA-I or ParetoSharing",
|
||||
'n',
|
||||
"Evolution Engine").value ();
|
||||
double kappa =
|
||||
_parser.createParam (0.05, "kappa", "Scaling factor kappa for IBEA", 'k',
|
||||
"Evolution Engine").value ();
|
||||
string & indStr =
|
||||
_parser.createParam (string ("Epsilon"), "indicator",
|
||||
"Binary quality indicator for IBEA : Epsilon, Hypervolume",
|
||||
'I', "Evolution Engine").value ();
|
||||
double rho = _parser.createParam (1.1, "rho",
|
||||
"reference point for the hypervolume calculation (must not be smaller than 1)",
|
||||
'r', "Evolution Engine").value ();
|
||||
// the eoPerf2Worth object
|
||||
eoPerf2Worth < EOT, double >*p2w;
|
||||
if ((selStr == string ("NSGA")) || (selStr == string ("NSGA-I"))) // NSGA-I
|
||||
p2w = new eoNDSorting_I < EOT > (nicheSize);
|
||||
else if (selStr == string ("NSGA-II")) // NSGA-II
|
||||
p2w = new eoNDSorting_II < EOT > ();
|
||||
else if (selStr == string ("IBEA"))
|
||||
{ // IBEA
|
||||
// the binary quality indicator
|
||||
moeoBinaryQualityIndicator < EOFitness > *I;
|
||||
if (indStr == string ("Epsilon"))
|
||||
I = new moeoAdditiveBinaryEpsilonIndicator < EOFitness >;
|
||||
else if (indStr == string ("Hypervolume"))
|
||||
I = new moeoBinaryHypervolumeIndicator < EOFitness > (rho);
|
||||
else
|
||||
{
|
||||
string stmp =
|
||||
string ("Invalid binary quality indicator (for IBEA): ") + indStr;
|
||||
throw std::runtime_error (stmp.c_str ());
|
||||
}
|
||||
p2w = new moeoIBEASorting < EOT > (I, kappa);
|
||||
}
|
||||
else if (selStr == string ("ParetoRanking"))
|
||||
{ // Pareto Ranking
|
||||
eoDominanceMap < EOT > &dominance =
|
||||
_state.storeFunctor (new eoDominanceMap < EOT >);
|
||||
p2w = new eoParetoRanking < EOT > (dominance);
|
||||
}
|
||||
else if (selStr == string ("ParetoSharing"))
|
||||
{ // Pareto Sharing
|
||||
p2w = new moeoParetoSharing < EOT > (nicheSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
string stmp = string ("Invalid Pareto selection criterion: ") + selStr;
|
||||
throw std::runtime_error (stmp.c_str ());
|
||||
}
|
||||
// store
|
||||
_state.storeFunctor (p2w);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* the selector */
|
||||
eoValueParam < eoParamParamType > &selectionParam =
|
||||
_parser.createParam (eoParamParamType ("DetTour(2)"), "selection",
|
||||
"Selection: Roulette, DetTour(T), StochTour(t) or Random",
|
||||
's', "Evolution Engine");
|
||||
eoParamParamType & ppSelect = selectionParam.value (); // pair< string , vector<string> >
|
||||
// the select object
|
||||
eoSelectOne < EOT > *select;
|
||||
if (ppSelect.first == string ("DetTour"))
|
||||
{ // DetTour
|
||||
unsigned detSize;
|
||||
if (!ppSelect.second.size ())
|
||||
{ // no parameter added
|
||||
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
|
||||
detSize = 2;
|
||||
// put back 2 in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back (string ("2"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
detSize = atoi (ppSelect.second[0].c_str ());
|
||||
select = new eoDetTournamentWorthSelect < EOT > (*p2w, detSize);
|
||||
}
|
||||
else if (ppSelect.first == string ("StochTour"))
|
||||
{ // StochTour
|
||||
double p;
|
||||
if (!ppSelect.second.size ())
|
||||
{ // no parameter added
|
||||
cerr << "WARNING, no parameter passed to StochTour, using 1" <<
|
||||
endl;
|
||||
p = 1;
|
||||
// put back p in parameter for consistency (and status file)
|
||||
ppSelect.second.push_back (string ("1"));
|
||||
}
|
||||
else // parameter passed by user as DetTour(T)
|
||||
p = atof (ppSelect.second[0].c_str ());
|
||||
select = new eoStochTournamentWorthSelect < EOT > (*p2w, p);
|
||||
}
|
||||
else if (ppSelect.first == string ("Roulette"))
|
||||
{ // Roulette
|
||||
select = new eoRouletteWorthSelect < EOT > (*p2w);
|
||||
}
|
||||
else if (ppSelect.first == string ("Random"))
|
||||
{ // Random
|
||||
select = new eoRandomSelect < EOT >;
|
||||
}
|
||||
else
|
||||
{
|
||||
string stmp = string ("Invalid selection: ") + ppSelect.first;
|
||||
throw std::runtime_error (stmp.c_str ());
|
||||
}
|
||||
// store
|
||||
_state.storeFunctor (select);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* elitism */
|
||||
bool useElitism = _parser.createParam (false, "elitism",
|
||||
"Use elitism in the selection process (individuals from the archive are randomly selected)",
|
||||
'E', "Evolution Engine").value ();
|
||||
double ratioFromPop = _parser.createParam (0.8, "ratio",
|
||||
"Ratio from the population for elitism (must not be greater than 1)",
|
||||
'\0',
|
||||
"Evolution Engine").value ();
|
||||
if (useElitism)
|
||||
{
|
||||
eoSelectOne < EOT > *selectPop = select;
|
||||
select =
|
||||
new moeoSelectOneFromPopAndArch < EOT > (*selectPop, _arch,
|
||||
ratioFromPop);
|
||||
// store
|
||||
_state.storeFunctor (select);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* the number of offspring */
|
||||
eoValueParam < eoHowMany > &offspringRateParam =
|
||||
_parser.createParam (eoHowMany (1.0), "nbOffspring",
|
||||
"Nb of offspring (percentage or absolute)", 'O',
|
||||
"Evolution Engine");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* the replacement */
|
||||
string & repStr =
|
||||
_parser.createParam (string ("Plus"), "replacement",
|
||||
"Replacement: Plus, DistinctPlus or Generational",
|
||||
'R', "Evolution Engine").value ();
|
||||
eoReplacement < EOT > *replace;
|
||||
if (repStr == string ("Plus")) // Plus
|
||||
{
|
||||
replace = new moeoElitistReplacement < EOT, double >(*p2w);
|
||||
}
|
||||
else if (repStr == string ("DistinctPlus")) // DistinctPlus
|
||||
{
|
||||
replace = new moeoDisctinctElitistReplacement < EOT, double >(*p2w);
|
||||
}
|
||||
else if (repStr == string ("Generational")) // Generational
|
||||
{
|
||||
replace = new eoGenerationalReplacement < EOT >;
|
||||
}
|
||||
else
|
||||
{
|
||||
string stmp = string ("Invalid replacement: ") + repStr;
|
||||
throw std::runtime_error (stmp.c_str ());
|
||||
}
|
||||
// store
|
||||
_state.storeFunctor (replace);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// the general breeder
|
||||
eoGeneralBreeder < EOT > *breed =
|
||||
new eoGeneralBreeder < EOT > (*select, _op, offspringRateParam.value ());
|
||||
_state.storeFunctor (breed);
|
||||
|
||||
// the eoEasyEA
|
||||
eoAlgo < EOT > *algo =
|
||||
new eoEasyEA < EOT > (_continue, _eval, *breed, *replace);
|
||||
_state.storeFunctor (algo);
|
||||
// that's it!
|
||||
return *algo;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue