adding constraints to disjunctions forces the solver to always pick the constrained route even if suboptimal #4316
Unanswered
tueboesen
asked this question in
Routing (and legacy CP) questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The fundamental problem I'm trying to solve is that I want to insert the option of adding a transit hub to a pickup/delivery, meaning that the solver should have the option of either doing a pickup/delivery a->b, or a pickup delivery a->c followed by another pickup delivery c->b (not necessarily with the same vehicle).
The way I am thinking of solving this problem is by making all of these options different nodes (at least for now). Thus my problem is that I have the following pickup/deliveries 0->1,2->3,4->5 (where 0->1 is the direct pickup/delivery, 2->3,4->5 represent an intermediate drop-off at a transit hub.)
To force the solver to pick one of these two options I use the following disjunctions:
Next I create the pickup/deliveries:
All of this works fine and does what I expect as far as I can see.
But next I need to add the constraint that (2->3) is done before (4->5) is started. Initially I figured I could just do
routing.AddPickupAndDelivery(manager.NodeToIndex(3), manager.NodeToIndex(4))
, but that didn't seem to work, and also it wasn't entirely clear to me that it should, since a normal pickup/delivery assumes a single vehicle is used, and also because both of these were already part of another pickup/delivery.So instead I decided to create a time dimension and then enforce the constraint that way:
So this adds the constraint, but unfortunately it seems that by adding this constraint the solver is now no longer free to pick between the two different disjunction routes and is instead forced to pick the transit stop, even when this is sub-optimal.
I tried to use
routing.ActiveVar(pickup_index)
in the constraint as suggested in other similar problems, but it seems to have no effect in this case.I believe the likely reason that this constraint is still affecting the solver and forcing it to choose this route is because it is still forcing some internal calculation of
time_dimension.CumulVar(pickup_index)
which might not be well defined if pickup_index is dropped?I have attached the full code for running this example.
For transparency I should mention that I have already posted about this issue here:
https://groups.google.com/g/or-tools-discuss/c/1q7BRIvayDs
and I also talked about it here:
#4284
Beta Was this translation helpful? Give feedback.
All reactions