护士排班实施具有非常“硬”的硬约束

时间:2014-08-21 23:01:16

标签: optaplanner rostering

我是一名信息学护士,正在尝试开发机器辅助护理排班流程。一半的工作人员在其他地方工作,所以我们的主要制约因素是他们工作的其他机构的时间表我们得到这个信息20。每个月所以我们有10天的时间提前计划。硬约束将是他们在其他工作中分配的轮班,没有模式,所以我们需要手动"从日历中划掉那些日子,然后计算解决方案(给出其他限制,例如夜班后没有提前班次,休息前没有夜班等)。您是否认为使用Optaplanner可以实现这样的实现?

2 个答案:

答案 0 :(得分:1)

只需要考虑OptaPlanner的护士排班示例(video)并根据您的需要调整约束(可能还有域模型)。但是,要做到这一点,它需要一些Java编程技能。

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

护士排班的源代码,您可以在其中添加其他约束类型:

答案 1 :(得分:0)

Cecilia,在这里,你有一些限制,我在我的排班应用程序中使用optaplanner库。您可以将此规则添加到NurseRosteringScoreRules.drl文件中,并且无需实现约束类型。我希望能帮助你。

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