Skip to content

Commit

Permalink
Adjust operator filtering logic for net priority gain.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Nov 10, 2023
1 parent cafd155 commit 26b4c4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/algorithms/local_search/local_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,11 @@ void LocalSearch<Route,

assert(fwd_over_rank > 0 || bwd_over_rank > 0);

if (best_priorities[source] <=
std::max(begin_priority_gain, end_priority_gain)) {
const auto best_current_priority =
std::max(begin_priority_gain, end_priority_gain);

if (best_current_priority > 0 &&
best_priorities[source] <= best_current_priority) {
#ifdef LOG_LS_OPERATORS
++tried_moves[OperatorName::PriorityReplace];
#endif
Expand All @@ -470,9 +473,6 @@ void LocalSearch<Route,
if (r.is_valid() &&
(best_priorities[source] < r.priority_gain() ||
(best_priorities[source] == r.priority_gain() &&
// Avoid cycling between replacements with gain
// improvement but zero net priority gain.
r.priority_gain() > 0 &&
best_gains[source][source] < r.gain()))) {
best_priorities[source] = r.priority_gain();
// This may potentially define a negative value as best
Expand Down
1 change: 1 addition & 0 deletions src/problems/cvrp/operators/priority_replace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ PriorityReplace::PriorityReplace(const Input& input,
_best_known_priority_gain(best_known_priority_gain),
_unassigned(unassigned) {
assert(!s_route.empty());
assert(_start_priority_gain > 0 or _end_priority_gain > 0);
}

void PriorityReplace::compute_start_gain() {
Expand Down

0 comments on commit 26b4c4f

Please sign in to comment.