【问题标题】:Nurse rostering implementation with very "hard" hard constraints具有非常“硬”的硬约束的护士排班实施
【发布时间】:2014-08-21 23:01:15
【问题描述】:

我是一名信息学护士,正在尝试开发一种用于护理轮班的机器辅助流程。一半的员工在其他地方工作,所以我们的主要限制是他们在他们工作的其他机构的日程安排。我们在 20 日收到此信息。每个月,所以我们有 10 天的时间提前计划。硬约束将是他们在其他工作中分配的班次,不遵循任何模式,因此我们需要“手动”从日历中划掉那些日子,然后计算解决方案(考虑到其他限制,例如在夜班、放假前不夜班等)。您认为使用 Optaplanner 可以实现这样的实现吗?

【问题讨论】:

  • 这个问题似乎跑题了,因为它是关于资源规划的。
  • 因为它在征求意见(在 StackOverflow 上他们不喜欢这种做法),它可能更适合 optaplanner dev list。容易犯的错误。

标签: optaplanner rostering


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-16
      • 2014-11-07
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      相关资源
      最近更新 更多