From 9135968b0e7139f9c6d053409ddcb179ce4041ea Mon Sep 17 00:00:00 2001 From: verel Date: Thu, 30 Sep 2010 13:14:33 +0000 Subject: [PATCH] Change the random walk explorer (nbStepMax dissappearts) and the constructor of moRandomWalk git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1944 331e1502-861f-0410-8da2-ba01fb791d7f --- trunk/paradiseo-mo/src/algo/moRandomWalk.h | 19 ++++++++-------- .../src/explorer/moRandomWalkExplorer.h | 22 +++++++------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/trunk/paradiseo-mo/src/algo/moRandomWalk.h b/trunk/paradiseo-mo/src/algo/moRandomWalk.h index cbf7dcb2b..dafa3f277 100644 --- a/trunk/paradiseo-mo/src/algo/moRandomWalk.h +++ b/trunk/paradiseo-mo/src/algo/moRandomWalk.h @@ -32,7 +32,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include #include -#include +#include #include #include @@ -59,8 +59,9 @@ public: * @param _nbStepMax number of step of the walk */ moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc& _fullEval, moEval& _eval, unsigned _nbStepMax): - moLocalSearch(explorer, trueCont, _fullEval), - explorer(_neighborhood, _eval, _nbStepMax) + moLocalSearch(explorer, iterCont, _fullEval), + iterCont(_nbStepMax), + explorer(_neighborhood, _eval) {} /** @@ -68,17 +69,17 @@ public: * @param _neighborhood the neighborhood * @param _fullEval the full evaluation function * @param _eval neighbor's evaluation function - * @param _nbStepMax number of step of the walk - * @param _cont an external continuator + * @param _cont a user-defined continuator */ - moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc& _fullEval, moEval& _eval, unsigned _nbStepMax, moContinuator& _cont): + moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc& _fullEval, moEval& _eval, moContinuator& _cont): moLocalSearch(explorer, _cont, _fullEval), - explorer(_neighborhood, _eval, _nbStepMax) + iterCont(0), + explorer(_neighborhood, _eval) {} private: - // always true continuator - moTrueContinuator trueCont; + // the continuator to stop on a maximum number of step + moIterContinuator iterCont; // the explorer of the random walk moRandomWalkExplorer explorer; }; diff --git a/trunk/paradiseo-mo/src/explorer/moRandomWalkExplorer.h b/trunk/paradiseo-mo/src/explorer/moRandomWalkExplorer.h index 331601094..78c7cbe91 100644 --- a/trunk/paradiseo-mo/src/explorer/moRandomWalkExplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moRandomWalkExplorer.h @@ -42,6 +42,11 @@ /** * Explorer for a random walk + * + * Choose at each step a random neighbor's solution + * So the neighborhood have to be "random" + * + * The number of steps of the walk is not limited in the explorer */ template< class Neighbor > class moRandomWalkExplorer : public moNeighborhoodExplorer @@ -55,15 +60,12 @@ public: /** * Constructor - * @param _neighborhood the neighborhood + * @param _neighborhood the neighborhood (which have to be random) * @param _eval the evaluation function - * @param _nbStep maximum number of step to do */ - moRandomWalkExplorer(Neighborhood& _neighborhood, moEval& _eval, unsigned _nbStep) : moNeighborhoodExplorer(_neighborhood, _eval), nbStep(_nbStep) { + moRandomWalkExplorer(Neighborhood& _neighborhood, moEval& _eval) : moNeighborhoodExplorer(_neighborhood, _eval) { isAccept = false; current=new Neighbor(); - // number of step done - step = 0; if (!neighborhood.isRandom()) { std::cout << "moRandomWalkExplorer::Warning -> the neighborhood used is not random" << std::endl; } @@ -81,7 +83,6 @@ public: * @param _solution unused solution */ virtual void initParam(EOT & _solution) { - step = 0; isAccept = true; }; @@ -90,7 +91,6 @@ public: * @param _solution unused solution */ virtual void updateParam(EOT & _solution) { - step++; }; /** @@ -128,7 +128,7 @@ public: * @return true there is some steps to do */ virtual bool isContinue(EOT & _solution) { - return (step < nbStep) && isAccept ; + return isAccept ; }; /** @@ -154,12 +154,6 @@ public: }; private: - // current number of step - unsigned int step; - - // maximum number of steps to do - unsigned int nbStep; - //Pointer on the best and the current neighbor Neighbor* current;