From ee71ea24779f06fba1db895255e1e17082344bb7 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Thu, 7 Jul 2016 11:28:07 +0200 Subject: [PATCH] minor update on permutation hoods --- .../permutation/moIndexedSwapNeighbor.h | 19 ++++++++++--------- mo/src/problems/permutation/moShiftNeighbor.h | 8 ++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/mo/src/problems/permutation/moIndexedSwapNeighbor.h b/mo/src/problems/permutation/moIndexedSwapNeighbor.h index d3ddababf..4706305f6 100644 --- a/mo/src/problems/permutation/moIndexedSwapNeighbor.h +++ b/mo/src/problems/permutation/moIndexedSwapNeighbor.h @@ -37,13 +37,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr * Indexed Swap Neighbor: the position of the swap are computed according to the index */ template -class moIndexedSwapNeighbor: public moBackableNeighbor, public moIndexNeighbor +class moIndexedSwapNeighbor: public moBackableNeighbor, public moIndexNeighbor { public: - using moBackableNeighbor::fitness; - using moIndexNeighbor::key; - using moIndexNeighbor::index; + using moBackableNeighbor::fitness; + using moIndexNeighbor::key; + using moIndexNeighbor::index; /** * Default Constructor @@ -78,11 +78,12 @@ public: */ virtual void move(EOT& _solution) { // bof utiliser plutot le template du vector : to do - EOT tmp(1); - - tmp[0] = _solution[indices.first]; - _solution[indices.first] = _solution[indices.second]; - _solution[indices.second] = tmp[0]; +// EOT tmp(1); +// +// tmp[0] = _solution[indices.first]; +// _solution[indices.first] = _solution[indices.second]; +// _solution[indices.second] = tmp[0]; + std::swap(_solution[indices.first], _solution[indices.second]); _solution.invalidate(); } diff --git a/mo/src/problems/permutation/moShiftNeighbor.h b/mo/src/problems/permutation/moShiftNeighbor.h index 87dfb9265..13eba1849 100644 --- a/mo/src/problems/permutation/moShiftNeighbor.h +++ b/mo/src/problems/permutation/moShiftNeighbor.h @@ -151,6 +151,14 @@ public: void print() { std::cout << key << ": [" << indices.first << ", " << indices.second << "] -> " << (*this).fitness() << std::endl; } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moShiftNeighbor"; + } private: std::pair indices;