Implementing a constraint on when a vehicle has to return to a depot with a delivery #2418
Replies: 1 comment
-
|
idx = routing.End(vehicle_id)
same_vehicle = routing.VehicleVar(index) == routing.VehicleVar(location_idx)
routing.solver().Add(same_vehicle * time_dimension.CumulVar(idx) <= delivery_window)If the constraint If the constraint |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What language and solver does this apply to?
Routing
Describe the problem you are trying to solve.
I working on a vehicle routing problem and am trying to implement a constraint that forces a vehicle to return to the depot by the delivery time requirements for the nodes visited.
Below is what I am currently trying to use to implement this constraint. The code not included is framed from the example problems in the documentation. I'd be happy to elaborate more if needed/show other parts of the code.
The solver doesn't seem to be a fan of how I am trying to implement the constraint. Currently, it is not returning a solution despite the model having solutions before this constraint. Based on the data I am testing it on, it should be possible provided the constraint is implemented properly.
To summarize, I am asking for help in understanding how to go about writing a constraint that requires a vehicle returns to the depot before the delivery deadlines of the orders it has picked up. I was wondering if there is a functionality that already handles this that I have missed, or if some functionality could be created to achieve this.
Any help would be greatly appreciated! I've tried a few different things but I am reaching my wit's end.
Beta Was this translation helpful? Give feedback.
All reactions