Search code examples
optaplanner

Optaplanner - availability of Vehicles


I am working on a VRPTW problem where vehicles have availablity constraints. This means that they might not be available the entire period of a day - basically a time windows for vehicles. Is there a way to build this in optaplanner?

Thank you and Brgds, Paul


Solution

  • This following should work:

    • add 2 fields (start and end) on (TimeWindowed)Vehicle
    • in ArrivalTimeUpdatingVariableListener use at least the vehicle's start time before it leaves a depot
    • add a hard constraint that the vehicle should be back at the depot by it's end time. Make sure to penalize not just -1, but instead, minus the amount of time it's overdue (to avoid a score trap, see docs).