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
This commit is contained in:
verel 2010-09-30 13:14:33 +00:00
commit 9135968b0e
2 changed files with 18 additions and 23 deletions

View file

@ -32,7 +32,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <algo/moLocalSearch.h>
#include <explorer/moRandomWalkExplorer.h>
#include <continuator/moTrueContinuator.h>
#include <continuator/moIterContinuator.h>
#include <eval/moEval.h>
#include <eoEvalFunc.h>
@ -59,8 +59,9 @@ public:
* @param _nbStepMax number of step of the walk
*/
moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax):
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
explorer(_neighborhood, _eval, _nbStepMax)
moLocalSearch<Neighbor>(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<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont):
moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
explorer(_neighborhood, _eval, _nbStepMax)
iterCont(0),
explorer(_neighborhood, _eval)
{}
private:
// always true continuator
moTrueContinuator<Neighbor> trueCont;
// the continuator to stop on a maximum number of step
moIterContinuator<Neighbor> iterCont;
// the explorer of the random walk
moRandomWalkExplorer<Neighbor> explorer;
};

View file

@ -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<Neighbor>
@ -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<Neighbor>& _eval, unsigned _nbStep) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), nbStep(_nbStep) {
moRandomWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval) : moNeighborhoodExplorer<Neighbor>(_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;