I am interested in implementing Hours of Service Regulations, which limit the hours a driver can operate a truck as constraints in my optimization:
https://www.fmcsa.dot.gov/regulations/hours-service/summary-hours-service-regulations
I do not think this is covered in the examples, but it seems like a problem many people will have with vehicle routing. Has anyone implemented this or does anyone have ideas how one would go about it?
Thanks.
Hi Ben, these are typically called time windows. We've got an example here:
https://developers.google.com/optimization/routing/tsp/vehicle_routing_time_windows
If there's anything we can do to make the documentation clearer, let us
know!
Jon
On Tue, Oct 10, 2017 at 4:43 PM, Ben Dichter notifications@github.com
wrote:
I am interested in implementing Hours of Service Regulations, which limit
the hours a driver can operate a truck as constraints in my optimization:https://www.fmcsa.dot.gov/regulations/hours-service/summary-hours-service-
regulationsI do not think this is covered in the examples, but it seems like a
problem many people will have with vehicle routing. Has anyone implemented
this or does anyone have ideas how one would go about it?Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/500, or mute the thread
https://github.com/notifications/unsubscribe-auth/AIoiWx5foW3Qqbh8gZCrcf5u8IKNq6MJks5sq9b0gaJpZM4P0i_5
.
Hi Jon,
Thanks for the help. I think these time windows are referring to constraints on shipments i.e. when they need to be delivered.
The constraints I am looking for are on the vehicles. I want to say something like "this vehicle must take a break after driving 11 hours". I think I found a lead here, however there are two issues I still can't figure out. The first is how I set up the proper relation between constraints. This example enforces that two breaks are at least 1 hour apart with operations_research::Solver::STARTS_AFTER_END, but I want one that is at most 11 hours apart. I think MakeIntervalVarRelationWithDelay(...,operations_research::Solver::STARTS_BEFORE,...) may suit my needs for this. The second issue is that I am using python, and I am not sure how to port this over. How would I establish these constraints in python? How do I call STARTS_BEFORE?
Thanks!
Ben
I figured it out. In python it's a method of InvervalVar
I figured it out. In python it's a method of InvervalVar
Would you please tell how did you implement it? I am not finding a method named InvervalVar under ortools.constraint_solver import pywrapcp or in pywrapcp.RoutingModel and I am not sure how I can add that as a constraint. Thank you.
It is a method of pywrapcp.Solver
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le mar. 5 févr. 2019 à 13:39, Abhi001vj notifications@github.com a écrit :
Would you please tell how did you implement it? I am not finding a method
named InvervalVar under ortools.constraint_solver import pywrapcp or in
pywrapcp.RoutingModel and I am not sure how I can add that as a constraint.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/500#issuecomment-460623325,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKj17T5iE1qk5bW-7INIZNTuSsZtvQHXks5vKXuCgaJpZM4P0i_5
.
Thank you. But is the maximum time per vehicle in add dimension doing some thing similar by restricting the working hours, we just want to make sure the trucks are operating in working hours.
Can I iterate over vehicles and a constraint so that the delivery items possible in that range will be considered and the others will be dropped.
Can I use it like this example code by using pywrapcp.Solver.IntervalVar() instead of routing.CumulVar and applying that as the costraint.
for i in range(num_vehicles):
# Add time windows at start of routes
intervals.append((routing.CumulVar(routing.Start(i), time),
vehicle_load_time,
"depot_interval"))
# Add time windows at end of routes.
intervals.append(solver.FixedDurationIntervalVar(routing.CumulVar(routing.End(i), time),
vehicle_unload_time,
"depot_interval"))
# Constrain the number of maximum simultaneous intervals at depot.
depot_capacity = 2;
depot_usage = [1 for i in range(num_vehicles * 2)]
solver.AddConstraint(
solver.Cumulative(intervals, depot_usage, depot_capacity, "depot"))