From 9d867cb9fa27345d6e5fa82ce64c5464cb513029 Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 31 Oct 2012 13:47:11 +0100 Subject: [PATCH] Please enter the commit message for your changes. Lines starting --- mo/src/problems/permutation/moIndexedSwapNeighbor.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mo/src/problems/permutation/moIndexedSwapNeighbor.h b/mo/src/problems/permutation/moIndexedSwapNeighbor.h index cff62ffd7..06491f134 100644 --- a/mo/src/problems/permutation/moIndexedSwapNeighbor.h +++ b/mo/src/problems/permutation/moIndexedSwapNeighbor.h @@ -43,6 +43,7 @@ public: using moBackableNeighbor::fitness; using moIndexNeighbor::key; + using moIndexNeighbor::index; /** * Apply the swap @@ -88,20 +89,21 @@ public: unsigned int n = (unsigned int) ( (1 + sqrt(1 + 8 * _key)) / 2); indices.first = _key - (n - 1) * n / 2; - indices.second = N - 1 - (n - 1 - _first); + indices.second = _solution.size() - 1 - (n - 1 - indices.first); } /** * Setter to fix the two indexes to swap + * @param _solution solution from which the neighborhood is visited * @param _first first index * @param _second second index */ - void set(unsigned int _first, unsigned int _second) { + void set(EOT & _solution, unsigned int _first, unsigned int _second) { indices.first = _first; indices.second = _second; // set the index - unsigned n = _solution.nbClientsWithin() + _first - _second; + unsigned n = _solution.size() + _first - _second; index( _first + n * (n - 1) / 2 ); }