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
*/
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:
using moBackableNeighbor<EOT>::fitness;
using moIndexNeighbor<EOT>::key;
using moIndexNeighbor<EOT>::index;
using moBackableNeighbor<EOT, Fitness>::fitness;
using moIndexNeighbor<EOT, Fitness>::key;
using moIndexNeighbor<EOT, Fitness>::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();
}

View file

@ -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<unsigned int, unsigned int> indices;