update do

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@376 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-06-26 12:11:08 +00:00
commit 7698e2267e
4 changed files with 91 additions and 82 deletions

View file

@ -21,11 +21,11 @@
#include <utils/selectors.h> #include <utils/selectors.h>
#include <utils/eoParser.h> #include <utils/eoParser.h>
#include <utils/eoState.h> #include <utils/eoState.h>
#include <moeoArchiveUpdater.h>
#include <moeoArchiveObjectiveVectorSavingUpdater.h>
#include <metric/moeoBinaryMetricSavingUpdater.h>
#include <metric/moeoContributionMetric.h> #include <metric/moeoContributionMetric.h>
#include <metric/moeoEntropyMetric.h> #include <metric/moeoEntropyMetric.h>
#include <utils/moeoArchiveUpdater.h>
#include <utils/moeoArchiveObjectiveVectorSavingUpdater.h>
#include <utils/moeoBinaryMetricSavingUpdater.h>
bool testDirRes(std::string _dirName, bool _erase); bool testDirRes(std::string _dirName, bool _erase);
@ -51,9 +51,9 @@ eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState &
// is nb Eval to be used as counter? // is nb Eval to be used as counter?
//bool useEval = _parser.getORcreateParam(true, "useEval", "Use nb of eval. as counter (vs nb of gen.)", '\0', "Output").value(); //bool useEval = _parser.getORcreateParam(true, "useEval", "Use nb of eval. as counter (vs nb of gen.)", '\0', "Output").value();
// Create anyway a generation-counter parameter // Create anyway a generation-counter parameter
eoValueParam<unsigned> *generationCounter = new eoValueParam<unsigned>(0, "Gen."); eoValueParam<unsigned int> *generationCounter = new eoValueParam<unsigned int>(0, "Gen.");
// Create an incrementor (sub-class of eoUpdater). // Create an incrementor (sub-class of eoUpdater).
eoIncrementor<unsigned> & increment = _state.storeFunctor( new eoIncrementor<unsigned>(generationCounter->value()) ); eoIncrementor<unsigned int> & increment = _state.storeFunctor( new eoIncrementor<unsigned int>(generationCounter->value()) );
// Add it to the checkpoint // Add it to the checkpoint
checkpoint.add(increment); checkpoint.add(increment);
// dir for DISK output // dir for DISK output
@ -77,13 +77,13 @@ eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState &
////////////////////////////// //////////////////////////////
// feed the state to state savers // feed the state to state savers
// save state every N generation // save state every N generation
eoValueParam<unsigned>& saveFrequencyParam = _parser.createParam(unsigned(0), "saveFrequency", "Save every F generation (0 = only final state, absent = never)", '\0', "Persistence" ); eoValueParam<unsigned int>& saveFrequencyParam = _parser.createParam((unsigned int)(0), "saveFrequency", "Save every F generation (0 = only final state, absent = never)", '\0', "Persistence" );
if (_parser.isItThere(saveFrequencyParam)) if (_parser.isItThere(saveFrequencyParam))
{ {
// first make sure dirName is OK // first make sure dirName is OK
if (! dirOK ) if (! dirOK )
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX ); unsigned int freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
#ifdef _MSVC #ifdef _MSVC
std::string stmp = dirName + "\generations"; std::string stmp = dirName + "\generations";
#else #else
@ -94,7 +94,7 @@ eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState &
checkpoint.add(*stateSaver1); checkpoint.add(*stateSaver1);
} }
// save state every T seconds // save state every T seconds
eoValueParam<unsigned>& saveTimeIntervalParam = _parser.getORcreateParam(unsigned(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" ); eoValueParam<unsigned int>& saveTimeIntervalParam = _parser.getORcreateParam((unsigned int)(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" );
if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0) if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
{ {
// first make sure dirName is OK // first make sure dirName is OK

View file

@ -54,7 +54,7 @@ eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eo
eoCombinedContinue<MOEOT> *continuator = NULL; eoCombinedContinue<MOEOT> *continuator = NULL;
// First the eoGenContinue - need a default value so you can run blind // First the eoGenContinue - need a default value so you can run blind
// but we also need to be able to avoid it <--> 0 // but we also need to be able to avoid it <--> 0
eoValueParam<unsigned>& maxGenParam = _parser.createParam(unsigned(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion"); eoValueParam<unsigned int>& maxGenParam = _parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
if (maxGenParam.value()) // positive: -> define and store if (maxGenParam.value()) // positive: -> define and store
{ {
eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value()); eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
@ -63,7 +63,7 @@ eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eo
continuator = make_combinedContinue<MOEOT>(continuator, genCont); continuator = make_combinedContinue<MOEOT>(continuator, genCont);
} }
// maxEval // maxEval
eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion"); eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)(0), "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
if (maxEvalParam.value()) if (maxEvalParam.value())
{ {
eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value()); eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value());
@ -72,7 +72,7 @@ eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eo
continuator = make_combinedContinue<MOEOT>(continuator, evalCont); continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
} }
// maxTime // maxTime
eoValueParam<unsigned long>& maxTimeParam = _parser.getORcreateParam((unsigned long)0, "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion"); eoValueParam<unsigned long>& maxTimeParam = _parser.getORcreateParam((unsigned long)(0), "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion");
if (maxTimeParam.value()) // positive: -> define and store if (maxTimeParam.value()) // positive: -> define and store
{ {
eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value()); eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());

View file

@ -20,26 +20,35 @@
#include <eoGenOp.h> #include <eoGenOp.h>
#include <utils/eoParser.h> #include <utils/eoParser.h>
#include <utils/eoState.h> #include <utils/eoState.h>
#include <moeoArchive.h>
#include <moeoComparator.h> #include <algo/moeoEA.h>
#include <moeoCrowdingDistanceDiversityAssignment.h> #include <algo/moeoEasyEA.h>
#include <moeoDetTournamentSelect.h> #include <archive/moeoArchive.h>
#include <moeoDiversityAssignment.h> #include <comparator/moeoAggregativeComparator.h>
#include <moeoEA.h> #include <comparator/moeoComparator.h>
#include <moeoEasyEA.h> #include <comparator/moeoDiversityThenFitnessComparator.h>
#include <moeoElitistReplacement.h> #include <comparator/moeoFitnessThenDiversityComparator.h>
#include <moeoEnvironmentalReplacement.h> #include <diversity/moeoDiversityAssignment.h>
#include <moeoFastNonDominatedSortingFitnessAssignment.h> #include <diversity/moeoDummyDiversityAssignment.h>
#include <moeoFitnessAssignment.h> #include <diversity/moeoFrontByFrontCrowdingDistanceDiversityAssignment.h>
#include <moeoGenerationalReplacement.h> #include <diversity/moeoFrontByFrontSharingDiversityAssignment.h>
#include <moeoIndicatorBasedFitnessAssignment.h> #include <fitness/moeoFastNonDominatedSortingFitnessAssignment.h>
#include <moeoRandomSelect.h> #include <fitness/moeoDummyFitnessAssignment.h>
#include <moeoReplacement.h> #include <fitness/moeoFitnessAssignment.h>
#include <moeoRouletteSelect.h> #include <fitness/moeoIndicatorBasedFitnessAssignment.h>
#include <moeoSelectOne.h> #include <metric/moeoAdditiveEpsilonBinaryMetric.h>
#include <moeoSharingDiversityAssignment.h> #include <metric/moeoHypervolumeBinaryMetric.h>
#include <moeoStochTournamentSelect.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h> #include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
#include <replacement/moeoElitistReplacement.h>
#include <replacement/moeoEnvironmentalReplacement.h>
#include <replacement/moeoGenerationalReplacement.h>
#include <replacement/moeoReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
#include <selection/moeoRandomSelect.h>
#include <selection/moeoStochTournamentSelect.h>
#include <selection/moeoSelectOne.h>
#include <selection/moeoSelectors.h>
/** /**
* This functions allows to build a moeoEA from the parser * This functions allows to build a moeoEA from the parser
@ -59,10 +68,10 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
/* the fitness assignment strategy */ /* the fitness assignment strategy */
string & fitnessParam = _parser.createParam(string("FastNonDominatedSorting"), "fitness", std::string & fitnessParam = _parser.createParam(std::string("FastNonDominatedSorting"), "fitness",
"Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased", 'F', "Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased", 'F',
"Evolution Engine").value(); "Evolution Engine").value();
string & indicatorParam = _parser.createParam(string("Epsilon"), "indicator", std::string & indicatorParam = _parser.createParam(std::string("Epsilon"), "indicator",
"Binary indicator for IndicatorBased: Epsilon, Hypervolume", 'i', "Binary indicator for IndicatorBased: Epsilon, Hypervolume", 'i',
"Evolution Engine").value(); "Evolution Engine").value();
double rho = _parser.createParam(1.1, "rho", "reference point for the hypervolume indicator", 'r', double rho = _parser.createParam(1.1, "rho", "reference point for the hypervolume indicator", 'r',
@ -70,36 +79,36 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
double kappa = _parser.createParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased", 'k', double kappa = _parser.createParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased", 'k',
"Evolution Engine").value(); "Evolution Engine").value();
moeoFitnessAssignment < MOEOT > * fitnessAssignment; moeoFitnessAssignment < MOEOT > * fitnessAssignment;
if (fitnessParam == string("Dummy")) if (fitnessParam == std::string("Dummy"))
{ {
fitnessAssignment = new moeoDummyFitnessAssignment < MOEOT> (); fitnessAssignment = new moeoDummyFitnessAssignment < MOEOT> ();
} }
else if (fitnessParam == string("FastNonDominatedSorting")) else if (fitnessParam == std::string("FastNonDominatedSorting"))
{ {
fitnessAssignment = new moeoFastNonDominatedSortingFitnessAssignment < MOEOT> (); fitnessAssignment = new moeoFastNonDominatedSortingFitnessAssignment < MOEOT> ();
} }
else if (fitnessParam == string("IndicatorBased")) else if (fitnessParam == std::string("IndicatorBased"))
{ {
// metric // metric
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric; moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
if (indicatorParam == string("Epsilon")) if (indicatorParam == std::string("Epsilon"))
{ {
metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >; metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
} }
else if (indicatorParam == string("Hypervolume")) else if (indicatorParam == std::string("Hypervolume"))
{ {
metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho); metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
} }
else else
{ {
string stmp = string("Invalid binary quality indicator: ") + indicatorParam; std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT > (*metric, kappa); fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT > (*metric, kappa);
} }
else else
{ {
string stmp = string("Invalid fitness assignment strategy: ") + fitnessParam; std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(fitnessAssignment); _state.storeFunctor(fitnessAssignment);
@ -110,16 +119,16 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
"Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding", 'D', "Evolution Engine"); "Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding", 'D', "Evolution Engine");
eoParamParamType & diversityParamValue = diversityParam.value(); eoParamParamType & diversityParamValue = diversityParam.value();
moeoDiversityAssignment < MOEOT > * diversityAssignment; moeoDiversityAssignment < MOEOT > * diversityAssignment;
if (diversityParamValue.first == string("Dummy")) if (diversityParamValue.first == std::string("Dummy"))
{ {
diversityAssignment = new moeoDummyDiversityAssignment < MOEOT> (); diversityAssignment = new moeoDummyDiversityAssignment < MOEOT> ();
} }
else if (diversityParamValue.first == string("Sharing")) else if (diversityParamValue.first == std::string("Sharing"))
{ {
double nicheSize; double nicheSize;
if (!diversityParamValue.second.size()) // no parameter added if (!diversityParamValue.second.size()) // no parameter added
{ {
cerr << "WARNING, no niche size given for Sharing, using 0.5" << std::endl; std::cerr << "WARNING, no niche size given for Sharing, using 0.5" << std::endl;
nicheSize = 0.5; nicheSize = 0.5;
diversityParamValue.second.push_back(std::string("0.5")); diversityParamValue.second.push_back(std::string("0.5"));
} }
@ -129,37 +138,37 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
} }
diversityAssignment = new moeoFrontByFrontSharingDiversityAssignment < MOEOT> (nicheSize); diversityAssignment = new moeoFrontByFrontSharingDiversityAssignment < MOEOT> (nicheSize);
} }
else if (diversityParamValue.first == string("Crowding")) else if (diversityParamValue.first == std::string("Crowding"))
{ {
diversityAssignment = new moeoFrontByFrontCrowdingDistanceDiversityAssignment < MOEOT> (); diversityAssignment = new moeoFrontByFrontCrowdingDistanceDiversityAssignment < MOEOT> ();
} }
else else
{ {
string stmp = string("Invalid diversity assignment strategy: ") + diversityParamValue.first; std::string stmp = std::string("Invalid diversity assignment strategy: ") + diversityParamValue.first;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(diversityAssignment); _state.storeFunctor(diversityAssignment);
/* the comparator strategy */ /* the comparator strategy */
string & comparatorParam = _parser.createParam(string("FitnessThenDiversity"), "comparator", std::string & comparatorParam = _parser.createParam(std::string("FitnessThenDiversity"), "comparator",
"Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative", 'C', "Evolution Engine").value(); "Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative", 'C', "Evolution Engine").value();
moeoComparator < MOEOT > * comparator; moeoComparator < MOEOT > * comparator;
if (comparatorParam == string("FitnessThenDiversity")) if (comparatorParam == std::string("FitnessThenDiversity"))
{ {
comparator = new moeoFitnessThenDiversityComparator < MOEOT> (); comparator = new moeoFitnessThenDiversityComparator < MOEOT> ();
} }
else if (comparatorParam == string("DiversityThenFitness")) else if (comparatorParam == std::string("DiversityThenFitness"))
{ {
comparator = new moeoDiversityThenFitnessComparator < MOEOT> (); comparator = new moeoDiversityThenFitnessComparator < MOEOT> ();
} }
else if (comparatorParam == string("Aggregative")) else if (comparatorParam == std::string("Aggregative"))
{ {
comparator = new moeoAggregativeComparator < MOEOT> (); comparator = new moeoAggregativeComparator < MOEOT> ();
} }
else else
{ {
string stmp = string("Invalid comparator strategy: ") + comparatorParam; std::string stmp = std::string("Invalid comparator strategy: ") + comparatorParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(comparator); _state.storeFunctor(comparator);
@ -170,15 +179,15 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
"Selection scheme: DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine"); "Selection scheme: DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine");
eoParamParamType & ppSelect = selectionParam.value(); eoParamParamType & ppSelect = selectionParam.value();
moeoSelectOne < MOEOT > * select; moeoSelectOne < MOEOT > * select;
if (ppSelect.first == string("DetTour")) if (ppSelect.first == std::string("DetTour"))
{ {
unsigned tSize; unsigned int tSize;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl; std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
tSize = 2; tSize = 2;
// put back 2 in parameter for consistency (and status file) // put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(string("2")); ppSelect.second.push_back(std::string("2"));
} }
else // parameter passed by user as DetTour(T) else // parameter passed by user as DetTour(T)
{ {
@ -186,15 +195,15 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
} }
select = new moeoDetTournamentSelect < MOEOT > (*comparator, tSize); select = new moeoDetTournamentSelect < MOEOT > (*comparator, tSize);
} }
else if (ppSelect.first == string("StochTour")) else if (ppSelect.first == std::string("StochTour"))
{ {
double tRate; double tRate;
if (!ppSelect.second.size()) // no parameter added if (!ppSelect.second.size()) // no parameter added
{ {
cerr << "WARNING, no parameter passed to StochTour, using 1" << endl; std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
tRate = 1; tRate = 1;
// put back 1 in parameter for consistency (and status file) // put back 1 in parameter for consistency (and status file)
ppSelect.second.push_back(string("1")); ppSelect.second.push_back(std::string("1"));
} }
else // parameter passed by user as StochTour(T) else // parameter passed by user as StochTour(T)
{ {
@ -209,37 +218,37 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF
// ... // ...
} }
*/ */
else if (ppSelect.first == string("Random")) else if (ppSelect.first == std::string("Random"))
{ {
select = new moeoRandomSelect <MOEOT > (); select = new moeoRandomSelect <MOEOT > ();
} }
else else
{ {
string stmp = string("Invalid selection strategy: ") + ppSelect.first; std::string stmp = std::string("Invalid selection strategy: ") + ppSelect.first;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(select); _state.storeFunctor(select);
/* the replacement strategy */ /* the replacement strategy */
string & replacementParam = _parser.createParam(string("Elitist"), "replacement", std::string & replacementParam = _parser.createParam(std::string("Elitist"), "replacement",
"Replacement scheme: Elitist, Environmental or Generational", 'R', "Evolution Engine").value(); "Replacement scheme: Elitist, Environmental or Generational", 'R', "Evolution Engine").value();
moeoReplacement < MOEOT > * replace; moeoReplacement < MOEOT > * replace;
if (replacementParam == string("Elitist")) if (replacementParam == std::string("Elitist"))
{ {
replace = new moeoElitistReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator); replace = new moeoElitistReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
} }
else if (replacementParam == string("Environmental")) else if (replacementParam == std::string("Environmental"))
{ {
replace = new moeoEnvironmentalReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator); replace = new moeoEnvironmentalReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
} }
else if (replacementParam == string("Generational")) else if (replacementParam == std::string("Generational"))
{ {
replace = new moeoGenerationalReplacement < MOEOT> (); replace = new moeoGenerationalReplacement < MOEOT> ();
} }
else else
{ {
string stmp = string("Invalid replacement strategy: ") + replacementParam; std::string stmp = std::string("Invalid replacement strategy: ") + replacementParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(replace); _state.storeFunctor(replace);

View file

@ -18,13 +18,13 @@
#include <eoGenOp.h> #include <eoGenOp.h>
#include <utils/eoParser.h> #include <utils/eoParser.h>
#include <utils/eoState.h> #include <utils/eoState.h>
#include <moeoArchive.h> #include <algo/moeoIBMOLS.h>
#include <moeoIndicatorBasedFitnessAssignment.h> #include <algo/moeoIteratedIBMOLS.h>
#include <moeoLS.h> #include <algo/moeoLS.h>
#include <moeoIndicatorBasedLS.h> #include <archive/moeoArchive.h>
#include <moeoIteratedIBMOLS.h> #include <fitness/moeoIndicatorBasedFitnessAssignment.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h> #include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
#include <moeoMoveIncrEval.h> #include <move/moeoMoveIncrEval.h>
/** /**
* This functions allows to build a moeoLS from the parser * This functions allows to build a moeoLS from the parser
@ -56,10 +56,10 @@ moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo (
/* the objective vector type */ /* the objective vector type */
typedef typename MOEOT::ObjectiveVector ObjectiveVector; typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/* the fitness assignment strategy */ /* the fitness assignment strategy */
string & fitnessParam = _parser.getORcreateParam(string("IndicatorBased"), "fitness", std::string & fitnessParam = _parser.getORcreateParam(std::string("IndicatorBased"), "fitness",
"Fitness assignment strategy parameter: IndicatorBased...", 'F', "Fitness assignment strategy parameter: IndicatorBased...", 'F',
"Evolution Engine").value(); "Evolution Engine").value();
string & indicatorParam = _parser.getORcreateParam(string("Epsilon"), "indicator", std::string & indicatorParam = _parser.getORcreateParam(std::string("Epsilon"), "indicator",
"Binary indicator to use with the IndicatorBased assignment: Epsilon, Hypervolume", 'i', "Binary indicator to use with the IndicatorBased assignment: Epsilon, Hypervolume", 'i',
"Evolution Engine").value(); "Evolution Engine").value();
double rho = _parser.getORcreateParam(1.1, "rho", "reference point for the hypervolume indicator", double rho = _parser.getORcreateParam(1.1, "rho", "reference point for the hypervolume indicator",
@ -67,49 +67,49 @@ moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo (
double kappa = _parser.getORcreateParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased", double kappa = _parser.getORcreateParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased",
'k', "Evolution Engine").value(); 'k', "Evolution Engine").value();
moeoIndicatorBasedFitnessAssignment < MOEOT > * fitnessAssignment; moeoIndicatorBasedFitnessAssignment < MOEOT > * fitnessAssignment;
if (fitnessParam == string("IndicatorBased")) if (fitnessParam == std::string("IndicatorBased"))
{ {
// metric // metric
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric; moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
if (indicatorParam == string("Epsilon")) if (indicatorParam == std::string("Epsilon"))
{ {
metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >; metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
} }
else if (indicatorParam == string("Hypervolume")) else if (indicatorParam == std::string("Hypervolume"))
{ {
metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho); metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
} }
else else
{ {
string stmp = string("Invalid binary quality indicator: ") + indicatorParam; std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT> (*metric, kappa); fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT> (*metric, kappa);
} }
else else
{ {
string stmp = string("Invalid fitness assignment strategy: ") + fitnessParam; std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(fitnessAssignment); _state.storeFunctor(fitnessAssignment);
// number of iterations // number of iterations
unsigned n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization", 'n', "Evolution Engine").value(); unsigned int n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization", 'n', "Evolution Engine").value();
// LS // LS
string & lsParam = _parser.getORcreateParam(string("I-IBMOLS"), "ls", std::string & lsParam = _parser.getORcreateParam(std::string("I-IBMOLS"), "ls",
"Local Search: IBMOLS, I-IBMOLS (Iterated-IBMOLS)...", 'L', "Local Search: IBMOLS, I-IBMOLS (Iterated-IBMOLS)...", 'L',
"Evolution Engine").value(); "Evolution Engine").value();
moeoLS < MOEOT, eoPop<MOEOT> & > * ls; moeoLS < MOEOT, eoPop<MOEOT> & > * ls;
if (lsParam == string("IBMOLS")) if (lsParam == std::string("IBMOLS"))
{ {
ls = new moeoIndicatorBasedLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue);; ls = new moeoIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue);;
} }
else if (lsParam == string("I-IBMOLS")) else if (lsParam == std::string("I-IBMOLS"))
{ {
ls = new moeoIteratedIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue, _op, _opInit, n); ls = new moeoIteratedIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue, _op, _opInit, n);
} }
else else
{ {
string stmp = string("Invalid fitness assignment strategy: ") + fitnessParam; std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
throw std::runtime_error(stmp.c_str()); throw std::runtime_error(stmp.c_str());
} }
_state.storeFunctor(ls); _state.storeFunctor(ls);