Search code examples
optaplanner

Java how to skipping holiday in maintenance scheduling?


Skip weekends. Does not work for holidays. To skip holidays too, cache all working days in scoreDirector.getWorkingSolution().getWorkCalendar(). Keep in sync with Programme.createStartDateList().


Solution

  • Starting from optaplanner-quickstarts's maintenance scheduling example:

    • First precalculate (before calling solve()) all working days and store them in a List<LocalDate> in WorkCalendar.
    • In MaintenanceSchedule.createStartDateList() return that list as the planning value range.
    • In EndDateUpdatingVariableListener.calculateEndDate() use that list instead of presuming it all weekdays (including holidays) are workdays.