Or-tools: Vehicle start time/end time

Created on 10 Sep 2018  路  3Comments  路  Source: google/or-tools

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!

Help Needed Python

Most helpful comment

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

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KeremAslan picture KeremAslan  路  3Comments

nosrettep picture nosrettep  路  5Comments

husamrahmanh2o picture husamrahmanh2o  路  4Comments

uioplmn picture uioplmn  路  5Comments

TeodoraB21 picture TeodoraB21  路  3Comments