From 159de4ca13b22dcf7837c88aab476c6063dfb37c Mon Sep 17 00:00:00 2001 From: verel Date: Sat, 10 Dec 2011 10:59:35 +0000 Subject: [PATCH] Use the variable selectedNeighbor moSimpleHC, moFirstImprHC, moRandomBestHC git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2558 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/explorer/moRandomBestHCexplorer.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/trunk/paradiseo-mo/src/explorer/moRandomBestHCexplorer.h b/trunk/paradiseo-mo/src/explorer/moRandomBestHCexplorer.h index 2db727860..d5e12f087 100644 --- a/trunk/paradiseo-mo/src/explorer/moRandomBestHCexplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moRandomBestHCexplorer.h @@ -56,6 +56,7 @@ public: using moNeighborhoodExplorer::neighborhood; using moNeighborhoodExplorer::eval; using moNeighborhoodExplorer::currentNeighbor; + using moNeighborhoodExplorer::selectedNeighbor; /** * Constructor @@ -137,6 +138,12 @@ public: else if (neighborComparator.equals(currentNeighbor, bestVector[0])) //if the current is equals to previous best solutions then update vector of the best solution bestVector.push_back(currentNeighbor); } + + // choose randomly one of the best solutions + unsigned int i = rng.random(bestVector.size()); + + // the selected Neighbor + selectedNeighbor = bestVector[i]; } else { //if _solution hasn't neighbor, @@ -157,6 +164,7 @@ public: * move the solution with the best neighbor * @param _solution the solution to move */ + /* virtual void move(EOT & _solution) { // choose randomly one of the best solutions unsigned int i = rng.random(bestVector.size()); @@ -167,6 +175,7 @@ public: //update its fitness _solution.fitness(bestVector[i].fitness()); }; + */ /** * accept test if an amelirated neighbor was found @@ -175,7 +184,7 @@ public: */ virtual bool accept(EOT & _solution) { if (neighborhood.hasNeighbor(_solution)) - isAccept = solNeighborComparator(_solution, bestVector[0]) ; + isAccept = solNeighborComparator(_solution, selectedNeighbor) ; return isAccept; };