update doc and sort files
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@211 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
528a149107
commit
db21384417
17 changed files with 620 additions and 546 deletions
|
|
@ -1,249 +1,178 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_checkpoint_pareto.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2000
|
||||
// make_checkpoint_moeo.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
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...
|
||||
|
||||
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: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@inria.fr
|
||||
mkeijzer@dhi.dk
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_checkpoint_pareto_h
|
||||
#define _make_checkpoint_pareto_h
|
||||
#ifndef MAKE_CHECKPOINT_MOEO_H_
|
||||
#define MAKE_CHECKPOINT_MOEO_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <eoContinue.h>
|
||||
#include <eoEvalFuncCounter.h>
|
||||
#include <utils/checkpointing>
|
||||
#include <utils/selectors.h>
|
||||
#include <utils/eoParser.h>
|
||||
#include <utils/eoState.h>
|
||||
#include <moeoArchiveUpdater.h>
|
||||
#include <moeoArchiveObjectiveVectorSavingUpdater.h>
|
||||
#include <metric/moeoBinaryMetricSavingUpdater.h>
|
||||
#include <metric/moeoContributionMetric.h>
|
||||
#include <metric/moeoEntropyMetric.h>
|
||||
|
||||
#include "MOEO.h"
|
||||
//#include "eoParetoFitness.h"
|
||||
#include "eoEvalFuncCounter.h"
|
||||
#include "utils/checkpointing"
|
||||
#include "utils/selectors.h"
|
||||
|
||||
// at the moment, in utils/make_help.cpp
|
||||
// this should become some eoUtils.cpp with corresponding eoUtils.h
|
||||
bool testDirRes(std::string _dirName, bool _erase);
|
||||
/////////////////// The checkpoint and other I/O //////////////
|
||||
|
||||
/**
|
||||
/**
|
||||
* This functions allows to build an eoCheckPoint for multi-objective optimization from the parser (partly taken from make_checkpoint_pareto.h)
|
||||
* @param _parser the parser
|
||||
* @param _state to store allocated objects
|
||||
* @param _eval the funtions evaluator
|
||||
* @param _continue the stopping crietria
|
||||
* @param _pop the population
|
||||
* @param _archive the archive of non-dominated solutions
|
||||
*/
|
||||
template <class EOT>
|
||||
eoCheckPoint<EOT>& do_make_checkpoint_moeo(eoParser& _parser, eoState& _state,
|
||||
eoEvalFuncCounter<EOT>& _eval, eoContinue<EOT>& _continue)
|
||||
template < class MOEOT >
|
||||
eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive)
|
||||
{
|
||||
// first, create a checkpoint from the eoContinue - and store in _state
|
||||
eoCheckPoint<EOT> & checkpoint = _state.storeFunctor(new eoCheckPoint<EOT>(_continue));
|
||||
|
||||
/////// get number of obectives
|
||||
unsigned nObj = EOT::ObjectiveVector::nObjectives();
|
||||
eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue));
|
||||
/* the objective vector type */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
// get number of obectives
|
||||
unsigned nObj = ObjectiveVector::nObjectives();
|
||||
|
||||
///////////////////
|
||||
// Counters
|
||||
//////////////////
|
||||
// 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();
|
||||
|
||||
// Create anyway a generation-counter parameter WARNING: not stored anywhere!!!
|
||||
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
|
||||
eoValueParam<unsigned> *generationCounter = new eoValueParam<unsigned>(0, "Gen.");
|
||||
// Create an incrementor (sub-class of eoUpdater).
|
||||
eoIncrementor<unsigned> & increment =
|
||||
_state.storeFunctor(new eoIncrementor<unsigned>(generationCounter->value()) );
|
||||
// Add it to the checkpoint,
|
||||
eoIncrementor<unsigned> & increment = _state.storeFunctor( new eoIncrementor<unsigned>(generationCounter->value()) );
|
||||
// Add it to the checkpoint
|
||||
checkpoint.add(increment);
|
||||
|
||||
// dir for DISK output
|
||||
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir",
|
||||
"Directory to store DISK outputs",
|
||||
'\0', "Output - Disk").value();
|
||||
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output").value();
|
||||
// shoudl we empty it if exists
|
||||
eoValueParam<bool>& eraseParam = _parser.getORcreateParam(true, "eraseDir",
|
||||
"erase files in dirName if any",
|
||||
'\0', "Output - Disk");
|
||||
eoValueParam<bool>& eraseParam = _parser.getORcreateParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output");
|
||||
bool dirOK = false; // not tested yet
|
||||
|
||||
/////////////////////////////////////////
|
||||
// now some statistics on the population:
|
||||
/////////////////////////////////////////
|
||||
/**
|
||||
* existing stats for Pareto as of today, Jan. 31. 2002
|
||||
*
|
||||
* eoSortedPopStat : whole population - type std::string (!!)
|
||||
*/
|
||||
/*
|
||||
eoValueParam<eoParamParamType>& fPlotParam
|
||||
= _parser.getORcreateParam(eoParamParamType("1(0,1)"), "frontFileFrequency",
|
||||
"File save frequency in objective spaces (std::pairs of comma-separated objectives " \
|
||||
"in 1 single parentheses std::pair)",
|
||||
'\0', "Output - Disk");
|
||||
|
||||
bool boolGnuplot = _parser.getORcreateParam(false, "plotFront",
|
||||
"Objective plots (requires corresponding files " \
|
||||
"- see frontFileFrequency",
|
||||
'\0', "Output - Graphical").value();
|
||||
|
||||
eoParamParamType & fPlot = fPlotParam.value(); // std::pair<std::string,std::vector<std::string> >
|
||||
unsigned frequency = atoi(fPlot.first.c_str());
|
||||
if (frequency) // something to plot
|
||||
{
|
||||
unsigned nbPlot = fPlot.second.size();
|
||||
if ( nbPlot % 2 ) // odd!
|
||||
throw std::runtime_error("Odd number of front description in make_checkpoint_pareto");
|
||||
|
||||
// only create the necessary stats
|
||||
std::vector<bool> bStat(nObj, false); // track of who's already there
|
||||
std::vector<eoMOFitnessStat<EOT>* > theStats(nObj);
|
||||
|
||||
// first create the stats
|
||||
for (unsigned i=0; i<nbPlot; i+=2)
|
||||
{
|
||||
unsigned obj1 = atoi(fPlot.second[i].c_str());
|
||||
unsigned obj2 = atoi(fPlot.second[i+1].c_str());
|
||||
eoMOFitnessStat<EOT>* fStat;
|
||||
if (!bStat[obj1]) { // not already there: create it
|
||||
std::ostringstream os;
|
||||
os << "Obj. " << obj1 << std::ends;
|
||||
fStat = new eoMOFitnessStat<EOT>(obj1, os.str().c_str());
|
||||
_state.storeFunctor(fStat);
|
||||
bStat[obj1]=true;
|
||||
theStats[obj1]=fStat;
|
||||
checkpoint.add(*fStat);
|
||||
}
|
||||
if (!bStat[obj2]) { // not already there: create it
|
||||
std::ostringstream os;
|
||||
os << "Obj. " << obj2 << std::ends;
|
||||
fStat = new eoMOFitnessStat<EOT>(obj2, os.str().c_str());
|
||||
_state.storeFunctor(fStat);
|
||||
bStat[obj2]=true;
|
||||
theStats[obj2]=fStat;
|
||||
checkpoint.add(*fStat);
|
||||
}
|
||||
|
||||
// then the fileSnapshots
|
||||
std::ostringstream os;
|
||||
os << "Front." << obj1 << "." << obj2 << "." << std::ends;
|
||||
eoFileSnapshot& snapshot = _state.storeFunctor(
|
||||
new eoFileSnapshot(dirName, frequency, os.str().c_str()));
|
||||
checkpoint.add(snapshot);
|
||||
|
||||
snapshot.add(*theStats[obj1]);
|
||||
snapshot.add(*theStats[obj2]);
|
||||
|
||||
// and create the gnuplotter from the fileSnapshot
|
||||
if(boolGnuplot)
|
||||
{
|
||||
eoGnuplot1DSnapshot & plotSnapshot = _state.storeFunctor(new
|
||||
eoGnuplot1DSnapshot(snapshot));
|
||||
plotSnapshot.setPointSize(3);
|
||||
checkpoint.add(plotSnapshot);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Dump of the whole population
|
||||
//-----------------------------
|
||||
/*
|
||||
bool printPop = _parser.getORcreateParam(false, "printPop",
|
||||
"Print sorted pop. every gen.",
|
||||
'\0', "Output").value();
|
||||
eoSortedPopStat<EOT> * popStat;
|
||||
bool printPop = _parser.getORcreateParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output").value();
|
||||
eoSortedPopStat<MOEOT> * popStat;
|
||||
if ( printPop ) // we do want pop dump
|
||||
{
|
||||
std::cout << "On cree printpop\n";
|
||||
popStat = & _state.storeFunctor(new eoSortedPopStat<EOT>);
|
||||
// add it to the checkpoint
|
||||
checkpoint.add(*popStat);
|
||||
}
|
||||
*/
|
||||
///////////////
|
||||
// The monitors
|
||||
///////////////
|
||||
/*
|
||||
// do we want an eoStdoutMonitor?
|
||||
bool needStdoutMonitor = printPop ; // only this one at the moment
|
||||
|
||||
// The Stdout monitor will print parameters to the screen ...
|
||||
if ( needStdoutMonitor )
|
||||
{
|
||||
eoStdoutMonitor & monitor = _state.storeFunctor(new eoStdoutMonitor(false));
|
||||
|
||||
// when called by the checkpoint (i.e. at every generation)
|
||||
checkpoint.add(monitor);
|
||||
|
||||
// the monitor will output a series of parameters: add them
|
||||
monitor.add(*generationCounter);
|
||||
if (useEval) // we want nb of evaluations
|
||||
monitor.add(_eval);
|
||||
if ( printPop)
|
||||
monitor.add(*popStat);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
popStat = & _state.storeFunctor(new eoSortedPopStat<MOEOT>);
|
||||
checkpoint.add(*popStat);
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// State savers
|
||||
//////////////////////////////
|
||||
|
||||
// feed the state to state savers
|
||||
// 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" );
|
||||
|
||||
if (_parser.isItThere(saveFrequencyParam))
|
||||
{
|
||||
// first make sure dirName is OK
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
|
||||
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
|
||||
// first make sure dirName is OK
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
|
||||
#ifdef _MSVC
|
||||
std::string stmp = dirName + "\generations";
|
||||
std::string stmp = dirName + "\generations";
|
||||
#else
|
||||
std::string stmp = dirName + "/generations";
|
||||
std::string stmp = dirName + "/generations";
|
||||
#endif
|
||||
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
|
||||
_state.storeFunctor(stateSaver1);
|
||||
checkpoint.add(*stateSaver1);
|
||||
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
|
||||
_state.storeFunctor(stateSaver1);
|
||||
checkpoint.add(*stateSaver1);
|
||||
}
|
||||
|
||||
// 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>& saveTimeIntervalParam = _parser.getORcreateParam(unsigned(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" );
|
||||
if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
|
||||
{
|
||||
// first make sure dirName is OK
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
|
||||
// first make sure dirName is OK
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
#ifdef _MSVC
|
||||
std::string stmp = dirName + "\time";
|
||||
std::string stmp = dirName + "\time";
|
||||
#else
|
||||
std::string stmp = dirName + "/time";
|
||||
std::string stmp = dirName + "/time";
|
||||
#endif
|
||||
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
|
||||
_state.storeFunctor(stateSaver2);
|
||||
checkpoint.add(*stateSaver2);
|
||||
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
|
||||
_state.storeFunctor(stateSaver2);
|
||||
checkpoint.add(*stateSaver2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////
|
||||
// Archive
|
||||
//////////////////
|
||||
// update the archive every generation
|
||||
bool updateArch = _parser.getORcreateParam(true, "updateArch", "Update the archive at each gen.", '\0', "Evolution Engine").value();
|
||||
if (updateArch)
|
||||
{
|
||||
moeoArchiveUpdater < MOEOT > * updater = new moeoArchiveUpdater < MOEOT > (_archive, _pop);
|
||||
_state.storeFunctor(updater);
|
||||
checkpoint.add(*updater);
|
||||
}
|
||||
// store the objective vectors contained in the archive every generation
|
||||
bool storeArch = _parser.getORcreateParam(false, "storeArch", "Store the archive's objective vectors at each gen.", '\0', "Output").value();
|
||||
if (storeArch)
|
||||
{
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
#ifdef _MSVC
|
||||
std::string stmp = dirName + "\arch";
|
||||
#else
|
||||
std::string stmp = dirName + "/arch";
|
||||
#endif
|
||||
moeoArchiveObjectiveVectorSavingUpdater < MOEOT > * save_updater = new moeoArchiveObjectiveVectorSavingUpdater < MOEOT > (_archive, stmp);
|
||||
_state.storeFunctor(save_updater);
|
||||
checkpoint.add(*save_updater);
|
||||
}
|
||||
// store the contribution of the non-dominated solutions
|
||||
bool cont = _parser.getORcreateParam(false, "contribution", "Store the contribution of the archive at each gen.", '\0', "Output").value();
|
||||
if (cont)
|
||||
{
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
#ifdef _MSVC
|
||||
std::string stmp = dirName + "\contribution";
|
||||
#else
|
||||
std::string stmp = dirName + "/contribution";
|
||||
#endif
|
||||
moeoContributionMetric < ObjectiveVector > * contribution = new moeoContributionMetric < ObjectiveVector >;
|
||||
moeoBinaryMetricSavingUpdater < MOEOT > * contribution_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*contribution, _archive, stmp);
|
||||
_state.storeFunctor(contribution_updater);
|
||||
checkpoint.add(*contribution_updater);
|
||||
}
|
||||
// store the entropy of the non-dominated solutions
|
||||
bool ent = _parser.getORcreateParam(false, "entropy", "Store the entropy of the archive at each gen.", '\0', "Output").value();
|
||||
if (ent)
|
||||
{
|
||||
if (! dirOK )
|
||||
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
|
||||
#ifdef _MSVC
|
||||
std::string stmp = dirName + "\entropy";
|
||||
#else
|
||||
std::string stmp = dirName + "/entropy";
|
||||
#endif
|
||||
moeoEntropyMetric < ObjectiveVector > * entropy = new moeoEntropyMetric < ObjectiveVector >;
|
||||
moeoBinaryMetricSavingUpdater < MOEOT > * entropy_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*entropy, _archive, stmp);
|
||||
_state.storeFunctor(entropy_updater);
|
||||
checkpoint.add(*entropy_updater);
|
||||
}
|
||||
|
||||
// and that's it for the (control and) output
|
||||
return checkpoint;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /*MAKE_CHECKPOINT_MOEO_H_*/
|
||||
|
|
|
|||
|
|
@ -1,142 +1,106 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_continue_pareto.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2000
|
||||
/*
|
||||
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.
|
||||
// make_continue_moeo.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
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: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@inria.fr
|
||||
mkeijzer@dhi.dk
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_continue_pareto_h
|
||||
#define _make_continue_pareto_h
|
||||
#ifndef MAKE_CONTINUE_MOEO_H_
|
||||
#define MAKE_CONTINUE_MOEO_H_
|
||||
|
||||
/*
|
||||
Contains the templatized version of parser-based choice of stopping criterion
|
||||
for Pareto optimization (e.g. no "... without improvement" criterion
|
||||
It can then be instantiated, and compiled on its own for a given EOType
|
||||
(see e.g. in dir ga, ga.cpp)
|
||||
*/
|
||||
|
||||
// Continuators - all include eoContinue.h
|
||||
#include <eoCombinedContinue.h>
|
||||
#include <eoGenContinue.h>
|
||||
#include <eoEvalContinue.h>
|
||||
#include <eoFitContinue.h>
|
||||
#include <eoTimeContinue.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <eoCtrlCContinue.h> // CtrlC handling (using 2 global variables!)
|
||||
#include <eoCtrlCContinue.h>
|
||||
#endif
|
||||
|
||||
// also need the parser and param includes
|
||||
#include <utils/eoParser.h>
|
||||
#include <utils/eoState.h>
|
||||
|
||||
|
||||
/////////////////// helper function ////////////////
|
||||
template <class Indi>
|
||||
eoCombinedContinue<Indi> * make_combinedContinue(eoCombinedContinue<Indi> *_combined, eoContinue<Indi> *_cont)
|
||||
/**
|
||||
* Helper function
|
||||
* @param _combined the eoCombinedContinue object
|
||||
* @param _cont the eoContinue to add
|
||||
*/
|
||||
template <class MOEOT>
|
||||
eoCombinedContinue<MOEOT> * make_combinedContinue(eoCombinedContinue<MOEOT> *_combined, eoContinue<MOEOT> *_cont)
|
||||
{
|
||||
if (_combined) // already exists
|
||||
_combined->add(*_cont);
|
||||
else
|
||||
_combined = new eoCombinedContinue<Indi>(*_cont);
|
||||
_combined = new eoCombinedContinue<MOEOT>(*_cont);
|
||||
return _combined;
|
||||
}
|
||||
|
||||
///////////// The make_continue function
|
||||
template <class Indi>
|
||||
eoContinue<Indi> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
||||
|
||||
/**
|
||||
* This functions allows to build a eoContinue for multi-objective optimization from the parser (partly taken from make_continue_pareto.h)
|
||||
* @param _parser the parser
|
||||
* @param _state to store allocated objects
|
||||
* @param _eval the funtions evaluator
|
||||
*/
|
||||
template <class MOEOT>
|
||||
eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoEvalFuncCounter<MOEOT> & _eval)
|
||||
{
|
||||
//////////// Stopping criterion ///////////////////
|
||||
// the combined continue - to be filled
|
||||
eoCombinedContinue<Indi> *continuator = NULL;
|
||||
|
||||
// for each possible criterion, check if wanted, otherwise do nothing
|
||||
|
||||
eoCombinedContinue<MOEOT> *continuator = NULL;
|
||||
// First the eoGenContinue - need a default value so you can run blind
|
||||
// but we also need to be able to avoid it <--> 0
|
||||
eoValueParam<unsigned>& maxGenParam = _parser.createParam(unsigned(100), "maxGen", "Maximum number of generations () = none)",'G',"Stopping criterion");
|
||||
|
||||
if (maxGenParam.value()) // positive: -> define and store
|
||||
{
|
||||
eoGenContinue<Indi> *genCont = new eoGenContinue<Indi>(maxGenParam.value());
|
||||
_state.storeFunctor(genCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, genCont);
|
||||
}
|
||||
|
||||
|
||||
/**************************/
|
||||
eoValueParam<unsigned long>& maxEvalParam
|
||||
= _parser.getORcreateParam((unsigned long)0, "maxEval",
|
||||
"Maximum number of evaluations (0 = none)",
|
||||
'E', "Stopping criterion");
|
||||
if (maxEvalParam.value()) // positive: -> define and store
|
||||
{
|
||||
eoEvalContinue<Indi> *evalCont = new eoEvalContinue<Indi>(_eval, maxEvalParam.value());
|
||||
_state.storeFunctor(evalCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, evalCont);
|
||||
}
|
||||
/**************************/
|
||||
|
||||
|
||||
|
||||
/**************************/
|
||||
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
|
||||
{
|
||||
eoTimeContinue<Indi> *timeCont = new eoTimeContinue<Indi>(maxTimeParam.value());
|
||||
_state.storeFunctor(timeCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<Indi>(continuator, timeCont);
|
||||
}
|
||||
/**************************/
|
||||
|
||||
|
||||
|
||||
eoValueParam<unsigned>& maxGenParam = _parser.createParam(unsigned(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
|
||||
if (maxGenParam.value()) // positive: -> define and store
|
||||
{
|
||||
eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
|
||||
_state.storeFunctor(genCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<MOEOT>(continuator, genCont);
|
||||
}
|
||||
// maxEval
|
||||
eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
|
||||
if (maxEvalParam.value())
|
||||
{
|
||||
eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value());
|
||||
_state.storeFunctor(evalCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
|
||||
}
|
||||
// maxTime
|
||||
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
|
||||
{
|
||||
eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());
|
||||
_state.storeFunctor(timeCont);
|
||||
// and "add" to combined
|
||||
continuator = make_combinedContinue<MOEOT>(continuator, timeCont);
|
||||
}
|
||||
// CtrlC
|
||||
#ifndef _MSC_VER
|
||||
// the CtrlC interception (Linux only I'm afraid)
|
||||
eoCtrlCContinue<Indi> *ctrlCCont;
|
||||
eoCtrlCContinue<MOEOT> *ctrlCCont;
|
||||
eoValueParam<bool>& ctrlCParam = _parser.createParam(true, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
|
||||
if (_parser.isItThere(ctrlCParam))
|
||||
{
|
||||
ctrlCCont = new eoCtrlCContinue<Indi>;
|
||||
ctrlCCont = new eoCtrlCContinue<MOEOT>;
|
||||
// store
|
||||
_state.storeFunctor(ctrlCCont);
|
||||
// add to combinedContinue
|
||||
continuator = make_combinedContinue<Indi>(continuator, ctrlCCont);
|
||||
continuator = make_combinedContinue<MOEOT>(continuator, ctrlCCont);
|
||||
}
|
||||
#endif
|
||||
|
||||
// now check that there is at least one!
|
||||
if (!continuator)
|
||||
throw std::runtime_error("You MUST provide a stopping criterion");
|
||||
// OK, it's there: store in the eoState
|
||||
_state.storeFunctor(continuator);
|
||||
|
||||
// and return
|
||||
return *continuator;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /*MAKE_CONTINUE_MOEO_H_*/
|
||||
|
|
|
|||
|
|
@ -27,13 +27,23 @@
|
|||
#include <moeoMoveIncrEval.h>
|
||||
|
||||
/**
|
||||
* ...
|
||||
* This functions allows to build a moeoLS from the parser
|
||||
* @param _parser the parser
|
||||
* @param _state to store allocated objects
|
||||
* @param _eval the funtions evaluator
|
||||
* @param _moveIncrEval the incremental evaluation
|
||||
* @param _continue the stopping crietria
|
||||
* @param _op the variation operators
|
||||
* @param _opInit the initilization operator
|
||||
* @param _moveInit the move initializer
|
||||
* @param _nextMove the move incrementor
|
||||
* @param _archive the archive of non-dominated solutions
|
||||
*/
|
||||
template < class MOEOT, class Move >
|
||||
moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo (
|
||||
eoParser & _parser,
|
||||
eoState & _state,
|
||||
moeoEvalFunc < MOEOT > & _eval,
|
||||
eoEvalFunc < MOEOT > & _eval,
|
||||
moeoMoveIncrEval < Move > & _moveIncrEval,
|
||||
eoContinue < MOEOT > & _continue,
|
||||
eoMonOp < MOEOT > & _op,
|
||||
|
|
@ -43,11 +53,8 @@ moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo (
|
|||
moeoArchive < MOEOT > & _archive
|
||||
)
|
||||
{
|
||||
|
||||
/* the objective vector type */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
|
||||
/* the fitness assignment strategy */
|
||||
string & fitnessParam = _parser.getORcreateParam(string("IndicatorBased"), "fitness",
|
||||
"Fitness assignment strategy parameter: IndicatorBased...", 'F',
|
||||
|
|
@ -85,15 +92,8 @@ moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo (
|
|||
throw std::runtime_error(stmp.c_str());
|
||||
}
|
||||
_state.storeFunctor(fitnessAssignment);
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization",
|
||||
'n', "Evolution Engine").value();
|
||||
|
||||
|
||||
|
||||
// number of iterations
|
||||
unsigned n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization", 'n', "Evolution Engine").value();
|
||||
// LS
|
||||
string & lsParam = _parser.getORcreateParam(string("I-IBMOLS"), "ls",
|
||||
"Local Search: IBMOLS, I-IBMOLS (Iterated-IBMOLS)...", 'L',
|
||||
|
|
@ -113,10 +113,8 @@ moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo (
|
|||
throw std::runtime_error(stmp.c_str());
|
||||
}
|
||||
_state.storeFunctor(ls);
|
||||
|
||||
|
||||
// that's it !
|
||||
return *ls;
|
||||
|
||||
}
|
||||
|
||||
#endif /*MAKE_LS_MOEO_H_*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue