在 drools DRL 中检查对象数组是否没有值
In drools DRL check that an array of objects doesnt have a value
我正在尝试向 optaplanner business central 中的员工名册示例添加新规则。检查是否将轮班分配给员工在其日程安排之外的规则会降低硬约束得分持有者。
package employeerostering.employeerostering;
rule "ShiftHoursWithinEmployeeSchedule"
dialect "mvel"
when
$shiftAssignment : ShiftAssignment( $employee : employee != null, $shiftEndDateTime : shift.timeslot.endTime, $shiftStartDate : shift.timeslot.startTime)
not Schedule ( day == $shiftEndDateTime.dayOfWeek.getValue() && (startTime > $shiftStartDateTime || endTime < $shiftEndDateTime) ) from $employee.schedules
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end
我是 DRL 的新手,我想修改第二条规则,以便它遍历 $employee 的所有计划,并检查是否有一个满足条件的计划。
我认为你只需要翻转关系运算符,因为你想惩罚没有时间表的情况,这样班次 适合时间表 :
not Schedule ( day == $shiftEndDateTime.dayOfWeek.getValue() && (
startTime < $shiftStartDateTime &&
endTime > $shiftEndDateTime)
) from $employee.schedules
不确定 Schedule.startTime
的类型。如果它是一天的时间偏移量(例如 8:00),那么您可能无法将它与 Timeslot.startTime
进行比较,后者可能是绝对时间量(日期 + 时间)。
我建议在 Schedule
中重复使用 Timeslot
类型,而不是将时间表定义为日期 + 时间。那么你应该可以写:
rule "ShiftHoursWithinEmployeeSchedule"
dialect "mvel"
when
$shiftAssignment : ShiftAssignment( $employee : employee != null, $shiftEndDateTime : shift.timeslot.endTime, $shiftStartDate : shift.timeslot.startTime)
not Schedule ( timeslot.startTime > $shiftStartDateTime && timeslot.endTime < $shiftEndDateTime ) from $employee.schedules
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end
我正在尝试向 optaplanner business central 中的员工名册示例添加新规则。检查是否将轮班分配给员工在其日程安排之外的规则会降低硬约束得分持有者。
package employeerostering.employeerostering;
rule "ShiftHoursWithinEmployeeSchedule"
dialect "mvel"
when
$shiftAssignment : ShiftAssignment( $employee : employee != null, $shiftEndDateTime : shift.timeslot.endTime, $shiftStartDate : shift.timeslot.startTime)
not Schedule ( day == $shiftEndDateTime.dayOfWeek.getValue() && (startTime > $shiftStartDateTime || endTime < $shiftEndDateTime) ) from $employee.schedules
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end
我是 DRL 的新手,我想修改第二条规则,以便它遍历 $employee 的所有计划,并检查是否有一个满足条件的计划。
我认为你只需要翻转关系运算符,因为你想惩罚没有时间表的情况,这样班次 适合时间表 :
not Schedule ( day == $shiftEndDateTime.dayOfWeek.getValue() && (
startTime < $shiftStartDateTime &&
endTime > $shiftEndDateTime)
) from $employee.schedules
不确定 Schedule.startTime
的类型。如果它是一天的时间偏移量(例如 8:00),那么您可能无法将它与 Timeslot.startTime
进行比较,后者可能是绝对时间量(日期 + 时间)。
我建议在 Schedule
中重复使用 Timeslot
类型,而不是将时间表定义为日期 + 时间。那么你应该可以写:
rule "ShiftHoursWithinEmployeeSchedule"
dialect "mvel"
when
$shiftAssignment : ShiftAssignment( $employee : employee != null, $shiftEndDateTime : shift.timeslot.endTime, $shiftStartDate : shift.timeslot.startTime)
not Schedule ( timeslot.startTime > $shiftStartDateTime && timeslot.endTime < $shiftEndDateTime ) from $employee.schedules
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end