3

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.

splifo
  • 45
  • 5

1 Answers1

2

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)

sutirtha
  • 375
  • 3
  • 21
  • 2
    A couple of clarifications on this. Jsprit is actually _time unit agnostic_, you define your preferred unit of measurement (I use minutes) and ensure you are consistent throughout. Also, you're not technically correct with `latest end time` although this is perhaps because the setup of that attribute is not overly clear. It's actually the `latest start time` and a job can end after `967`. See [this](https://github.com/graphhopper/jsprit/issues/233) suggested feature for an alternative time window implementation. – roganjosh Jun 16 '16 at 14:52
  • @sutirtha Whether these numbers we are giving in the time windows (TimeWindow.newInstance(912,967)) are only wrt a daytime, means this day this service have to be started at 10 am and ends at 1 pm or what are those numbers representing? 912 and 967 don't make sense. – Manjunath M Apr 11 '17 at 05:37
  • 1
    @ManjunathM as roganjosh explained jsprit is time unit agnostic. You can define youe preferred time unit. Suppose you are declaring a problem based on epoch time stamp it will be like : setTimeWindow(TimeWindow.newInstance(timestamp1, timestamp2)); Again you can take time usin as min, then it will be like: setTimeWindow(TimeWindow.newInstance(min1, min2)); And these times are wrt the problem (You can say start time of the day). Which is again depends on you. You can take the start time as the start of the vehicle. In that case vehicle time window will be (0, end time of the vehicle work) – sutirtha Apr 11 '17 at 09:36
  • @sutirtha Thanks that's helpful. – Manjunath M Apr 11 '17 at 10:59
  • @sutirtha Suppose if my early start and end date of the vehicle is based on the day means every day he works 10AM-8PM. What if services those he has to finish actually takes more than a day let Job requires 12Hrs.Then since I have mentioned my vehicle time specific to a day (8Hrs a day) and the job requires more than a day to complete.It will not give any routes.So how to mention time in such type of situation? – Manjunath M Apr 11 '17 at 11:15
  • You cant. Its not making sense to me to use a vehicle for a job where job requires more time than the vehicle service time. – sutirtha Apr 11 '17 at 11:29