Skip to content

Question regarding pd_shift #462

@krypt-n

Description

@krypt-n

Hi, this is not a real issue, just a thing I noticed in the code.

I'm currently looking into the running time of instances that use PDShift and compute_best_insertion_pd heavily.
Both contain an algorithm to find a cheap insertion of a shipment into a route. I merged the two algorithms but noticed that this changes the resulting routes.
After some debugging I noticed that the only relevant difference between the algorithm in pd_shift.cpp and the one in local_search.cpp is the range of the possible pickup locations. My question thus is:

Is it intended that PDShift does not consider the end of a route for the pickup? Or am I missing something?

This change is not a clear improvement in solution quality in the benchmarks I checked, some solutions improve, some get worse. This is why I am hesitant to apply this change.

diff --git a/src/problems/vrptw/operators/pd_shift.cpp b/src/problems/vrptw/operators/pd_shift.cpp
index 39f2a7b..0dcefd2 100644
--- a/src/problems/vrptw/operators/pd_shift.cpp
+++ b/src/problems/vrptw/operators/pd_shift.cpp
@@ -80,7 +80,7 @@ void PDShift::compute_gain() {
       target.is_valid_addition_for_tw(_input, s_route[_s_d_rank], t_d_rank);
   }

-  for (unsigned t_p_rank = 0; t_p_rank < t_route.size(); ++t_p_rank) {
+  for (unsigned t_p_rank = 0; t_p_rank <= t_route.size(); ++t_p_rank) {
     Gain t_p_gain = -utils::addition_cost(_input,
                                           m,
                                           s_route[_s_p_rank],

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions