Time Windows not respected on Service

Hi everyone, I’ve got a problem when using TimeWindows on a Service.

I’m using the Service.addTimeWindow(double earliest, double latest) method to configure a TimeWindow on a service, providing time information in second unit.

I’ve also got Vehicles with earliest departure and latest arrival (always in seconds).

If I do put a TimeWindow that cannot be satisfied considering Vehicle working hours, that is skipped as expected and categorized as unassigned job.

Eg: Service has TW between 8am and 9am, Vehicles starts at 10am -> TW = ignored (correct)

If the TimeWindow in instead inside the Vehicle working hours, the result I get is random, sometimes it is respected, some others not, some others it shifts all the other Services of that day just after the TimeWindow.latest property.

Eg: Service has TW between 8am and 9am, Vehicles starts at 7am -> TW = random behavior

Why this happens?
Do I need to set some other specific property?


Hi @LucioB,

In Jsprit, a time window on an activity imposes the constraint that the start time of the activity cannot be outside the time window. Note the difference between start time and arrival time.

For example, if a Service has a time window 8am - 9am, this means the start time of the Service activity must be between 8am and 9am. The arrival time could be before 8am, then the vehicle will wait at the location and start the Service activity at 8am; the arrival time could be between 8am and 9am, then the Service activity could start immediately after arrival; and the arrival time cannot be after 9am.

Hopefully the above clarifies.

Best regards,

1 Like

So the TimeWindows are only related to the start time of a Service?
How can I specify more complex TimeWindows like Service start and end both inside an interval?

Edit (reduce) the end of the time window, specified in jsprit, so that the latest it could possibly start would accommodate the full service duration before the actual, real-life, end of the window.

I other words, if the job must be completed between 8am and 9am, and takes 15 mins to complete, then you specify that it must be done between 8am and 8:45.

1 Like

This seems to be reasonable.
Thank you