1

I'm a Informatics Nurse trying to develop a machine-assisted process for nursing rostering. Half the staff works elsewhere so our main constraint is their schedule in the other institution where they work. We get this information the 20th. of every month so we have 10 days to plan ahead. The hard constraints would be their assigned shifts in their other job, that follows no pattern, so we would need to "manually" cross out those days from the calendar, and then calculate the solution (given other constraints such as no early shift after a night shift, no night shift before a day off, etc.). Do you think an implementation like this could be feasible with Optaplanner?

Community
  • 1
  • 1
ceciliasp
  • 23
  • 4
  • 1
    This question appears to be off-topic because it is about resource planning. – Evan Trimboli Aug 21 '14 at 23:05
  • Because it's asking for an opinion (which they don't like at StackOverflow), it's probably better suited for the [optaplanner dev list](https://groups.google.com/forum/#!forum/optaplanner-dev). An easy mistake to make. – Geoffrey De Smet Aug 22 '14 at 08:16

2 Answers2

1

It's just a matter of taking OptaPlanner's nurse rostering example (video) and adjust the constraints (and potentially the domain model) to your needs. However, to do this, it requires some Java programming skill.

Docs that explain which constraint types are already available in the example out of the box.

Source code for nurse rostering, where you can add additional constraint types:

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
0

Cecilia, here you are, some constraints, that I use in my rostering App, with optaplanner library. You can add this rules, to the NurseRosteringScoreRules.drl file, and will not be necesary to implement constraint types. I hope that help you.

rule "No dos tareas iguales el mismo dia al mismo empleado"//"oneShiftPerDay" Modificada, la antigua, hay que quitarla.
    when
        $leftAssignment : ShiftAssignment($leftId : id, $employee : employee, $shiftDate : shiftDate, $shiftType : shiftType, employee != null)
        $rightAssignment : ShiftAssignment(employee == $employee, shiftDate == $shiftDate, $shiftType == shiftType, id > $leftId)
    then
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end

rule "No Noche-Libre en días consecutivos"
        salience 1
    when
        ShiftAssignment(
            shiftType.code == "N",
            $employee : employee, $shiftDate : shiftDate, employee != null)
        DayOffRequest(employee == $employee, shiftDate.dayIndex == ($shiftDate.dayIndex + 1))
    then
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end
rule "No Noche-Mañana en días consecutivos"
        salience 2
    when
        ShiftAssignment(
            shiftType.code == "N",
            $employee : employee, $shiftDate : shiftDate, employee != null)
        ShiftAssignment(
            shiftType.code == "M",
            employee == $employee, shiftDate.dayIndex == ($shiftDate.dayIndex + 1)
        )
    then
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end
rule "No Noche-Tarde en días consecutivos"
        salience 2
    when
        ShiftAssignment(
            shiftType.code == "N",
            $employee : employee, $shiftDate : shiftDate, employee != null)
        ShiftAssignment(
            shiftType.code == "T",
            employee == $employee, shiftDate.dayIndex == ($shiftDate.dayIndex + 1)
        )
    then
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end
rule "No Mañana-Tarde en el mismo día"
    when
        $leftAssignment : ShiftAssignment($leftId : id, $employee : employee,
        $shiftDate : shiftDate, $shiftType : shiftType, employee != null)
        $rightAssignment : ShiftAssignment(employee == $employee,
        shiftDate == $shiftDate, shiftType.code == "T", $shiftType.code == "M", id > $leftId)
    then
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end

rule "No Tarde-Noche en el mismo día"
    when
        $leftAssignment : ShiftAssignment($leftId : id, $employee : employee,
        $shiftDate : shiftDate, $shiftType : shiftType, employee != null)
        $rightAssignment : ShiftAssignment(employee == $employee,
        shiftDate == $shiftDate, shiftType.code == "N", $shiftType.code == "T", id > $leftId)
    then
        scoreHolder.addHardConstraintMatch(kcontext, -1);
end