Adding service time at node to VRPTW

2,381 views
Skip to first unread message

Jordan Christensen

unread,
Apr 10, 2019, 2:00:42 PM4/10/19
to or-tools-discuss

Are there any examples or ideas of adding required time at each node to the VRPTW? 


Vincent Furnon

unread,
Apr 11, 2019, 10:01:28 AM4/11/19
to or-tools...@googlegroups.com
By required time, if you mean service or stop time then you can have a look at https://github.com/google/or-tools/blob/stable/ortools/constraint_solver/samples/cvrptw.py#L162

On Wed, Apr 10, 2019 at 8:00 PM Jordan Christensen <jordanchr...@gmail.com> wrote:

Are there any examples or ideas of adding required time at each node to the VRPTW? 


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordan Christensen

unread,
Apr 11, 2019, 3:23:38 PM4/11/19
to or-tools-discuss
Thanks! 

blind.line

unread,
Apr 11, 2019, 8:32:39 PM4/11/19
to or-tools...@googlegroups.com
You can also play funky games with service time, etc because the callback gets origin and destination. So for example, if service time includes a driver parking and opening up the van, but you have two virtual nodes at the same physical place (modeling the delivery of multiple items at one place) then you don’t want to charge that cost twice. By looking at the from and to nodes, your code can decide whether to incur this cost or not. 

So you can code up the cost of arriving at a destination (by checking that from and to nodes are really different places) plus the cost of loading or unloading at the node. Because it is all precomputed into a lookup table prior to running the solver, the added logic is free (lookup is still O(1)). 

James

On Apr 11, 2019, at 12:23, Jordan Christensen <jordanchr...@gmail.com> wrote:

Thanks! 
Message has been deleted

Kazi Ahsan

unread,
Jul 5, 2021, 2:58:39 AM7/5/21
to or-tools-discuss
We did the similar but then it reaches earlier than pickup time. So if pickup time is 7 am and location service time is 15 minutes. It reaches there at 6.45 am instead of 7 am.

Any help will be much appreciated. Many thanks.

blind.line

unread,
Jul 10, 2021, 1:17:21 AM7/10/21
to or-tools...@googlegroups.com
This link in the docs might help:


Specifically, you should study and understand the part:

“Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). “

So you have to be careful which node you use for service time when calling that fn. 

I always think like this: the cumul(i) is the state when the vehicle arrives at i. The service time at i is added after it arrives, and then the travel time to j is added, plus slack needed, then you get cumul(j). 

It sounds to me like you’re using the wrong node when calling for service time. I’m on my phone so this is likely to be unreadable, but…

def tottime(i, j):
  return traveltime(i, j) + servicetime(j)

(But hard to give good advice without seeing code.) 

James

On Jul 4, 2021, at 23:58, Kazi Ahsan <ktanvi...@gmail.com> wrote:

We did the similar but then it reaches earlier than pickup time. So if pickup time is 7 am and location service time is 15 minutes. It reaches there at 6.45 am instead of 7 am.
Reply all
Reply to author
Forward
0 new messages