0
votes

I'm building a roster planner application based on the NurseRostering example for OptaPlanner 7.5.0 Final.

The rostering demands for holidays such as Christmas or Easter are identical to regular weekends (same shift type & amount), therefore I want to change the default weekend definition to include predefined holidays.

I tried changing the WeekendDefinition class in the NurseRostering example (src\main\java\org\optaplanner\examples\nurserostering\domain\WeekendDefinition.java), but is has no effect on the weekend definition used by the planner.
How do I change the weekend definition used by OptaPlanner?

1

1 Answers

0
votes

Start from ShiftAssignment.isWeekend(): https://github.com/kiegroup/optaplanner/blob/master/optaplanner-examples/src/main/java/org/optaplanner/examples/nurserostering/domain/ShiftAssignment.java#L94

    public boolean isWeekend() {
        if (employee == null) {
            return false;
        }
        WeekendDefinition weekendDefinition = employee.getContract().getWeekendDefinition();
        DayOfWeek dayOfWeek = shift.getShiftDate().getDayOfWeek();
        return weekendDefinition.isWeekend(dayOfWeek); // Add or shiftDate is 25-DEC
    }