Skip to content

Commit

Permalink
Add max load checking asserts in RouteSplit::apply.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Sep 22, 2023
1 parent cff4e0f commit b0afd61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/problems/cvrp/operators/route_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void RouteSplit::apply() {
std::move(s_route.begin() + choice.split_rank,
s_route.end(),
std::back_inserter(end_route.route));
end_route.update_amounts(_input);
assert(end_route.max_load() ==
source.sub_route_max_load_after(choice.split_rank));

// Empty route holding the beginning of the split.
auto& begin_route = _sol[_begin_route_rank];
Expand All @@ -79,12 +82,12 @@ void RouteSplit::apply() {
std::move(s_route.begin(),
s_route.begin() + choice.split_rank,
std::back_inserter(begin_route.route));
begin_route.update_amounts(_input);
assert(begin_route.max_load() ==
source.sub_route_max_load_before(choice.split_rank));

s_route.clear();

source.update_amounts(_input);
end_route.update_amounts(_input);
begin_route.update_amounts(_input);
}

std::vector<Index> RouteSplit::addition_candidates() const {
Expand Down
4 changes: 4 additions & 0 deletions src/problems/vrptw/operators/route_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void RouteSplit::apply() {
s_route.end(),
0,
0);
assert(end_route.max_load() ==
_tw_s_route.sub_route_max_load_after(choice.split_rank));

// Empty route holding the beginning of the split.
auto& begin_route = _tw_sol[_begin_route_rank];
Expand All @@ -79,6 +81,8 @@ void RouteSplit::apply() {
s_route.begin() + choice.split_rank,
0,
0);
assert(begin_route.max_load() ==
_tw_s_route.sub_route_max_load_before(choice.split_rank));

_tw_s_route.remove(_input, 0, s_route.size());
}
Expand Down

0 comments on commit b0afd61

Please sign in to comment.