Hi. I think Im confused about return to Depot option. I have set for each vehicle the endLocation and I have set returnToDepot to be true. But it does not seem to do anything and Im not sure what the outcome should be.
Should I be expecting another task to be added to the end of each route sends the vehicle to the endLocation or does it just make sure there is travel time available to be back at the depot by the lastArrival time for the vehicle ?
Im not sure how this should manifest itself and it does not seem to do anything.
Other than that - I love this system. It is pure digital magic.
If returnToDepot is true, then the vehicle needs to return to where it actually started (start location). If it is false, it can end its route anywhere. To be a bit more precise, “anywhere” means that the algorithm determines the end location of the vehicle. It chooses the end location from the set of all task locations. And yes, if returnToDepot is false, the vehicle do not need to make the return leg, i.e. it might have time to conduct another task.
How are you determining this? I think the travel distance and time to the depot at the end of the route should be clear in an unmodified SolutionPrinter output. Are you manually extracting the stops from your route?
We are using SolutionPrinter but a modified version. I’ll put some code in to generate the original as well and see if it looks different. Thanks for the suggestion
Im still struggling with this.
I have included the end of a detailed solution printout for a job that was set to "return to depot"
I see nothing to indicate that it should return to depot and the last activity is deliverShipment then End.
I could do with some help here. I just can’t see what Im doing wrong. I have confirmed that the option is set to true for return to depot. Are there any circumstances that would result it in being ignored ?
if the end location of vehicle 8500154829445 (if not set, then the start location, since return to depot is true) and the delivery location of shipment 2571_30 are not the same, then something seems not correct.
if you can confirm they are different, could you send a code snippet of constructing the vrp? because return to depot works fine for me and I am not able to reproduce your issue. Thanks.
A route is a sequence of activities, i.e. start, act1, act2, …, act_n, end.
Start and end need to be retrieved by route.getStart() and route.getEnd(). If you want to get any other activity between start and end, you need to iterate over route.getActivities(). Thus, start and end are not included in this list (route.getActivities()).
If returnToDepot == true then route.getEnd() is either equal to route.getStart() (if you omit to set a specific end) or your specified end location. If returnToDepot == false, route.getEnd() should be equal to the last activity (act_n) location from route.getActivities().
Thanks Stefan that helped to understand what I should be looking for. It also shows that I have a problem. In the details report above it shows that the end time of the last job is the start time as the arrive time of the “end”. But the vehicle would have to have travelled some distance to get there So I would expect the arrive time of “end” to be somewhat later than the “depart” time of the last activity.
Anything in the code fragment that suggests a bungle on my part ?
I extended the print out to include the location of the END event and it is showing as the location of the last job - whereas it should be showing as the location of the depot (start point).
Below is an extract from the output. Note that the value after the location is the distance from the previous activity to the named location - in this case 0.0
Im still struggling with this. It is clear that the “End” activity is the same location as the last “Deliver” activity and as far as I can tell it should not be - it should be the depot location.
I am delighted to report that the issue is resolved. Your suggestion (jie31best) pointed us at the problem. It was actually that the code to set the return to depot flag was failing the conditional test
stefan is it possible to close this issue ? It is not really helpful to the community in general as the problem was an “undocumented feature” in our code.