Prioritizing high-cost deliveries with time windows and custom constraints #4744
Unanswered
Domeless
asked this question in
Routing (and legacy CP) questions
Replies: 1 comment
-
Why not set the cost as the penalty for dropping a node instead of setting it to 0 for all nodes? Though you might need to multiply the cost by a coefficient if you want it to be the predominant factor in the objective function. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm working on a delivery routing problem that includes time windows and an additional constraint on the number of deliveries per driver, which depends on the route distance.
I wanted to introduce prioritization for deliveries, such that if there are multiple possible options, the solver prefers the ones with higher "cost" (priority).
To implement this, I added a custom dimension "Cost" that accumulates the delivery priority. Then, for each route end, I used:
cost_dimension.SetCumulVarSoftLowerBound(end, 300, 500)
to encourage the solver to select deliveries with a higher total cost per vehicle.
In this case, 300 is the total cost sum of all available deliveries, so this constraint essentially encourages the solver to keep as many high-cost deliveries as possible.
In my test, I have:
The only difference between the 4 deliveries is their cost value.
I expected the solver to exclude the lowest-cost delivery from the route. However, what I observe is that the last delivery in the list is always excluded — regardless of its cost. It seems the cost is not being taken into account during tie-breaking or final assignment.
How can I make sure that, when multiple delivery combinations are possible, the solver selects the set with the highest total cost, while still respecting the time windows and delivery limits per route?
Is there a better way to force the solver to optimize for delivery cost in this situation?
Any suggestions or patterns would be greatly appreciated!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions