Time_windows for start and end depot

I have an optimization request with x amount of stops, and 1 vehicle. Most of the times the ‘end_address’ is the depot, but sometimes it’s an customer. But the driver may only arive at the end_address in a certain time_window. I don’t want to set the end_address as normal ‘service’ because then the optimization may put it between two other services.

Is it anyway possible to set a time_window? Only setting latest_end will not work, because this only makes it that the driver must arive before a specified time.

I’m not sure if I understand your requirements properly. Would return_to_deport: false be something that helps you?

Maybe you can describe your current solution with an example and include why it does not work for your use case?

return_to_depot: false would not exactly help, because than the problem arises that the last stop could be optimized between two other stops.

For example, I have a route with 6 stops.

  • The first stop is the HUB (so the start_address for the vehicle).
  • The second, third, fourth and fifth stops are customers that can visited in any order throughout the day.
  • The last stop is not the HUB, also a customer that must come last, but can only be visited between a certain time_window.

For the second to fifth stop, I can add a service with a time_window from the start until the end of the day. If I do the same for the sixth stop and press optimze, It is possible that GraphHopper returns a solution with stop six somewere in the middle, which I don’t want. If I set the sixth location as a end_address for my vehicle, I can’t enter a time_window and GraphHopper can return a solution where the sixth stop arr_time is way before the time_window I want to give to that stop.

That’s why I hoped there would be the option to give the end_address a time_window.

1 Like

You can solve your problem by adding a relation as follows:

   "type": "in_direct_sequence",
   "ids": ["last_stop","end"]

This way you force the last stop to be made just before the end of the route.

relations are described here: https://docs.graphhopper.com/#operation/asyncVRP/body/application/json/relations