'VRP OR-Tools: Including additional cost in the objective depending on the destination
I am solving a VRP problem where the items are picked up from multiple pickup locations and delivered at multiple drop locations (Note: the delivery locations are not pre-fixed for items). Apart from the ArcCost, I have to include an additional cost for each pickup item depending on their delivery location.
For example, consider a scenario consisting of four locations - {a,b,c,d}, where a and b are pickup locations and c and d are delivery locations. Assume the ArcCost between these nodes are,
- D(a,b) = D(b,a) = 3,
- D(a,c) = 5,
- D(a,d) = 8,
- D(b,c) = 4,
- D(b,d) = 7
For the above values, the optimal route (for minimization of total arccost) is a->b->c with the route cost as 7 (3 + 4). However, this changes when I include an additional cost for each item depending on where it is dropped. Assume that in the above example,
- if item from a is dropped in c, the additional cost is 10
- if item from b is dropped in c, the additional cost is 5
- if item from a is dropped in d, the additional cost is 3
- if item from b is dropped in d, the additional cost is 11
Considering these additional costs the route a->b->c is no longer optimal (the total cost of this route is 3 + 4 + 10 + 5 = 22). The optimal route considering this additional cost is: a->d, b->c (the total cost of this route is 8 + 3 + 4 + 5 = 20).
In the VRP tool, I modeled this additional cost using AddSoftSameVehicleConstraint() function between each pickup and drop point with penalty as negative "additional cost". For the above example, I added the following four soft constraints to the model:
- AddSoftSameVehicleConstraint(a, c, -10),
- AddSoftSameVehicleConstraint(b, c, -5),
- AddSoftSameVehicleConstraint(a, d, -3),
- AddSoftSameVehicleConstraint(b, d, -11)
I also included a dummy final depot with 15 (10 + 5) as the cost to travel from c to the dummy depot and 14 (11 + 3) as the cost to travel from d to the dummy depot. Now, consider the route a->c, b->d. The cost from a->c would be 5 (arccost from a to c) + 15 (cost to travel to the dummy final depot) -5 (penalty since b and c are not included in the same vehicle) = 15 (this is same as the cost that I want 5 (arccost) + 10 (additional cost of dropping a in c)). Similarly, the cost from b->d would be 7 + 14 -3 = 18.
Through this I am able to model the additional cost perfectly. However, the VRP tool does not optimize this soft constraint always. The tools Sometimes optimizes the soft constraint violation cost and sometimes it does not. (Similar to the issue mentioned here). I tried different combinations of first solution strategy and local search strategies but none of them worked the way I wanted.
Is there any better way to model this additional cost such that the tool considers this cost during the optimization?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
