diff --git a/eo/src/eo b/eo/src/eo index 57f9e5cc0..c0fe2b8d7 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -92,8 +92,10 @@ #include "eoSteadyFitContinue.h" #include "eoEvalContinue.h" #include "eoFitContinue.h" +#include "eoSIGContinue.h" #include "eoPeriodicContinue.h" #include "eoTimeContinue.h" // added th T.Legrand +#include "eoSecondsElapsedContinue.h" #ifndef _MSC_VER #include "eoCtrlCContinue.h" // CtrlC handling (using 2 global variables!) #endif @@ -145,6 +147,7 @@ #include "eoEasyEA.h" #include "eoSGA.h" // #include "eoEvolutionStrategy.h" removed for a while - until eoGenOp is done +#include "eoAlgoRestart.h" // Utils #include "utils/checkpointing" diff --git a/eo/src/eoAlgoRestart.h b/eo/src/eoAlgoRestart.h new file mode 100644 index 000000000..6e98d774a --- /dev/null +++ b/eo/src/eoAlgoRestart.h @@ -0,0 +1,120 @@ +/* +The Evolving Objects framework is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own evolutionary algorithms. + +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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2010 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _EOALGORESTART_H_ +#define _EOALGORESTART_H_ + +#include "eoPop.h" +#include "eoAlgo.h" + +/** An algo that restart the given algorithm on a freshly init pop. + * + * @note: The fresh population size is set to the size of the last population at previous run. + * + * @ingroup Algorithms + */ +template +class eoAlgoRestart : public eoAlgo +{ +public: + /** Constructor with an eoPopEvalFunc + * + * @param init the initialization operator + * @param popeval an evaluator for populations + * @param algo the algorithm to restart + * @param continuator a stopping criterion to manage the number of restarts + */ + eoAlgoRestart( + eoInit& init, + eoPopEvalFunc& pop_eval, + eoAlgo& algo, + eoContinue& continuator + ) : + eoAlgo(), + _init(init), + _eval(_dummy_eval), + _loop_eval(_dummy_eval), + _pop_eval(pop_eval), + _algo(algo), + _continue(continuator) + {} + + /** Constructor with an eoEvalFunc + * + * @param init the initialization operator + * @param popeval an evaluator for populations + * @param algo the algorithm to restart + * @param continuator a stopping criterion to manage the number of restarts + */ + eoAlgoRestart( + eoInit& init, + eoEvalFunc& eval, + eoAlgo& algo, + eoContinue& continuator + ) : + eoAlgo(), + _init(init), + _eval(eval), + _loop_eval(_eval), + _pop_eval(_loop_eval), + _algo(algo), + _continue(continuator) + {} + + virtual void operator()(eoPop & pop) + { + do { + size_t pop_size = pop.size(); + pop.clear(); + pop.append(pop_size, _init); + _pop_eval(pop,pop); + + _algo(pop); + + } while( _continue(pop) ); + } + +protected: + eoInit& _init; + + eoEvalFunc& _eval; + eoPopLoopEval _loop_eval; + eoPopEvalFunc& _pop_eval; + + eoAlgo& _algo; + eoContinue& _continue; + + class eoDummyEval : public eoEvalFunc + { + public: + void operator()(EOT &) + {} + }; + eoDummyEval _dummy_eval; +}; + + +#endif // _EOALGORESTART_H_ diff --git a/eo/src/utils/eoLogMonitor.h b/eo/src/utils/eoLogMonitor.h index 94884250b..46420ef3f 100644 --- a/eo/src/utils/eoLogMonitor.h +++ b/eo/src/utils/eoLogMonitor.h @@ -32,9 +32,9 @@ Authors: #include "eoLogger.h" /** - Prints statistics to a given ostream. + Prints statistics to the given eoLogger. - You can pass any instance of an ostream to the constructor, like, for example, std::clog. + You can configure the log level. @ingroup Monitors */