我正在将Optaplanner与Drools结合使用,并且有Drools规则:
basename `cat /proc/1/cpuset`
7be92808767a667f35c8505cbf40d14e931ef6db5b0210329cf193b15ba9d605
这很好。
我想确保学生没有背对背的课程:
rule "No student double booked"
when
ScheduledLesson($timeslot : timeslot, $student : lesson.student)
ScheduledLesson(timeslot == $timeslot, lesson.student == $student)
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end
请注意第四行的rule "Student does not have contiguous lessons"
when
ScheduledLesson($timeslot : timeslot, $student : lesson.student)
ScheduledLesson(timeslot == $timeslot + 1, lesson.student == $student)
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end
件。这给出了以下错误:
timeslot == $timeslot + 1
这似乎与Drools documentation which touches on maths不符。我要去哪里错了,如何在Drools中实施此规则?
Exception in thread "main" java.lang.RuntimeException: Error evaluating constraint 'timeslot == $timeslot + 1' in [Rule "Student does not have contiguous lessons" filename]
看起来像这样:
ScheduledLesson
谢谢。
答案 0 :(得分:0)
我怀疑redisAsyncSetConnectCallback
返回了实例ScheduledLesson.getTimeslot()
,而不是Timeslot
。
int
方法
ScheduledLesson.getTimeslotIndex()
return timeslot.getIndex()