diff --git a/trunk/paradiseo-mo/src/continuator/moCombinedContinuator.h b/trunk/paradiseo-mo/src/continuator/moCombinedContinuator.h new file mode 100644 index 000000000..a12d4caa6 --- /dev/null +++ b/trunk/paradiseo-mo/src/continuator/moCombinedContinuator.h @@ -0,0 +1,87 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moCombinedContinuator_h +#define _moCombinedContinuator_h + +#include +#include +/** + * Combined several continuators + * Continue until one of the continuators is false + */ +template< class Neighbor > +class moCombinedContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * @param _maxFit maximum fitness to reach + */ + moCombinedContinuator(Fitness _maxFit): maxFit(_maxFit){} + + /** + * Default constructor (moCheckpoint must have at least one continuator) + * @param _cont a continuator + */ + moCombinedContinuator(moContinuator& _cont) : { + continuators.push_back(&_cont); + } + + /** + * add a continuator to the combined continuator + * @param _cont a continuator + */ + void add(moContinuator& _cont) { + continuators.push_back(&_cont); + } + + /** + *@param _solution a solution + *@return true all the continuators are true + */ + virtual bool operator()(EOT & _solution) { + bool bContinue = true; + + // some data may be update in each continuator. + // So, all continuators are tested + for(unsigned int i = 0; i < continuators.size(); ++i) + if ( !(*continuators[i])(_sol) ) + bContinue = false; + + return bContinue; + } + +private: + /** continuators vector */ + std::vector*> continuators; + +}; +#endif diff --git a/trunk/paradiseo-mo/src/continuator/moFitContinuator.h b/trunk/paradiseo-mo/src/continuator/moFitContinuator.h new file mode 100644 index 000000000..eca43f8f9 --- /dev/null +++ b/trunk/paradiseo-mo/src/continuator/moFitContinuator.h @@ -0,0 +1,62 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moFitContinuator_h +#define _moFitContinuator_h + +#include +#include +/** + * Continue until a maximum fitness is reached + */ +template< class Neighbor > +class moFitContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + /** + * @param _maxFit maximum fitness to reach + */ + moFitContinuator(Fitness _maxFit): maxFit(_maxFit){} + + /** + *@param _solution a solution + *@return true if counter < maxFit + */ + virtual bool operator()(EOT & _solution) { + return (_solution.fitness() < maxFit); + } + +private: + Fitness maxFit; + +}; +#endif diff --git a/trunk/paradiseo-mo/src/continuator/moFullEvalContinuator.h b/trunk/paradiseo-mo/src/continuator/moFullEvalContinuator.h new file mode 100644 index 000000000..9ddfa32bf --- /dev/null +++ b/trunk/paradiseo-mo/src/continuator/moFullEvalContinuator.h @@ -0,0 +1,75 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moFullEvalContinuator_h +#define _moFullEvalContinuator_h + +#include +#include +#include + +/** + * Continue until a maximum fixed number of full evaluation is reached + */ +template< class Neighbor > +class moFullEvalContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Default constructor + * @param _eval evaluation function to count + * @param _maxFullEval number maximum of iterations + */ + moFullEvalContinuator(eoEvalFuncCounter & _eval, unsigned int _maxFullEval): maxFullEval(_maxFullEval){} + + /** + * Test if continue + *@param _solution a solution + *@return true if number of evaluations < maxFullEval + */ + virtual bool operator()(EOT & _solution) { + return (eval.value() < maxFullEval); + } + + /** + * Reset the number of evaluations + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + eval.value() = 0; + } + +private: + eoEvalFuncCounter & eval; + unsigned int maxFullEval; + +}; +#endif diff --git a/trunk/paradiseo-mo/src/continuator/moNeighborEvalContinuator.h b/trunk/paradiseo-mo/src/continuator/moNeighborEvalContinuator.h new file mode 100644 index 000000000..d09338664 --- /dev/null +++ b/trunk/paradiseo-mo/src/continuator/moNeighborEvalContinuator.h @@ -0,0 +1,75 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moNeighborEvalContinuator_h +#define _moNeighborEvalContinuator_h + +#include +#include +#include + +/** + * Continue until a maximum fixed number of neighbor evaluation is reached + */ +template< class Neighbor > +class moNeighborEvalContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Default constructor + * @param _eval neighbor evaluation function to count + * @param _maxNeighborEval number maximum of iterations + */ + moNeighborEvalContinuator(moEvalCounter & _eval, unsigned int _maxNeighborEval): maxNeighborEval(_maxNeighborEval){} + + /** + * Test if continue + *@param _solution a solution + *@return true if number of evaluations < maxNeighborEval + */ + virtual bool operator()(EOT & _solution) { + return (eval.value() < maxNeighborEval); + } + + /** + * Reset the number of evaluations + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + eval.value() = 0; + } + +private: + moEvalCounter & eval; + unsigned int maxNeighborEval; + +}; +#endif diff --git a/trunk/paradiseo-mo/src/eval/moEvalCounter.h b/trunk/paradiseo-mo/src/eval/moEvalCounter.h new file mode 100644 index 000000000..2a9d49184 --- /dev/null +++ b/trunk/paradiseo-mo/src/eval/moEvalCounter.h @@ -0,0 +1,66 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _moEvalCounter_h +#define _moEvalCounter_h + +#include +#include + +/** + Counts the number of neighbor evaluations actually performed, thus checks first + if it has to evaluate.. etc. +*/ +template +class moEvalCounter : public moEval, public eoValueParam +{ +public: + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness; + + moEvalCounter(moEval& _eval, std::string _name = "Neighbor Eval. ") + : eoValueParam(0, _name), eval(_eval) {} + + /** + * Increase the number of neighbor evaluations and perform the evaluation + * + * @param _solution a solution + * @param _neighbor a neighbor + */ + void operator()(EOT& _solution, Neighbor& _neigbor) { + value()++; + eval(_solution, _neighbor); + } + +private: + moEval & eval; + +}; + +#endif diff --git a/trunk/paradiseo-mo/src/mo.h b/trunk/paradiseo-mo/src/mo.h index d9bfe23da..d92975df8 100755 --- a/trunk/paradiseo-mo/src/mo.h +++ b/trunk/paradiseo-mo/src/mo.h @@ -65,11 +65,16 @@ #include #include #include +#include +#include +#include +#include #include #include #include #include +#include #include #include diff --git a/trunk/paradiseo-mo/src/problems/eval/moOneMaxIncrEval.h b/trunk/paradiseo-mo/src/problems/eval/moOneMaxIncrEval.h index 3e11cce87..501b3fba9 100644 --- a/trunk/paradiseo-mo/src/problems/eval/moOneMaxIncrEval.h +++ b/trunk/paradiseo-mo/src/problems/eval/moOneMaxIncrEval.h @@ -42,7 +42,7 @@ public: typedef typename Neighbor::EOT EOT; /* - * incremental evaluation of the solution for the oneMax problem + * incremental evaluation of the neighbor for the oneMax problem * @param _solution the solution to move (bit string) * @param _neighbor the neighbor to consider (of type moBitNeigbor) */ @@ -51,7 +51,7 @@ public: _neighbor.fitness(_solution.fitness() + 1); else _neighbor.fitness(_solution.fitness() - 1); - }; + }g }; #endif diff --git a/trunk/paradiseo-mo/src/problems/eval/oneMaxFullEval.h b/trunk/paradiseo-mo/src/problems/eval/oneMaxFullEval.h new file mode 100644 index 000000000..f778c3414 --- /dev/null +++ b/trunk/paradiseo-mo/src/problems/eval/oneMaxFullEval.h @@ -0,0 +1,55 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#ifndef _oneMaxFullEval_h +#define _oneMaxFullEval_h + +#include + +/** + * Fitness function (full evaluation) for the OneMax problem + */ +template< class EOT > +class oneMaxFullEval : public eoEvalFunc +{ +public: + + /** + * Count the number of 1 in a bitString + * @param _sol the solution to evaluate + */ + void operator() (EOT& _sol) { + unsigned int sum = 0; + for (unsigned int i = 0; i < _sol.size(); i++) + sum += _sol[i]; + _sol.fitness(sum); + } +}; + +#endif