Add a swap function
This commit is contained in:
9
sa.hpp
9
sa.hpp
@@ -49,10 +49,17 @@ class solution {
|
||||
}
|
||||
|
||||
void randomize() {
|
||||
shuffle(items.begin(), items.end(), gen);
|
||||
std::shuffle(items.begin(), items.end(), gen);
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user