we are using optaplanner to try to improve our current vehicle routes with time windows. We have a few smaller issues which we are not sure how to overcome:
Our current idea for the second problem is to create two new classes:
public class ReturningCustomer extends TimeWindowedCustomer {
protected int returningId;
and
public class ReturnToDepot extends TimeWindowedCustomer {
protected int returningId;
where the first one models the customer with special packages, which are to be returned. The second one is the “fake” customer that represents the driver’s return to the depot. ReturnToDepot would have the same location as the depot itself. Comparing their ids in Drools will assure that they are on the same vehicle’s path. Treating the ReturnToDepot as another customer would hopefully assure that the planner finds an optimal way to put it into a route.
However, for the lunch break modeling, we are not quite sure what to do.
Is there a better way to model this? What would be the best way to model the lunch breaks? Are there any samples which could point us to the right direction?
Thanks.
Starting from the TimeWindowed VRP examples, you can do those 2 reqs like this:
Lunch breaks: adjust the arrivalTime calculation in the VariableListener
so that any arrival after the 3th hour will add another 30 minutes to the arrivalTime. Depending on your business needs - for example they can only take a break between locations not at locations - optionally add a hard constraint to assure there's an arrival between the 3th and 5th hour.
Get back in time to depot: add a shadow variable on Vehicle called arrivalBackToDepotTime
and use variableListenerRef
to reuse the ArrivalTimeUpdateVariableListener
which then also needs to update that field. Add a hard constraint to check for each Customer that the Vehicle's arrivalBackToDepotTime
is less than the Customer's required time to get to the depot.