From 9cf796d2e0c5ea76e7a6e2a151930f5be3201c41 Mon Sep 17 00:00:00 2001 From: verel Date: Tue, 6 Dec 2011 13:35:37 +0000 Subject: [PATCH] Add the notion of currentNeighbor in the moSAExplorer git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2543 331e1502-861f-0410-8da2-ba01fb791d7f --- trunk/paradiseo-mo/src/explorer/moSAexplorer.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/trunk/paradiseo-mo/src/explorer/moSAexplorer.h b/trunk/paradiseo-mo/src/explorer/moSAexplorer.h index dfe818a90..23ba5330f 100644 --- a/trunk/paradiseo-mo/src/explorer/moSAexplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moSAexplorer.h @@ -59,6 +59,7 @@ public: using moNeighborhoodExplorer::neighborhood; using moNeighborhoodExplorer::eval; + using moNeighborhoodExplorer::currentNeighbor; /** * Constructor @@ -112,10 +113,10 @@ public: //Test if _solution has a Neighbor if (neighborhood.hasNeighbor(_solution)) { //init on the first neighbor: supposed to be random solution in the neighborhood - neighborhood.init(_solution, current); + neighborhood.init(_solution, currentNeighbor); //eval the _solution moved with the neighbor and stock the result in the neighbor - eval(_solution, current); + eval(_solution, currentNeighbor); } else { //if _solution hasn't neighbor, @@ -138,9 +139,9 @@ public: */ virtual void move(EOT & _solution) { //move the solution - current.move(_solution); + currentNeighbor.move(_solution); //update its fitness - _solution.fitness(current.fitness()); + _solution.fitness(currentNeighbor.fitness()); }; /** @@ -152,10 +153,10 @@ public: double alpha=0.0; double fit1, fit2; if (neighborhood.hasNeighbor(_solution)) { - if (solNeighborComparator(_solution, current)) // accept if the current neighbor is better than the solution + if (solNeighborComparator(_solution, currentNeighbor)) // accept if the current neighbor is better than the solution isAccept = true; else { - fit1=(double)current.fitness(); + fit1=(double)currentNeighbor.fitness(); fit2=(double)_solution.fitness(); if (fit1 < fit2) // this is a maximization alpha = exp((fit1 - fit2) / temperature ); @@ -183,9 +184,6 @@ private: double temperature; - //Pointer on the best and the current neighbor - Neighbor current; - // true if the move is accepted bool isAccept ; };