Soft upper bound on time for CVRPTW

219 views
Skip to first unread message

Borja Menéndez Moreno

unread,
Jun 23, 2021, 10:15:48 AM6/23/21
to or-tools-discuss
Hi folks,

I'm working on a CVRPTW in which I would like to set a soft upper bound on time. I've successfully tested the soft upper bound on a duration dimension that only takes into account the time between nodes, and then adding something like:

duration_dimension.SetCumulVarSoftUpperBound(routing.End(vehicle_id), 180, 10)

Meaning that the model would add a penalty of 10 after 180 minutes of route for each vehicle. But now I would like to change that so the soft upper bound applies to the last node of the route different from the depot, since the important part of the route is from the depot to the last visited node, but the route from that node to the depot is not important at all. How would I change that upper bound to consider that? I don't think so, but is it as simple as setting routing.End(vehicle_id)-1?

Thank you very much in advance,

Borja.

Mizux Seiha

unread,
Jun 24, 2021, 9:53:03 AM6/24/21
to or-tools-discuss
1. duration_dimension.SetCumulVarSoftUpperBound(routing.End(vehicle_id), 180, 10) means you'll have a penalty of 10 PER UNIT above the upper bound 180
e.g. if  route end with a CumulVar of 193 penalty cost will be (193 -180) * 10 = 13 * 10 = 130

2. no it's not so easy to get it, BUT if you don't care of the distance/time last visit -> depot, simply return 0 in your transit callback for any transit "i -> depot" thus SoftCumulVar on End is the same than applying it on the last node...

Borja Menéndez Moreno

unread,
Jun 28, 2021, 5:45:17 AM6/28/21
to or-tools-discuss
Hi Mizux,

Thanks for the answers. Returning 0 from last node to depot is a good solution in this case I think because on the one hand I need to minimize total distance, which is a different dimension, and on the other hand I need to set an upper bound for the driving time for each route except for the last node to depot, which is something solvable with your answer.

In the case I need to care about the time for last node to depot, another simply solution could be to have two different matrices, one considering that move and another one not considering it, and then creating two different dimensions for both purposes?

Thanks a lot,

Borja.

Reply all
Reply to author
Forward
0 new messages