Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong delivery values #1191

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#### Core solving

- 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)
- Segfault when using the C++ API with empty vehicles (#1187)
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 @@ -2379,9 +2379,12 @@ void LocalSearch<Route,
std::vector<Index> between_pd(_sol[v].route.begin() + r + 1,
_sol[v].route.begin() + delivery_r);

const auto delivery_between_pd =
_sol[v].delivery_in_range(r + 1, delivery_r);

valid_removal =
_sol[v].is_valid_addition_for_tw(_input,
_input.zero_amount(),
delivery_between_pd,
between_pd.begin(),
between_pd.end(),
r,
Expand Down
6 changes: 4 additions & 2 deletions src/problems/vrptw/operators/pd_shift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ PDShift::PDShift(const Input& input,

void PDShift::compute_gain() {
// Check for valid removal wrt TW constraints.
if (!_tw_s_route.is_valid_addition_for_tw(_input,
_input.zero_amount(),
if (const auto delivery_between_pd =
_tw_s_route.delivery_in_range(_s_p_rank + 1, _s_d_rank);
!_tw_s_route.is_valid_addition_for_tw(_input,
delivery_between_pd,
s_route.begin() + _s_p_rank + 1,
s_route.begin() + _s_d_rank,
_s_p_rank,
Expand Down