From ffda8592d8c35989c15e85035bf32b0b4000dcca Mon Sep 17 00:00:00 2001 From: jcoupey Date: Thu, 14 Nov 2024 16:42:14 +0100 Subject: [PATCH 1/4] Fix delivery amount for removal check in PDShift. --- src/problems/vrptw/operators/pd_shift.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/problems/vrptw/operators/pd_shift.cpp b/src/problems/vrptw/operators/pd_shift.cpp index 0fa959e72..4558ff7f5 100644 --- a/src/problems/vrptw/operators/pd_shift.cpp +++ b/src/problems/vrptw/operators/pd_shift.cpp @@ -37,8 +37,11 @@ PDShift::PDShift(const Input& input, void PDShift::compute_gain() { // Check for valid removal wrt TW constraints. + const auto delivery_between_pd = + _tw_s_route.delivery_in_range(_s_p_rank + 1, _s_d_rank); + if (!_tw_s_route.is_valid_addition_for_tw(_input, - _input.zero_amount(), + delivery_between_pd, s_route.begin() + _s_p_rank + 1, s_route.begin() + _s_d_rank, _s_p_rank, From 456417d1615bd78e694c082ce4f199f406219aea Mon Sep 17 00:00:00 2001 From: jcoupey Date: Thu, 14 Nov 2024 16:42:51 +0100 Subject: [PATCH 2/4] Fix delivery amount for validity check in remove_from_routes. --- src/algorithms/local_search/local_search.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/algorithms/local_search/local_search.cpp b/src/algorithms/local_search/local_search.cpp index 07dc1a3c7..ebe620807 100644 --- a/src/algorithms/local_search/local_search.cpp +++ b/src/algorithms/local_search/local_search.cpp @@ -2379,9 +2379,12 @@ void LocalSearch 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, From f4013d736a84ee1b5a3834aad4dedbd1ae18f458 Mon Sep 17 00:00:00 2001 From: jcoupey Date: Thu, 14 Nov 2024 16:46:37 +0100 Subject: [PATCH 3/4] Mention delivery values fix in changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index edbd665e8..c88cc924f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) From e92bd0452395680251ce0c37826845976ff285a9 Mon Sep 17 00:00:00 2001 From: jcoupey Date: Thu, 14 Nov 2024 16:51:56 +0100 Subject: [PATCH 4/4] Use init-statement inside if. --- src/problems/vrptw/operators/pd_shift.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/problems/vrptw/operators/pd_shift.cpp b/src/problems/vrptw/operators/pd_shift.cpp index 4558ff7f5..ee03b9e79 100644 --- a/src/problems/vrptw/operators/pd_shift.cpp +++ b/src/problems/vrptw/operators/pd_shift.cpp @@ -37,10 +37,9 @@ PDShift::PDShift(const Input& input, void PDShift::compute_gain() { // Check for valid removal wrt TW constraints. - const auto delivery_between_pd = - _tw_s_route.delivery_in_range(_s_p_rank + 1, _s_d_rank); - - if (!_tw_s_route.is_valid_addition_for_tw(_input, + 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,