I have a routing problem with one vehicle and a number of waypoints (pickups and deliveries).
I can successfully add a time window for each waypoint with:
dimension.CumulVar(index).SetRange(start_window, end_window)
But I also want to force the vehicle to wait at each wait point to mimic the loading or unloading time. I try to do so with:
dimension.SlackVar(index).SetValue(loading_time)
The solution window I get with only using the CumulVar
looks like:
waypoint 1: (10:17, 11:19)
waypoint 2: (11:25, 11:38)
waypoint 3: (11:45, 11:46)
waypoint 4: (11:45, 11:46)
waypoint 5: (11:45, 11:46)
waypoint 6: (11:53, 11:54)
waypoint 7: (12:00, 12:00)
Once adding the SlackVar
, it looks like:
waypoint 1: (11:14, 11:14)
waypoint 2: (11:27, 11:27)
waypoint 3: (11:40, 11:40)
waypoint 4: (11:45, 11:45)
waypoint 5: (11:50, 11:50)
waypoint 6: (12:09, 12:09)
waypoint 7: (12:21, 12:21)
Why is the solution windows has no flexibility anymore? Why waypoint 1 can be done within almost an hour but then loose all flexibility once using the SlackVar? What are my misunderstandings? Where are my mistakes?
the formula is cumulvar(next(i)) == cumulvar(i) + transition(i, next(i)) + slack(i)
If you fix all slacks, you remove all flexibility. Instead of fixing them, just add a lower bound.
dimension.SlackVar(index).SetMin(loading_time)