Skip to content

Commit

Permalink
Properly update best_removals.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Jan 29, 2025
1 parent 669989b commit 1564f98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

- Solution quality regression when using lots of skills (#1193)
- Invalid route reached by `PriorityReplace` (#1162)
- Account for gain and assigned tasks to pick priority-improving moves (#1212)
- Crash due to wrong delivery values in some validity checks (#1164)
- Crash when input is valid JSON but not an object (#1172)
- Capacity array check consistency (#1086)
Expand Down
5 changes: 4 additions & 1 deletion src/algorithms/local_search/local_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void LocalSearch<Route,
// Dummy init to enter first loop.
Eval best_gain(static_cast<Cost>(1));
Priority best_priority = 0;
auto best_removal = std::numeric_limits<unsigned>::max();

while (best_gain.cost > 0 || best_priority > 0) {
if (_deadline.has_value() && _deadline.value() < utils::now()) {
Expand Down Expand Up @@ -1838,7 +1839,7 @@ void LocalSearch<Route,
// Find best overall move, first checking priority increase then
// best gain if no priority increase is available.
best_priority = 0;
auto best_removal = std::numeric_limits<unsigned>::max();
best_removal = std::numeric_limits<unsigned>::max();
best_gain = Eval();
Index best_source = 0;
Index best_target = 0;
Expand Down Expand Up @@ -1949,6 +1950,7 @@ void LocalSearch<Route,
for (auto v_rank : update_candidates) {
best_gains[v_rank].assign(_nb_vehicles, Eval());
best_priorities[v_rank] = 0;
best_removals[v_rank] = std::numeric_limits<unsigned>::max();
best_ops[v_rank] = std::vector<std::unique_ptr<Operator>>(_nb_vehicles);
}

Expand Down Expand Up @@ -1991,6 +1993,7 @@ void LocalSearch<Route,
if (invalidate_move) {
best_gains[v][v] = Eval();
best_priorities[v] = 0;
best_removals[v] = std::numeric_limits<unsigned>::max();
best_ops[v][v] = std::unique_ptr<Operator>();
s_t_pairs.emplace_back(v, v);
}
Expand Down

0 comments on commit 1564f98

Please sign in to comment.