Multiday single long distance deliveries without reload

I am analyzing JSPRIT functionalities with time window for a specific problem of a single trip but due to a large distances to deliver all packages from a factory it takes w few days for a truck. Two drivers exchanging when driving plus hotels needs to be taken. This is because there are large distances between delivery points. Every stop is opened from 8:00 till 16:00 (timewindow) so there are hard time windows. During the first day the truck delivers some packages up to 16:00 and no more deliveries the same day allowed. Then driver should go into another delivery point which is going to be open again the following day from 8:00 till 16:00, sleep somewhere in between or at another (next day delivery location) and procedure continues till all packages are being delivered and track can go back to its depot. Is it possible to implement such scenario within JSPRIT ?

You asked this on SO recently and I gave an answer but actually I seem to have misunderstood the issue here. @stefan how many time windows can be reasonably accommodated for a single job?

1 Like

Thank you for replaying to my question. I will replay here rather then in stack overflow. Not sure I properly understand your suggestion.
The problem of a real business scenario which I am trying to implement in jsprit is that trucks a packed with a multiple loads. These loads are to be delivered over large distances (few countries). The truck start in a factory and goes from point to point until all are delivered. The problem that businesses who are delivery destinations operates only during business hours 8am-4pm. So truck crew once delivered part of load during Monday and its around 4pm have a break till following day opening hours. Trucks should actually utilise the time (evening and night) to get close to the next delivery point and then take a break (sleep).
Therefore imposing 7:30am-4 pm constraints for a truck operating hours would probably not allow for driving between delivery points at night or evening. Any thoughts?

@roganjosh an arbitrary number of tws can be assigned - I would assume

Deleted last answer, I led myself down a rabbit hole trying to reason it out.

This shouldn’t be too difficult then. Provided that you can have an arbitrary number of time windows for each job, this should be relatively simple (I don’t know how 5 or 7 time windows will affect the number of iterations for convergence…):

  1. Define a time unit that spans the whole week e.g. in minutes you go from 1 on Sunday 00:01 to 10079 at 23:39 on Sat.
  2. Define each job once with multiple time windows that correspond to each 8am to 4pm on each day of the week.
  3. Run as normal.

Vehicles cannot do jobs that don’t have an open time window (time windows are considered hard constraints). You set it so that each vehicle runs for the whole week, no breaks. Once the 4pm time window closes, the algorithm will assume that the vehicle moves to its next job in the optimal route and just sits there until 8am when the new time window opens (provided that travel time is less than 16 hours; it will account for this). What your driver actually does in this period is an operational decision; (s)he might drive half way and then stop over, it doesn’t matter. Provided that they arrive at 8am for the next customer in the route, it’s valid.

1 Like

Thank you roganjosh, this solves the problem :slight_smile:

1 Like

This case works. However, it does not cover the entire journey time. This does not take into account the driver’s stops for lunch, dinner and overnight

This hits my eyes so hard. I just stuck on this problem at these days. The solutions proposed by community definitely does not cover multiday trip of one shipment. The problem as @eltonramos correctly mentioned is that there are two kinds of timewindows. First is timewindows for shipment itself. Means the shipment can be delivered each day in week in specific timewindows. But there is another limitation, work hours of vehicle. Which is defined by earliestStart and latestEnd. BUT this does not cover multiday trip. I want to define vehicle start and end time for each day, not only first day and last.

First I look on shifts planning which was introduced some year earlier. That does not cover this scenario. Whole solution is at splitting one wehicle into multiple.

The solution proposed by @roganjosh does not cover this either. Because time will end up like waiting time, but vehicle can start at particular time, earliestStart, so transport must start after. So all these times (transport, waiting, break) are mixed together. This in same cases can be OK, but each of these times has different price for time unit, so it pretty much affects a solution.

I end up with one possible way to do this. To have multiple breaks. For each earliestStart and latestEnd timewindow I just fill a time gap with break. Of cource jsprit does not support multiple breaks, even when community is desperate to have it. It seems like jsprit is a little bit of track in these days. No one is taking care of pull request. So I just fork jsprit and implement multibreaks feature. Everything is prepared in core library, if you look into BreakScheduler, there is no problem to let algorithm insert more then one break. In ruin phase just erase all breaks. Easy as that. Of course I must made some other changes in code to adapt behaviour to multiple breaks. But it inserts multiple breaks in long time journey, so look like it works, somehow. After two weeks of analysing a migrating project (because I’m so bad with Java, but equally desperate) I will test this with production data and validate result. So if my work will be failure I’ll let you know.

Well, multiple breaks doesn’t work either. Beacause break is optional job, so if JSprit doesn’t have space to server break, it just penalize solution. But I need hard boundaries for wehicle, thus I must teach vehicle to have time windows. Now I can simulate working hours for multiple day span. Works well, change wasn’t that hard.