From 8ca458536e220074ca5b8eda29226a335adf8a5b Mon Sep 17 00:00:00 2001 From: verel Date: Tue, 6 Dec 2011 09:39:29 +0000 Subject: [PATCH] Minor change of the best and current in moSimpleHC git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2537 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/explorer/moSimpleHCexplorer.h | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/trunk/paradiseo-mo/src/explorer/moSimpleHCexplorer.h b/trunk/paradiseo-mo/src/explorer/moSimpleHCexplorer.h index 5ecba3318..df934cb9a 100644 --- a/trunk/paradiseo-mo/src/explorer/moSimpleHCexplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moSimpleHCexplorer.h @@ -62,16 +62,12 @@ public: */ moSimpleHCexplorer(Neighborhood& _neighborhood, moEval& _eval, moNeighborComparator& _neighborComparator, moSolNeighborComparator& _solNeighborComparator) : moNeighborhoodExplorer(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) { isAccept = false; - current=new Neighbor(); - best=new Neighbor(); } /** * Destructor */ ~moSimpleHCexplorer() { - delete current; - delete best; } /** @@ -100,23 +96,23 @@ public: //Test if _solution has a Neighbor if (neighborhood.hasNeighbor(_solution)) { //init the first neighbor - neighborhood.init(_solution, (*current)); + neighborhood.init(_solution, current); //eval the _solution moved with the neighbor and stock the result in the neighbor - eval(_solution, (*current)); + eval(_solution, current); //initialize the best neighbor - (*best) = (*current); + best = current; //test all others neighbors while (neighborhood.cont(_solution)) { //next neighbor - neighborhood.next(_solution, (*current)); + neighborhood.next(_solution, current); //eval - eval(_solution, (*current)); + eval(_solution, current); //if we found a better neighbor, update the best - if (neighborComparator((*best), (*current))) { - (*best) = (*current); + if (neighborComparator(best, current)) { + best = current; } } @@ -142,10 +138,10 @@ public: */ virtual void move(EOT & _solution) { //move the solution - (*best).move(_solution); + best.move(_solution); //update its fitness - _solution.fitness((*best).fitness()); + _solution.fitness(best.fitness()); }; @@ -156,7 +152,7 @@ public: */ virtual bool accept(EOT & _solution) { if (neighborhood.hasNeighbor(_solution)) { - isAccept = solNeighborComparator(_solution, (*best)) ; + isAccept = solNeighborComparator(_solution, best) ; } return isAccept; }; @@ -175,8 +171,8 @@ private: moSolNeighborComparator& solNeighborComparator; //Pointer on the best and the current neighbor - Neighbor* best; - Neighbor* current; + Neighbor best; + Neighbor current; // true if the move is accepted bool isAccept ;