Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle start time/end time #846

Closed
karomad opened this issue Sep 10, 2018 · 3 comments
Closed

Vehicle start time/end time #846

karomad opened this issue Sep 10, 2018 · 3 comments
Assignees
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue
Projects
Milestone

Comments

@karomad
Copy link

karomad commented Sep 10, 2018

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!

@Mizux Mizux added the Help Needed Modeling/Usage problem label Sep 12, 2018
@270ajay
Copy link
Contributor

270ajay commented Sep 13, 2018

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

@Mizux Mizux added the Lang: Python Python wrapper issue label Sep 13, 2018
@karomad
Copy link
Author

karomad commented Sep 13, 2018

Thank you 270ajay! It really helped me

@Mizux Mizux added this to ToDo in Kanban v6.9 via automation Sep 13, 2018
@Mizux Mizux added this to the v6.9 milestone Sep 13, 2018
@Mizux Mizux closed this as completed Sep 13, 2018
Kanban v6.9 automation moved this from ToDo to Done Sep 13, 2018
@nepsi
Copy link

nepsi commented Mar 29, 2019

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.

@Mizux Mizux self-assigned this Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue
Projects
No open projects
Kanban v6.9
  
Done
Development

No branches or pull requests

4 participants