minor update on permutation hoods
This commit is contained in:
parent
fc4a398459
commit
ee71ea2477
2 changed files with 18 additions and 9 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue