From 6bb2a4a822b0f71f72fe97c76463148ac652630c Mon Sep 17 00:00:00 2001 From: jhumeau Date: Mon, 29 Mar 2010 15:58:25 +0000 Subject: [PATCH] ILS v1 :) git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1727 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/acceptCrit/moAlwaysAcceptCrit.h | 2 +- .../src/continuator/moIterContinuator.h | 70 +++++++++++++++++ .../src/coolingSchedule/moCoolingSchedule.h | 12 +-- .../coolingSchedule/moSimpleCoolingSchedule.h | 14 ++-- trunk/paradiseo-mo/src/eval/moDummyEval.h | 52 +++++++++++++ .../paradiseo-mo/src/explorer/moILSexplorer.h | 17 ++-- .../src/explorer/moNeighborhoodExplorer.h | 8 ++ .../paradiseo-mo/src/explorer/moSAexplorer.h | 8 +- trunk/paradiseo-mo/src/mo.h | 5 +- .../src/neighborhood/moDummyNeighbor.h | 48 ++++++++++++ .../src/neighborhood/moDummyNeighborhood.h | 78 +++++++++++++++++++ .../paradiseo-mo/src/perturb/moMonOpPerturb.h | 9 ++- .../{moPertubation.h => moPerturbation.h} | 0 trunk/paradiseo-mo/test/moTestClass.h | 10 +-- .../paradiseo-mo/test/t-moFullEvalByCopy.cpp | 6 +- .../paradiseo-mo/test/t-moFullEvalByModif.cpp | 2 +- trunk/paradiseo-mo/test/t-moNeighbor.cpp | 4 +- .../test/t-moSimpleHCexplorer.cpp | 14 ++-- .../paradiseo-mo/test/t-moTrueContinuator.cpp | 2 +- .../tutorial/oneMax/application/testILS.cpp | 21 ++++- .../application/testSimulatedAnnealing.cpp | 8 +- 21 files changed, 330 insertions(+), 60 deletions(-) create mode 100644 trunk/paradiseo-mo/src/continuator/moIterContinuator.h create mode 100644 trunk/paradiseo-mo/src/eval/moDummyEval.h create mode 100644 trunk/paradiseo-mo/src/neighborhood/moDummyNeighbor.h create mode 100644 trunk/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h rename trunk/paradiseo-mo/src/perturb/{moPertubation.h => moPerturbation.h} (100%) diff --git a/trunk/paradiseo-mo/src/acceptCrit/moAlwaysAcceptCrit.h b/trunk/paradiseo-mo/src/acceptCrit/moAlwaysAcceptCrit.h index c4dc385cb..ce22dd186 100644 --- a/trunk/paradiseo-mo/src/acceptCrit/moAlwaysAcceptCrit.h +++ b/trunk/paradiseo-mo/src/acceptCrit/moAlwaysAcceptCrit.h @@ -40,7 +40,7 @@ template< class Neighbor > class moAlwaysAcceptCrit : public moAcceptanceCriterion, public moDummyMemory{ public: - typedef typename Neighor::EOT EOT; + typedef typename Neighbor::EOT EOT; /** * Always accept the new solution diff --git a/trunk/paradiseo-mo/src/continuator/moIterContinuator.h b/trunk/paradiseo-mo/src/continuator/moIterContinuator.h new file mode 100644 index 000000000..20de09211 --- /dev/null +++ b/trunk/paradiseo-mo/src/continuator/moIterContinuator.h @@ -0,0 +1,70 @@ +/* + +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 _moIterContinuator_h +#define _moIterContinuator_h + +#include + +/** + * Continue until a maximum fixed number of iterations is reached + */ +template< class NH > +class moIterContinuator : public moContinuator +{ +public: + typedef typename NH::EOT EOT ; + + /** + * @param _maxIter number maximum of iterations + */ + moIterContinuator(unsigned int _maxIter): maxIter(_maxIter){} + + /** + *@param _solution a solution + *@return true if counter < maxIter + */ + virtual bool operator()(EOT & _solution) { + return (cpt++ < maxIter); + } + + /** + * reset the counter of iteration + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + cpt=0; + } + +private: + unsigned int maxIter; + unsigned int cpt; + +}; +#endif diff --git a/trunk/paradiseo-mo/src/coolingSchedule/moCoolingSchedule.h b/trunk/paradiseo-mo/src/coolingSchedule/moCoolingSchedule.h index e72b236d6..b75e68a6e 100644 --- a/trunk/paradiseo-mo/src/coolingSchedule/moCoolingSchedule.h +++ b/trunk/paradiseo-mo/src/coolingSchedule/moCoolingSchedule.h @@ -35,6 +35,8 @@ #ifndef _moCoolingSchedule_h #define _moCoolingSchedule_h +#include + /** * Cooling Schedule of the temperature in the simulated algorithm * @@ -47,20 +49,14 @@ public: * Initial temperature * @param _solution initial solution */ - double init(EOT & _solution) = 0; + virtual double init(EOT & _solution) = 0; /** * update the temperature * @param _temp current temperature to update */ - void update(double& _temp) = 0; + virtual void update(double& _temp) = 0; - /** - * test the ending of the process - * @param _temp current temperature - * @return true if the process could be continue - */ - // bool operator()(double _temp) = 0; }; diff --git a/trunk/paradiseo-mo/src/coolingSchedule/moSimpleCoolingSchedule.h b/trunk/paradiseo-mo/src/coolingSchedule/moSimpleCoolingSchedule.h index 5cf462e08..90e17b3b7 100644 --- a/trunk/paradiseo-mo/src/coolingSchedule/moSimpleCoolingSchedule.h +++ b/trunk/paradiseo-mo/src/coolingSchedule/moSimpleCoolingSchedule.h @@ -43,7 +43,7 @@ * */ template< class EOT > -class moSimpleCoolingSchedule : public eoUF +class moSimpleCoolingSchedule : public moCoolingSchedule { public: /** @@ -91,18 +91,14 @@ public: private: // initial temperature double initT; - - // threshold temperature - double finalT; - // coefficient of decrease double alpha; - // maximum number of iterations at the same temperature - unisgned span; - + unsigned int span; + // threshold temperature + double finalT; // number of steps with the same temperature - unsigned step; + unsigned int step; }; diff --git a/trunk/paradiseo-mo/src/eval/moDummyEval.h b/trunk/paradiseo-mo/src/eval/moDummyEval.h new file mode 100644 index 000000000..60f487d54 --- /dev/null +++ b/trunk/paradiseo-mo/src/eval/moDummyEval.h @@ -0,0 +1,52 @@ +/* + +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 _moDummyEval_h +#define _moDummyEval_h + +#include + +/** + * Dummy Evaluation function + */ +template +class moDummyEval : public moEval{ +public: + typedef typename N::EOT EOT; + typedef typename EOT::Fitness Fitness; + + /** + * NOTHING TO DO + * @param _sol a solution + */ + void operator()(EOT& _sol, N& _n){} + +}; + +#endif diff --git a/trunk/paradiseo-mo/src/explorer/moILSexplorer.h b/trunk/paradiseo-mo/src/explorer/moILSexplorer.h index 2df3878f4..7debe322e 100644 --- a/trunk/paradiseo-mo/src/explorer/moILSexplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moILSexplorer.h @@ -41,20 +41,21 @@ #include #include #include +#include +#include /** * Explorer for an Iterated Local Search */ template< class NHE > -class moILSexplorer : public moNeighborhoodExplorer +class moILSexplorer : public moNeighborhoodExplorer > > { public: typedef typename NHE::Neighborhood Neighborhood ; typedef typename Neighborhood::EOT EOT ; typedef typename Neighborhood::Neighbor Neighbor ; - - using moNeighborhoodExplorer::neighborhood; - using moNeighborhoodExplorer::eval; + typedef moDummyNeighbor dummyNeighbor; + typedef moDummyNeighborhood dummyNeighborhood; /** * Constructor @@ -62,7 +63,7 @@ public: * @param _perturb a perturbation operator * @param _acceptCrit a acceptance criteria */ - moILSexplorer(moLocalSearch& _ls, moPerturbation& _perturb, moAcceptanceCriterion& _acceptCrit) : ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){ + moILSexplorer(moLocalSearch& _ls, moPerturbation& _perturb, moAcceptanceCriterion& _acceptCrit) : moNeighborhoodExplorer(), ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){ firstIteration=true; } @@ -88,7 +89,7 @@ public: * @param _solution the current solution */ virtual void updateParam(EOT & _solution){ - if((*this).isMoved()){ + if((*this).moveApplied()){ perturb.add(_solution,emptyNeighbor); acceptCrit.add(_solution,emptyNeighbor); } @@ -110,8 +111,10 @@ public: current=_solution; //perturb solution exept at the first iteration - if(!firstIteration) + if(!firstIteration){ perturb(current); + + } else firstIteration=false; diff --git a/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h b/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h index 98c1c50da..27f7cc922 100644 --- a/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h @@ -40,6 +40,9 @@ #include #include +//#include +#include +#include /** * Explore the neighborhood @@ -50,8 +53,11 @@ class moNeighborhoodExplorer : public eoUF public: typedef NH Neighborhood ; typedef typename Neighborhood::EOT EOT ; + typedef typename EOT::Fitness Fitness ; typedef typename Neighborhood::Neighbor Neighbor ; + moNeighborhoodExplorer():neighborhood(dummyNeighborhood), eval(dummyEval), isMoved(false) {} + /** * Constructor with a Neighborhood and evaluation function * @param _neighborhood the neighborhood @@ -123,6 +129,8 @@ public: } protected: + moDummyNeighborhood dummyNeighborhood; + moDummyEval dummyEval; Neighborhood & neighborhood; moEval& eval; bool isMoved; diff --git a/trunk/paradiseo-mo/src/explorer/moSAexplorer.h b/trunk/paradiseo-mo/src/explorer/moSAexplorer.h index a37e9ebb5..417935829 100644 --- a/trunk/paradiseo-mo/src/explorer/moSAexplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moSAexplorer.h @@ -67,7 +67,7 @@ public: * @param _solNeighborComparator a solution vs neighbor comparator * @param _nbStep maximum number of step to do */ - moSAexplorer(Neighborhood& _neighborhood, moEval& _eval, moSolNeighborComparator& _solNeighborComparator, moCoolingSchedule _coolingSchedule) : moNeighborhoodExplorer(_neighborhood, _eval), solNeighborComparator(_solNeighborComparator), coolingSchedule(_coolingSchedule) { + moSAexplorer(Neighborhood& _neighborhood, moEval& _eval, moSolNeighborComparator& _solNeighborComparator, moCoolingSchedule& _coolingSchedule) : moNeighborhoodExplorer(_neighborhood, _eval), solNeighborComparator(_solNeighborComparator), coolingSchedule(_coolingSchedule) { isAccept = false; if (!neighborhood.isRandom()) { @@ -168,11 +168,9 @@ private: // comparator betwenn solution and neighbor moSolNeighborComparator& solNeighborComparator; - // current number of step - unsigned int step; + moCoolingSchedule& coolingSchedule; - // maximum number of steps to do - unsigned int nbStep; + double temperature; //Pointer on the best and the current neighbor Neighbor current; diff --git a/trunk/paradiseo-mo/src/mo.h b/trunk/paradiseo-mo/src/mo.h index c3bef2971..6fad1f33b 100755 --- a/trunk/paradiseo-mo/src/mo.h +++ b/trunk/paradiseo-mo/src/mo.h @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -103,8 +104,8 @@ #include #include -#include -#include +#include +#include //#include //#include diff --git a/trunk/paradiseo-mo/src/neighborhood/moDummyNeighbor.h b/trunk/paradiseo-mo/src/neighborhood/moDummyNeighbor.h new file mode 100644 index 000000000..8f3ee7e42 --- /dev/null +++ b/trunk/paradiseo-mo/src/neighborhood/moDummyNeighbor.h @@ -0,0 +1,48 @@ +/* + +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 _moDummyNeighbor_h +#define _moDummyNeighbor_h + +#include + +/** + * Dummy Neighborhood + */ +template< class EOT , class Fitness > +class moDummyNeighbor : public moNeighbor< EOT,Fitness>{ +public: + + /** + * NOTHING TO DO + * @param _solution the related solution + */ + virtual void move(EOT& _solution){} +}; +#endif diff --git a/trunk/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h new file mode 100644 index 000000000..8094822db --- /dev/null +++ b/trunk/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h @@ -0,0 +1,78 @@ +/* + +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 _moDummyNeighborhood_h +#define _moDummyNeighborhood_h + +#include + +/** + * Dummy Neighborhood + */ +template< class N > +class moDummyNeighborhood : public moNeighborhood{ +public: + typedef N Neighbor; + typedef typename Neighbor::EOT EOT; + + /** + * NOTHING TO DO + * @param _solution the related solution + * @return always false + */ + virtual bool hasNeighbor(EOT & _solution){ + return false; + } + + /** + * NOTHING TO DO + * @param _solution the solution to explore + * @param _current the first neighbor + */ + virtual void init(EOT & _solution, Neighbor & _current){} + + /** + * NOTHING TO DO + * @param _solution the solution to explore + * @param _current the next neighbor + */ + virtual void next(EOT & _solution, Neighbor & _current){} + + /** + * NOTHING TO DO + * @param _solution the solution to explore + * @return always false + */ + virtual bool cont(EOT & _solution){ + return false; + } + +}; + +#endif diff --git a/trunk/paradiseo-mo/src/perturb/moMonOpPerturb.h b/trunk/paradiseo-mo/src/perturb/moMonOpPerturb.h index d9e4c2644..fa7b67a54 100644 --- a/trunk/paradiseo-mo/src/perturb/moMonOpPerturb.h +++ b/trunk/paradiseo-mo/src/perturb/moMonOpPerturb.h @@ -30,8 +30,10 @@ Contact: paradiseo-help@lists.gforge.inria.fr #ifndef _moMonOpPerturb_h #define _moMonOpPerturb_h +#include #include #include +#include /** * Perturbation operator using only a eoMonOp @@ -46,7 +48,7 @@ public: * Default Constructor * @param _monOp an eoMonOp (pertubation operator) */ - moMonOpPerturb(eoMonOp& _monOp):monOp(_monOp){} + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval):monOp(_monOp), fullEval(_fullEval){} /** * Apply monOp on the solution @@ -54,12 +56,15 @@ public: * @return value of monOp */ bool operator()(EOT& _solution){ - return monOp(_solution); + bool res = monOp(_solution); + fullEval(_solution); + return res; } private: /** monOp */ eoMonOp& monOp; + eoEvalFunc& fullEval; }; #endif diff --git a/trunk/paradiseo-mo/src/perturb/moPertubation.h b/trunk/paradiseo-mo/src/perturb/moPerturbation.h similarity index 100% rename from trunk/paradiseo-mo/src/perturb/moPertubation.h rename to trunk/paradiseo-mo/src/perturb/moPerturbation.h diff --git a/trunk/paradiseo-mo/test/moTestClass.h b/trunk/paradiseo-mo/test/moTestClass.h index 9324f3ac4..b0d71ee3a 100644 --- a/trunk/paradiseo-mo/test/moTestClass.h +++ b/trunk/paradiseo-mo/test/moTestClass.h @@ -63,7 +63,7 @@ typedef moDummyRndNeighborhood bitNeighborhood ; typedef EO Solution; -class moDummyNeighbor : public moNeighbor { +class moDummyNeighborTest : public moNeighbor { public: virtual void move(Solution & _solution) {} }; @@ -74,11 +74,11 @@ public: virtual void moveBack(Solution & _solution) {} }; -class moDummyNeighborhood : public moNeighborhood { +class moDummyNeighborhoodTest : public moNeighborhood { public: - typedef moDummyNeighbor Neighbor; + typedef moDummyNeighborTest Neighbor; - moDummyNeighborhood():i(0),j(0) {} + moDummyNeighborhoodTest():i(0),j(0) {} virtual bool hasNeighbor(EOT & _solution) { bool res; @@ -100,7 +100,7 @@ private: int i,j; }; -class moDummyEval: public eoEvalFunc { +class moDummyEvalTest: public eoEvalFunc { public: void operator()(Solution& _sol) { if (_sol.invalid()) diff --git a/trunk/paradiseo-mo/test/t-moFullEvalByCopy.cpp b/trunk/paradiseo-mo/test/t-moFullEvalByCopy.cpp index c7d7c838b..b487c6751 100644 --- a/trunk/paradiseo-mo/test/t-moFullEvalByCopy.cpp +++ b/trunk/paradiseo-mo/test/t-moFullEvalByCopy.cpp @@ -45,11 +45,11 @@ int main() { std::cout << "[t-moFullEvalByCopy] => START" << std::endl; Solution sol; - moDummyNeighbor neighbor; - moDummyEval eval; + moDummyNeighborTest neighbor; + moDummyEvalTest eval; //verif constructor - moFullEvalByCopy test(eval); + moFullEvalByCopy test(eval); sol.fitness(3); diff --git a/trunk/paradiseo-mo/test/t-moFullEvalByModif.cpp b/trunk/paradiseo-mo/test/t-moFullEvalByModif.cpp index 741b831d9..b52813c37 100644 --- a/trunk/paradiseo-mo/test/t-moFullEvalByModif.cpp +++ b/trunk/paradiseo-mo/test/t-moFullEvalByModif.cpp @@ -46,7 +46,7 @@ int main() { Solution sol; moDummyBackableNeighbor neighbor; - moDummyEval eval; + moDummyEvalTest eval; //verif constructor moFullEvalByModif test(eval); diff --git a/trunk/paradiseo-mo/test/t-moNeighbor.cpp b/trunk/paradiseo-mo/test/t-moNeighbor.cpp index 6fbff336d..ddf324941 100644 --- a/trunk/paradiseo-mo/test/t-moNeighbor.cpp +++ b/trunk/paradiseo-mo/test/t-moNeighbor.cpp @@ -42,7 +42,7 @@ int main() { std::cout << "[t-moNeighbor] => START" << std::endl; //test constructor - moDummyNeighbor test1, test2; + moDummyNeighborTest test1, test2; test1.fitness(3); //test operateur d'affectation @@ -50,7 +50,7 @@ int main() { assert(test1.fitness()==test2.fitness()); //test operateur de copy - moDummyNeighbor test3(test1); + moDummyNeighborTest test3(test1); assert(test1.fitness()==test3.fitness()); test1.printOn(std::cout); diff --git a/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp b/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp index 3fdeed63f..1d730a8dd 100644 --- a/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp +++ b/trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp @@ -48,15 +48,15 @@ int main() { std::cout << "[t-moSimpleHCexplorer] => START" << std::endl; Solution sol; - moDummyNeighbor neighbor; - moDummyEval eval; - moDummyNeighborhood nh; - moFullEvalByCopy fulleval(eval); - moNeighborComparator comp; - moSolNeighborComparator solNeighborComp; + moDummyNeighborTest neighbor; + moDummyEvalTest eval; + moDummyNeighborhoodTest nh; + moFullEvalByCopy fulleval(eval); + moNeighborComparator comp; + moSolNeighborComparator solNeighborComp; //verif constructor - moSimpleHCexplorer test(nh, fulleval, comp, solNeighborComp); + moSimpleHCexplorer test(nh, fulleval, comp, solNeighborComp); //verif operator() et accept: le neigorhood est construit pour qu'on tombe dans les 3 cas suivants: //hasNeighbor() retourne faux a l'entrée de l'operator() donc on doit pas continuer diff --git a/trunk/paradiseo-mo/test/t-moTrueContinuator.cpp b/trunk/paradiseo-mo/test/t-moTrueContinuator.cpp index eb717abbb..3c8d7d92a 100644 --- a/trunk/paradiseo-mo/test/t-moTrueContinuator.cpp +++ b/trunk/paradiseo-mo/test/t-moTrueContinuator.cpp @@ -43,7 +43,7 @@ int main() { std::cout << "[t-moTrueContinuator] => START" << std::endl; - moTrueContinuator test; + moTrueContinuator test; Solution s; assert(test(s)); diff --git a/trunk/paradiseo-mo/tutorial/oneMax/application/testILS.cpp b/trunk/paradiseo-mo/tutorial/oneMax/application/testILS.cpp index bbf6cd2bd..faf025aed 100644 --- a/trunk/paradiseo-mo/tutorial/oneMax/application/testILS.cpp +++ b/trunk/paradiseo-mo/tutorial/oneMax/application/testILS.cpp @@ -18,6 +18,7 @@ // the general include for eo #include #include +#include using namespace std; @@ -37,11 +38,16 @@ using namespace std; #include #include +#include +#include +#include + // REPRESENTATION //----------------------------------------------------------------------------- typedef eoBit Indi; typedef moBitNeighbor Neighbor ; // incremental evaluation typedef moOrderNeighborhood Neighborhood ; +typedef moSimpleHCexplorer NHE; void main_function(int argc, char **argv) { @@ -161,7 +167,20 @@ void main_function(int argc, char **argv) moTrueContinuator continuator;//always continue - moLocalSearch< moSimpleHCexplorer > localSearch(explorer, continuator, eval); + moLocalSearch< NHE > hc(explorer, continuator, eval); + + eoBitMutation monOp(1.0/vecSize); + + moMonOpPerturb perturb(monOp, eval); + + moAlwaysAcceptCrit accept; + + moILSexplorer< NHE > explorerILS(hc, perturb, accept); + + moIterContinuator continuatorILS(10); + + moLocalSearch< moILSexplorer< moSimpleHCexplorer > >localSearch(explorerILS, continuatorILS, eval); + /* ========================================================= * diff --git a/trunk/paradiseo-mo/tutorial/oneMax/application/testSimulatedAnnealing.cpp b/trunk/paradiseo-mo/tutorial/oneMax/application/testSimulatedAnnealing.cpp index 0b2c67774..71d14fcbb 100644 --- a/trunk/paradiseo-mo/tutorial/oneMax/application/testSimulatedAnnealing.cpp +++ b/trunk/paradiseo-mo/tutorial/oneMax/application/testSimulatedAnnealing.cpp @@ -66,10 +66,6 @@ void main_function(int argc, char **argv) parser.processParam( vecSizeParam, "Representation" ); unsigned vecSize = vecSizeParam.value(); - eoValueParam stepParam(10, "nbStep", "Number of steps of the random walk", 'n'); - parser.processParam( stepParam, "Representation" ); - unsigned nbStep = stepParam.value(); - // the name of the "status" file where all actual parameter values will be saved string str_status = parser.ProgramName() + ".status"; // default value eoValueParam statusParam(str_status.c_str(), "status", "Status file"); @@ -154,7 +150,7 @@ void main_function(int argc, char **argv) * ========================================================= */ // initial temp, factor of decrease, number of steps without decrease, final temp. - moSimpleCoolingSchdedule coolingSchedule(10, 0.9, 1, 0.01); + moSimpleCoolingSchedule coolingSchedule(10, 0.9, 1, 0.01); /* ========================================================= * @@ -172,7 +168,7 @@ void main_function(int argc, char **argv) moTrueContinuator continuator;//always continue - moLocalSearch< moMetropolisHastingExplorer > localSearch(explorer, continuator, eval); + moLocalSearch< moSAexplorer > localSearch(explorer, continuator, eval); /* ========================================================= *