Or-tools: Wait time

Created on 24 Jul 2018  路  8Comments  路  Source: google/or-tools

Hello,
Probably addresses in the past, but I couldn't find this.
How can I assign a wait duration for each Node, so solver considers waiting/service/visit time at each Node? (not just the travel time)

Maybe adding that time to the "Time" Dimension from each Node to the target Node?
Maybe duplicate all the Nodes (with 0 cost to travel to the duplicated node) to emulate such wait times?
Other?
Thx

Help Needed Routing Solver

Most helpful comment

Simply put. We use Time Windows on Arrival time thus time dimension add constraints on node arrival.
We compute the transit cost as the sum of the travel time and the service time.

Computing Departure time is more tricky since it will also depends on waiting time aka SlackVar.
ArrivalTime(B) = ArrivalTime(A) + Transit(A, B) + WaitingTime(A) and
Tansit(A, B) == ServiceTime(A) + TravelTime(A,B) == TotalTime(A,B)
so you may define DepartureTime as
DepartureTime(A) = ArrivalTime(A) + ServiceTime(A) + WaitingTime(A)

note: ArrivalTime is the CumulVar() from the solver point of view
note: WaitTime is the SlackVar() from the solver point of view
note: CumulVar and SlackVar may be range interval
note: SlackVar range is dependent of the CumulVar value but what we return can be see as the union of all range of SlackVar for all value of CumulVar.

All 8 comments

Hi, simply add 'service time" to the transit callback
cf the python example cvrptw.py
Here I define a service time according to the capacity of each node:
src: https://github.com/google/or-tools/blob/master/examples/python/cvrptw.py#L182
and then I add it to the transit function
src: https://github.com/google/or-tools/blob/master/examples/python/cvrptw.py#L208

note: I add the service to the output edge i.e. Transit(A -> B): ServiceTime(A) + TravelTime(A -> B) so my Time Windows define an "arrival time constraint at node N".

So, we get the departure time by adding the "service time" at that Node to the arrival time?

And the arrival time at the next Node will automatically include it - since you used:
_total_time[from_node][to_node] = int( service_time(data, **from_node**) + travel_time(data, from_node, to_node))

right?

Simply put. We use Time Windows on Arrival time thus time dimension add constraints on node arrival.
We compute the transit cost as the sum of the travel time and the service time.

Computing Departure time is more tricky since it will also depends on waiting time aka SlackVar.
ArrivalTime(B) = ArrivalTime(A) + Transit(A, B) + WaitingTime(A) and
Tansit(A, B) == ServiceTime(A) + TravelTime(A,B) == TotalTime(A,B)
so you may define DepartureTime as
DepartureTime(A) = ArrivalTime(A) + ServiceTime(A) + WaitingTime(A)

note: ArrivalTime is the CumulVar() from the solver point of view
note: WaitTime is the SlackVar() from the solver point of view
note: CumulVar and SlackVar may be range interval
note: SlackVar range is dependent of the CumulVar value but what we return can be see as the union of all range of SlackVar for all value of CumulVar.

Thx.
Isn't SlackVar really the maximum wait time allowed at a certain Node, that would still enable to meet the Arrival time constraints of all the following Nodes?

Also, when Solver() runs -- searching through a certain Vehicle/Route -- is it possible to get the service order of a certain Node?
That is: Query the Solver() using the NodeIndex of the last Node in the search, and get its relative order, in the sequence of preceding Nodes, served before it along that route?
(of course, as the search progresses the order of the Nodes increases)

Can you please comment re the second question? (hoping the question was clear ...)

I'd hate to revive a 'dead' issue, but the issue here is also one I face, and the links above appear to be broken.

@willwill2will54 Did you get all the answers you were looking for ?

Was this page helpful?
0 / 5 - 0 ratings