Add the notion of currentNeighbor in the moRandomWalkExplorer, and ILS

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2545 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
verel 2011-12-06 13:50:32 +00:00
commit 6f6770e6de

View file

@ -57,6 +57,7 @@ public:
using moNeighborhoodExplorer<Neighbor>::neighborhood; using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval; using moNeighborhoodExplorer<Neighbor>::eval;
using moNeighborhoodExplorer<Neighbor>::currentNeighbor;
/** /**
* Constructor * Constructor
@ -65,7 +66,6 @@ public:
*/ */
moRandomWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval) { moRandomWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval) {
isAccept = false; isAccept = false;
current=new Neighbor();
if (!neighborhood.isRandom()) { if (!neighborhood.isRandom()) {
std::cout << "moRandomWalkExplorer::Warning -> the neighborhood used is not random" << std::endl; std::cout << "moRandomWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
} }
@ -75,7 +75,6 @@ public:
* Destructor * Destructor
*/ */
~moRandomWalkExplorer() { ~moRandomWalkExplorer() {
delete current;
} }
/** /**
@ -109,10 +108,10 @@ public:
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if (neighborhood.hasNeighbor(_solution)) { if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, currentNeighbor);
//eval the _solution moved with the neighbor and stock the result in the neighbor //eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, (*current)); eval(_solution, currentNeighbor);
isAccept = true; isAccept = true;
} }
@ -137,9 +136,9 @@ public:
*/ */
virtual void move(EOT & _solution) { virtual void move(EOT & _solution) {
//move the solution //move the solution
(*current).move(_solution); currentNeighbor.move(_solution);
//update its fitness //update its fitness
_solution.fitness((*current).fitness()); _solution.fitness(currentNeighbor.fitness());
}; };
/** /**
@ -154,9 +153,6 @@ public:
}; };
private: private:
//Pointer on the best and the current neighbor
Neighbor* current;
// true if the move is accepted // true if the move is accepted
bool isAccept ; bool isAccept ;
}; };