Skip to content

Commit

Permalink
Adress review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
krypt-n committed Sep 10, 2021
1 parent 6f0fd2a commit e42c3b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/algorithms/local_search/insertion_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ RouteInsertion compute_best_insertion_pd(const Input& input,
}
}
}
assert(result.cost <= cost_threshold);
if (result.cost == cost_threshold) {
result.cost = std::numeric_limits<Gain>::max();
}
Expand Down
1 change: 1 addition & 0 deletions src/problems/cvrp/operators/pd_shift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ PDShift::PDShift(const Input& input,
assert(s_route.size() >= 2);
assert(s_p_rank < s_d_rank);
assert(s_d_rank < s_route.size());
assert(s_route.route[s_p_rank] + 1 == s_route.route[s_d_rank]);

stored_gain = gain_threshold;
}
Expand Down
25 changes: 8 additions & 17 deletions src/problems/vrptw/operators/pd_shift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ PDShift::PDShift(const Input& input,
static_cast<RawRoute&>(tw_t_route),
t_vehicle,
gain_threshold),
_is_valid_removal(true),
_source_without_pd(s_route.begin() + _s_p_rank + 1,
s_route.begin() + _s_d_rank),
_tw_s_route(tw_s_route),
Expand All @@ -42,19 +41,13 @@ PDShift::PDShift(const Input& input,

void PDShift::compute_gain() {
// Check for valid removal wrt TW constraints.
if (_s_d_rank == _s_p_rank + 1) {
_is_valid_removal =
_is_valid_removal && _tw_s_route.is_valid_removal(_input, _s_p_rank, 2);
} else {
_is_valid_removal =
_is_valid_removal &&
_tw_s_route.is_valid_addition_for_tw(_input,
_source_without_pd.begin(),
_source_without_pd.end(),
_s_p_rank,
_s_d_rank + 1);
}
if (!_is_valid_removal) {
bool is_valid_removal =
_tw_s_route.is_valid_addition_for_tw(_input,
_source_without_pd.begin(),
_source_without_pd.end(),
_s_p_rank,
_s_d_rank + 1);
if (!is_valid_removal) {
return;
}

Expand All @@ -64,12 +57,10 @@ void PDShift::compute_gain() {
t_vehicle,
_tw_t_route,
_remove_gain - stored_gain);
assert(s_route[_s_p_rank] + 1 == s_route[_s_d_rank]);

if (rs.cost < std::numeric_limits<Gain>::max()) {
assert(_remove_gain + -rs.cost > stored_gain);
_valid = true;
stored_gain = _remove_gain + -rs.cost;
stored_gain = _remove_gain - rs.cost;
_best_t_p_rank = rs.pickup_rank;
_best_t_d_rank = rs.delivery_rank;
}
Expand Down
1 change: 0 additions & 1 deletion src/problems/vrptw/operators/pd_shift.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace vrptw {

class PDShift : public cvrp::PDShift {
private:
bool _is_valid_removal;
std::vector<Index> _source_without_pd;
TWRoute& _tw_s_route;
TWRoute& _tw_t_route;
Expand Down

0 comments on commit e42c3b3

Please sign in to comment.