bug corrected on some Ctors
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1215 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
06e698095c
commit
9f24113e1c
1 changed files with 96 additions and 65 deletions
|
|
@ -38,8 +38,8 @@
|
||||||
#ifndef MOEOIBEA_H_
|
#ifndef MOEOIBEA_H_
|
||||||
#define MOEOIBEA_H_
|
#define MOEOIBEA_H_
|
||||||
|
|
||||||
|
|
||||||
#include <eoBreed.h>
|
#include <eoBreed.h>
|
||||||
|
#include <eoCloneOps.h>
|
||||||
#include <eoContinue.h>
|
#include <eoContinue.h>
|
||||||
#include <eoEvalFunc.h>
|
#include <eoEvalFunc.h>
|
||||||
#include <eoGenContinue.h>
|
#include <eoGenContinue.h>
|
||||||
|
|
@ -55,140 +55,171 @@
|
||||||
#include <selection/moeoDetTournamentSelect.h>
|
#include <selection/moeoDetTournamentSelect.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IBEA (Indicator-Based Evolutionary Algorithm) as described in:
|
* IBEA (Indicator-Based Evolutionary Algorithm).
|
||||||
* E. Zitzler, S. Künzli, "Indicator-Based Selection in Multiobjective Search", Proc. 8th International Conference on Parallel Problem Solving from Nature (PPSN VIII), pp. 832-842, Birmingham, UK (2004).
|
* E. Zitzler, S. Künzli, "Indicator-Based Selection in Multiobjective Search", Proc. 8th International Conference on Parallel Problem Solving from Nature (PPSN VIII), pp. 832-842, Birmingham, UK (2004).
|
||||||
* This class builds the IBEA algorithm only by using the fine-grained components of the ParadisEO-MOEO framework.
|
* This class builds the IBEA algorithm only by using the fine-grained components of the ParadisEO-MOEO framework.
|
||||||
*/
|
*/
|
||||||
template < class MOEOT >
|
template < class MOEOT >
|
||||||
class moeoIBEA : public moeoEA < MOEOT >
|
class moeoIBEA : public moeoEA < MOEOT >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** The type of objective vector */
|
/** The type of objective vector */
|
||||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple ctor with a eoGenOp.
|
* Ctor with a crossover, a mutation and their corresponding rates.
|
||||||
* @param _maxGen number of generations before stopping
|
* @param _maxGen maximum number of generations before stopping
|
||||||
* @param _eval evaluation function
|
* @param _eval evaluation function
|
||||||
* @param _op variation operator
|
* @param _crossover crossover
|
||||||
* @param _metric metric
|
* @param _pCross crossover probability
|
||||||
* @param _kappa scaling factor kappa
|
* @param _mutation mutation
|
||||||
*/
|
* @param _pMut mutation probability
|
||||||
moeoIBEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
* @param _metric metric
|
||||||
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select(2),
|
* @param _kappa scaling factor kappa
|
||||||
fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, dummyDiversityAssignment), genBreed(select, _op), breed(genBreed)
|
*/
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple ctor with a eoTransform.
|
|
||||||
* @param _maxGen number of generations before stopping
|
|
||||||
* @param _eval evaluation function
|
|
||||||
* @param _op variation operator
|
|
||||||
* @param _metric metric
|
|
||||||
* @param _kappa scaling factor kappa
|
|
||||||
*/
|
|
||||||
moeoIBEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
|
||||||
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select(2),
|
|
||||||
fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, dummyDiversityAssignment), genBreed(select, _op), breed(genBreed)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ctor with a crossover, a mutation and their corresponding rates.
|
|
||||||
* @param _maxGen number of generations before stopping
|
|
||||||
* @param _eval evaluation function
|
|
||||||
* @param _crossover crossover
|
|
||||||
* @param _pCross crossover probability
|
|
||||||
* @param _mutation mutation
|
|
||||||
* @param _pMut mutation probability
|
|
||||||
* @param _metric metric
|
|
||||||
* @param _kappa scaling factor kappa
|
|
||||||
*/
|
|
||||||
moeoIBEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
moeoIBEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
||||||
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), popEval(_eval), select (2),
|
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select (2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment)
|
||||||
fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, dummyDiversityAssignment), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut),
|
|
||||||
genBreed (select, defaultSGAGenOp), breed (genBreed)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ctor with a continuator (instead of _maxGen) and a eoGenOp.
|
* Ctor with a eoContinue and a eoGenOp.
|
||||||
* @param _continuator stopping criteria
|
* @param _continuator stopping criteria
|
||||||
* @param _eval evaluation function
|
* @param _eval evaluation function
|
||||||
* @param _op variation operator
|
* @param _op variation operators
|
||||||
* @param _metric metric
|
* @param _metric metric
|
||||||
* @param _kappa scaling factor kappa
|
* @param _kappa scaling factor kappa
|
||||||
*/
|
*/
|
||||||
moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
||||||
continuator(_continuator), popEval(_eval), select(2),
|
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2),
|
||||||
fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, dummyDiversityAssignment), genBreed(select, _op), breed(genBreed)
|
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ctor with a continuator (instead of _maxGen) and a eoTransform.
|
* Ctor with a eoContinue, a eoPopEval and a eoGenOp.
|
||||||
* @param _continuator stopping criteria
|
* @param _continuator stopping criteria
|
||||||
* @param _eval evaluation function
|
* @param _popEval population evaluation function
|
||||||
* @param _op variation operator
|
* @param _op variation operators
|
||||||
* @param _metric metric
|
* @param _metric metric
|
||||||
* @param _kappa scaling factor kappa
|
* @param _kappa scaling factor kappa
|
||||||
*/
|
*/
|
||||||
moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
||||||
continuator(_continuator), popEval(_eval), select(2),
|
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2),
|
||||||
fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, dummyDiversityAssignment), genBreed(select, _op), breed(genBreed)
|
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a few generation of evolution to the population _pop until the stopping criteria is verified.
|
* Ctor with a eoContinue and a eoTransform.
|
||||||
|
* @param _continuator stopping criteria
|
||||||
|
* @param _eval evaluation function
|
||||||
|
* @param _transform variation operator
|
||||||
|
* @param _metric metric
|
||||||
|
* @param _kappa scaling factor kappa
|
||||||
|
*/
|
||||||
|
moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
||||||
|
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval),
|
||||||
|
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, diversityAssignment)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
|
||||||
|
* @param _continuator stopping criteria
|
||||||
|
* @param _popEval population evaluation function
|
||||||
|
* @param _transform variation operator
|
||||||
|
* @param _metric metric
|
||||||
|
* @param _kappa scaling factor kappa
|
||||||
|
*/
|
||||||
|
moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
|
||||||
|
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval),
|
||||||
|
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, diversityAssignment)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the algorithm to the population _pop until the stopping criteria is satified.
|
||||||
* @param _pop the population
|
* @param _pop the population
|
||||||
*/
|
*/
|
||||||
virtual void operator () (eoPop < MOEOT > &_pop)
|
virtual void operator () (eoPop < MOEOT > &_pop)
|
||||||
{
|
{
|
||||||
eoPop < MOEOT > offspring, empty_pop;
|
eoPop < MOEOT > offspring, empty_pop;
|
||||||
popEval (empty_pop, _pop); // a first eval of _pop
|
popEval (empty_pop, _pop); // a first eval of _pop
|
||||||
// evaluate fitness and diversity
|
// evaluate fitness and diversity
|
||||||
fitnessAssignment(_pop);
|
fitnessAssignment(_pop);
|
||||||
dummyDiversityAssignment(_pop);
|
diversityAssignment(_pop);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// generate offspring, worths are recalculated if necessary
|
// generate offspring, worths are recalculated if necessary
|
||||||
breed (_pop, offspring);
|
breed (_pop, offspring);
|
||||||
// eval of offspring
|
// eval of offspring
|
||||||
popEval (_pop, offspring);
|
popEval (_pop, offspring);
|
||||||
// after replace, the new pop is in _pop. Worths are recalculated if necessary
|
// after replace, the new pop is in _pop. Worths are recalculated if necessary
|
||||||
replace (_pop, offspring);
|
replace (_pop, offspring);
|
||||||
}
|
}
|
||||||
while (continuator (_pop));
|
while (continuator (_pop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** a continuator based on the number of generations (used as default) */
|
/** a continuator based on the number of generations (used as default) */
|
||||||
eoGenContinue < MOEOT > defaultGenContinuator;
|
eoGenContinue < MOEOT > defaultGenContinuator;
|
||||||
/** stopping criteria */
|
/** stopping criteria */
|
||||||
eoContinue < MOEOT > & continuator;
|
eoContinue < MOEOT > & continuator;
|
||||||
|
/** default eval */
|
||||||
|
class DummyEval : public eoEvalFunc < MOEOT >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void operator()(MOEOT &) {}
|
||||||
|
}
|
||||||
|
defaultEval;
|
||||||
|
/** evaluation function */
|
||||||
|
eoEvalFunc < MOEOT > & eval;
|
||||||
|
/** default popEval */
|
||||||
|
eoPopLoopEval < MOEOT > defaultPopEval;
|
||||||
/** evaluation function used to evaluate the whole population */
|
/** evaluation function used to evaluate the whole population */
|
||||||
eoPopLoopEval < MOEOT > popEval;
|
eoPopEvalFunc < MOEOT > & popEval;
|
||||||
|
/** default select */
|
||||||
|
class DummySelect : public eoSelect < MOEOT >
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
|
||||||
|
}
|
||||||
|
defaultSelect;
|
||||||
/** binary tournament selection */
|
/** binary tournament selection */
|
||||||
moeoDetTournamentSelect < MOEOT > select;
|
moeoDetTournamentSelect < MOEOT > select;
|
||||||
/** fitness assignment used in IBEA */
|
/** default select many */
|
||||||
moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > fitnessAssignment;
|
eoSelectMany < MOEOT > selectMany;
|
||||||
/** dummy diversity assignment */
|
/** select transform */
|
||||||
moeoDummyDiversityAssignment < MOEOT > dummyDiversityAssignment;
|
eoSelectTransform < MOEOT > selectTransform;
|
||||||
/** elitist replacement */
|
/** a default crossover */
|
||||||
moeoEnvironmentalReplacement < MOEOT > replace;
|
eoQuadCloneOp < MOEOT > defaultQuadOp;
|
||||||
|
/** a default mutation */
|
||||||
|
eoMonCloneOp < MOEOT > defaultMonOp;
|
||||||
/** an object for genetic operators (used as default) */
|
/** an object for genetic operators (used as default) */
|
||||||
eoSGAGenOp < MOEOT > defaultSGAGenOp;
|
eoSGAGenOp < MOEOT > defaultSGAGenOp;
|
||||||
|
/** default transform */
|
||||||
|
class DummyTransform : public eoTransform < MOEOT >
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
void operator()(eoPop<MOEOT>&) {}
|
||||||
|
}
|
||||||
|
defaultTransform;
|
||||||
/** general breeder */
|
/** general breeder */
|
||||||
eoGeneralBreeder < MOEOT > genBreed;
|
eoGeneralBreeder < MOEOT > genBreed;
|
||||||
/** breeder */
|
/** breeder */
|
||||||
eoBreed < MOEOT > & breed;
|
eoBreed < MOEOT > & breed;
|
||||||
|
/** fitness assignment used in IBEA */
|
||||||
|
moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > fitnessAssignment;
|
||||||
|
/** dummy diversity assignment */
|
||||||
|
moeoDummyDiversityAssignment < MOEOT > diversityAssignment;
|
||||||
|
/** environmental replacement */
|
||||||
|
moeoEnvironmentalReplacement < MOEOT > replace;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*MOEOIBEA_H_*/
|
#endif /*MOEOIBEA_H_*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue