Add a swap function
This commit is contained in:
parent
55008b3e40
commit
7dbfdde3f1
9
sa.hpp
9
sa.hpp
@ -49,10 +49,17 @@ class solution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void randomize() {
|
void randomize() {
|
||||||
shuffle(items.begin(), items.end(), gen);
|
std::shuffle(items.begin(), items.end(), gen);
|
||||||
|
|
||||||
fitness = calculate_boxes();
|
fitness = calculate_boxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swap(solution &other) {
|
||||||
|
std::swap(fitness, other.fitness);
|
||||||
|
std::swap(items, other.items);
|
||||||
|
std::swap(capacity, other.capacity);
|
||||||
|
std::swap(gen, other.gen);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sa
|
} // namespace sa
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user