Search code examples
optaplanner

VRP - Vehicle go back to depot depends on each Customer


I'm modeling a problem where the "vehicle go back to depot" constraint depends on each Customer Delivery.

For example, I will delivery something to customer A and he will sign an paper, this paper needs to return to the depot. I will delivery something to another customer B, and on this delivery the vehicle doesn't have to return to depot. If the customer A and customer B are near, and respect the time window, it could be delivered together.

There is a simple way to do this? Thanks in advance.


Solution

  • The default model doesn't need to alter much for this.

    The getDistanceToPrevious method is basically what is is now for B, for A it is the distance to the depot + the distance from the depot to A.