Hi guys,
I am using Capacitated Vehicle Routing Problem with Time Windows model. In our case drivers (vehicles) are working with shifts, so I need to set vehicle availability time. Is there a way to do this?
Thanks!
minStartTime = 123
maxStartTime = 244
You can store these minStartTime and maxStartTime in a list for different vehicles
for vehicle_id in range(numOfVehicles):
index = routing.Start(vehicle_id)
timeDimension.CumulVar(index).SetRange(minStartTime, maxStartTime])
routing.AddToAssignment(timeDimension.SlackVar(index))
For end time, you can add a dimension:
maxTime = 600 # minutes
routing.AddDimension(timeEvaluator, 0, maxTime, True, "MAXTIME")
see: https://developers.google.com/optimization/routing/cvrptw#time_window_constraints
Thank you 270ajay! It really helped me
Hi,
I set the vehicle end time using Set Range method-
long index = routing.End(vehicle_id);
time_dimension.CumulVar(index).SetRange(start, end);
But it was taking approximately 2 hr to give the results.Then I followed the above approach using dimension to set the vehicle end time -
routing.AddDimension(timeEvaluator, 0, maxTime, True, "MAXTIME")
and performance improved a lot .From 2 hr, it give me results in 15 min.
I just want to know the difference between the two .Why there is such huge difference in both approaches.
Thanks.
Most helpful comment
You can store these
minStartTimeandmaxStartTimein a list for different vehiclesFor end time, you can add a dimension:
see: https://developers.google.com/optimization/routing/cvrptw#time_window_constraints