Search code examples
optaplanner

Conditional Time Window based on the type of crew


We are building a solution that will optimize flight crew transportation (vehicle capacited problem with time window) . The problem is bus must be at the correct time when picking up arrival crew and when dropping off departure crew. Can we set time window for pickup time of arrival crew and another time window for dropoff time of departure crew? Also i cannot split optimization into runs since both types of crew are using the same buses?


Solution

  • This is a VRP with pickup and delivery and time windows. The OptaPlanner Examples don't include a pickup and delivery example yet, but many users have implemented it before. There are several ways to do pickup and delivery (see discussions on mailing list etc).

    If you have the easiest pickup and delivery use case, for which you can't mix crews in the same bus at the same time, it's easy: simply split Customer.location into Customer.pickupLocation and Customer.deliveryLocation. Similarly, split up the readyTime and dueTime into pickupReadyTime, pickupDueTime, deliveryReadyTime and deliveryDuetime. Then split up the shadow var arrivalTime into pickupArrivalTime and maybe deliveryArrivalTime if needed. Adjust the variable listener that updates those 2 arrivalTimes accordingly. Have that listener still make sure that if the pickupReadyTime is after the pickupArrivalTime, it delays the pickupArrivalTime to the pickupReadyTime.