minor update on permutation hoods

This commit is contained in:
Arnaud Liefooghe 2016-07-07 11:28:07 +02:00
commit ee71ea2477
2 changed files with 18 additions and 9 deletions

View file

@ -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 * Indexed Swap Neighbor: the position of the swap are computed according to the index
*/ */
template <class EOT, class Fitness=typename EOT::Fitness> template <class EOT, class Fitness=typename EOT::Fitness>
class moIndexedSwapNeighbor: public moBackableNeighbor<EOT, Fitness>, public moIndexNeighbor<EOT> class moIndexedSwapNeighbor: public moBackableNeighbor<EOT, Fitness>, public moIndexNeighbor<EOT, Fitness>
{ {
public: public:
using moBackableNeighbor<EOT>::fitness; using moBackableNeighbor<EOT, Fitness>::fitness;
using moIndexNeighbor<EOT>::key; using moIndexNeighbor<EOT, Fitness>::key;
using moIndexNeighbor<EOT>::index; using moIndexNeighbor<EOT, Fitness>::index;
/** /**
* Default Constructor * Default Constructor
@ -78,11 +78,12 @@ public:
*/ */
virtual void move(EOT& _solution) { virtual void move(EOT& _solution) {
// bof utiliser plutot le template du vector : to do // bof utiliser plutot le template du vector : to do
EOT tmp(1); // EOT tmp(1);
//
tmp[0] = _solution[indices.first]; // tmp[0] = _solution[indices.first];
_solution[indices.first] = _solution[indices.second]; // _solution[indices.first] = _solution[indices.second];
_solution[indices.second] = tmp[0]; // _solution[indices.second] = tmp[0];
std::swap(_solution[indices.first], _solution[indices.second]);
_solution.invalidate(); _solution.invalidate();
} }

View file

@ -152,6 +152,14 @@ public:
std::cout << key << ": [" << indices.first << ", " << indices.second << "] -> " << (*this).fitness() << std::endl; 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: private:
std::pair<unsigned int, unsigned int> indices; std::pair<unsigned int, unsigned int> indices;