Search code examples
jsprit

How to use jsprit with time windows?


i don t understand how to use time windows in jsprit.

I know it s a value that u give to vehicle with the method like :

setLatestArrival(1236);

and for services like :

setTimeWindow(TimeWindow.newInstance(912,967));

but how to convert hours to this values? how can i write a time windows for 2 services :

1- begin at 10h and finish at 12h

2- begin at 16 and finish at 15h

Thx for help.


Solution

  • Jsprit takes time unit as seconds. If you want to use hours you need to convert the time in seconds first. One thing I want to clarify here,

    setTimeWindow(TimeWindow.newInstance(912,967));

    Here 912 and 967 is not the start time and end time of task. Here 912 is the earliest start time which means you can not start this service before 912. And 967 is latest end time which means you have to end this service before 967. Service might have some duration which you can mention in

    setServiceTime(time in seconds)