From 0d293edcb274be4e316e9c49113d5e1f70c3f170 Mon Sep 17 00:00:00 2001 From: jcoupey Date: Fri, 22 Sep 2023 11:39:32 +0200 Subject: [PATCH] Properly handle capacity constraints for RouteSplit. --- CHANGELOG.md | 2 ++ src/algorithms/local_search/route_split_utils.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d9a94192..b97229839 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Refactor heuristics to be able to operate on a subset of jobs and vehicles (#837) - Account for vehicle/job compatibility in heuristic regrets values (#982) - Slightly reduce computing times for SWAP* operator (#987) +- Refactor `RouteSplit` operator (#996) ### Fixed @@ -40,6 +41,7 @@ - Meaningless `location_index` provided in output for break steps (#877) - `max_travel_time` not accounted for with vehicle steps in solving mode (#954) - `max_travel_time` not accounted for in `RouteSplit` (#941) +- Wrong capacity checks in `RouteSplit` (#981) - Address sonarcloud "bugs" reports (#984) - Address some sonarcloud "code smell" reports (#986) diff --git a/src/algorithms/local_search/route_split_utils.h b/src/algorithms/local_search/route_split_utils.h index 8d207d04f..32be10943 100644 --- a/src/algorithms/local_search/route_split_utils.h +++ b/src/algorithms/local_search/route_split_utils.h @@ -59,7 +59,7 @@ compute_best_route_split_choice(const Input& input, auto second_best_end_eval = NO_EVAL; Index second_v_end = 0; // dummy init - const auto& end_load = source.bwd_peak(r); + const auto end_max_load = source.sub_route_max_load_after(r); const auto end_delivery = source.delivery_in_range(r, source.size()); for (Index v_rank = 0; v_rank < empty_route_ranks.size(); ++v_rank) { @@ -67,7 +67,7 @@ compute_best_route_split_choice(const Input& input, const auto& end_v = input.vehicles[v]; if (r < sol_state.bwd_skill_rank[s_vehicle][v] || - !(end_load <= end_v.capacity) || + !(end_max_load <= end_v.capacity) || end_v.max_tasks < source.size() - r) { continue; } @@ -131,7 +131,7 @@ compute_best_route_split_choice(const Input& input, auto second_best_begin_eval = NO_EVAL; Index second_v_begin = 0; // dummy init - const auto& begin_load = source.fwd_peak(r - 1); + const auto begin_max_load = source.sub_route_max_load_before(r); const auto begin_delivery = source.delivery_in_range(0, r); for (Index v_rank = 0; v_rank < empty_route_ranks.size(); ++v_rank) { @@ -139,7 +139,7 @@ compute_best_route_split_choice(const Input& input, const auto& begin_v = input.vehicles[v]; if (sol_state.fwd_skill_rank[s_vehicle][v] < r || - !(begin_load <= begin_v.capacity) || begin_v.max_tasks < r) { + !(begin_max_load <= begin_v.capacity) || begin_v.max_tasks < r) { continue; }