Closed GuyBenhaim closed 5 years ago
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 ?
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)
andTansit(A, B) == ServiceTime(A) + TravelTime(A,B) == TotalTime(A,B)
so you may define DepartureTime asDepartureTime(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.
hello Mizux, I have a problem, as you say, we define a waiting time for each node, but I want to define the sum of vehicle waiting time, how to solve this kind of problem?
Please do not revive issues that are years old :-) Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00
Le lun. 19 sept. 2022 à 12:07, wagjixiang @.***> a écrit :
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.
hello Mizux, I have a problem, as you say, we define a waiting time for each node, but I want to define the sum of vehicle waiting time, how to solve this kind of problem?
— Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/765#issuecomment-1250820930, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3PLGBN3BSC4KTZZEULV7A3OBANCNFSM4FLRFTIQ . You are receiving this because you modified the open/close state.Message ID: @.***>
Please do not revive issues that are years old :-) Laurent Perron | Operations Research | @. | (33) 1 42 68 53 00 Le lun. 19 sept. 2022 à 12:07, wagjixiang @.> a écrit : … 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. hello Mizux, I have a problem, as you say, we define a waiting time for each node, but I want to define the sum of vehicle waiting time, how to solve this kind of problem? — Reply to this email directly, view it on GitHub <#765 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3PLGBN3BSC4KTZZEULV7A3OBANCNFSM4FLRFTIQ . You are receiving this because you modified the open/close state.Message ID: @.***>
I'm sorry to take up your time! It may be simple for you, but i can't solve it by myself. So can you tell me how to solve this problem?
problem: limit the sum of vehicle waiting time.
Thank you very much again!
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