绑定变量似乎被错误地识别为方法
Binding variables seemed to be recognized as methods incorrectly
drl:
rule "adjectFreePeriods"
when
$studentGroupAndEduClass : StudentGroupAndEduClass($eduClasses : eduClasses)
not LectureOfEduClass(eduClass memberOf $eduClasses,
$day : day, $timeslotIndex : timeslotIndex, period != null
)
not LectureOfEduClass(eduClass memberOf $eduClasses,
$day == day, timeslotIndex == ($timeslotIndex + 1)
)
then
scoreHolder.addSoftConstraintMatch(kcontext,- $studentGroupAndEduClass.getStudents().size());
end
java:
public class LectureOfEduClass{
// ...
//omitted others
public Day getDay(){
if(period == null){
return null;
}
return period.getDay();
}
public int getTimeslotIndex() {
if (period == null) {
return Integer.MIN_VALUE;
}
return period.getTimeslot().getTimeslotIndex();
}
}
这是确切的错误消息。
Unable to Analyse Expression $day == day:
[Error: unable to resolve method using strict-mode: domain.LectureOfEduClass.$day()]
[Near : {... $day == day ....}]
^
Unable to Analyse Expression timeslotIndex == ($timeslotIndex + 1):
[Error: unable to resolve method using strict-mode: domain.LectureOfEduClass.$timeslotIndex()]
[Near : {... timeslotIndex == ($timeslotIndex + 1) ....}]
^
根据显示的错误消息,引擎似乎错误地将这两个绑定变量作为 POJO 的方法。
这些代码片段有什么问题?我该如何解决?
问题是您在 not
模式中绑定 $day
。由于显而易见的原因,not
(或 exists
)模式中的所有变量都是该模式的局部变量。我认为你正在尝试做的是这样的:
rule "adjectFreePeriods"
when
$studentGroupAndEduClass : StudentGroupAndEduClass($eduClasses : eduClasses)
not (
LectureOfEduClass(
eduClass memberOf $eduClasses,
$day : day,
$timeslotIndex : timeslotIndex, period != null
) and
LectureOfEduClass(
eduClass memberOf $eduClasses,
$day == day,
timeslotIndex == ($timeslotIndex + 1)
)
)
then
scoreHolder.addSoftConstraintMatch(kcontext,- $studentGroupAndEduClass.getStudents().size());
end
希望对您有所帮助,
drl:
rule "adjectFreePeriods"
when
$studentGroupAndEduClass : StudentGroupAndEduClass($eduClasses : eduClasses)
not LectureOfEduClass(eduClass memberOf $eduClasses,
$day : day, $timeslotIndex : timeslotIndex, period != null
)
not LectureOfEduClass(eduClass memberOf $eduClasses,
$day == day, timeslotIndex == ($timeslotIndex + 1)
)
then
scoreHolder.addSoftConstraintMatch(kcontext,- $studentGroupAndEduClass.getStudents().size());
end
java:
public class LectureOfEduClass{
// ...
//omitted others
public Day getDay(){
if(period == null){
return null;
}
return period.getDay();
}
public int getTimeslotIndex() {
if (period == null) {
return Integer.MIN_VALUE;
}
return period.getTimeslot().getTimeslotIndex();
}
}
这是确切的错误消息。
Unable to Analyse Expression $day == day:
[Error: unable to resolve method using strict-mode: domain.LectureOfEduClass.$day()]
[Near : {... $day == day ....}]
^
Unable to Analyse Expression timeslotIndex == ($timeslotIndex + 1):
[Error: unable to resolve method using strict-mode: domain.LectureOfEduClass.$timeslotIndex()]
[Near : {... timeslotIndex == ($timeslotIndex + 1) ....}]
^
根据显示的错误消息,引擎似乎错误地将这两个绑定变量作为 POJO 的方法。 这些代码片段有什么问题?我该如何解决?
问题是您在 not
模式中绑定 $day
。由于显而易见的原因,not
(或 exists
)模式中的所有变量都是该模式的局部变量。我认为你正在尝试做的是这样的:
rule "adjectFreePeriods"
when
$studentGroupAndEduClass : StudentGroupAndEduClass($eduClasses : eduClasses)
not (
LectureOfEduClass(
eduClass memberOf $eduClasses,
$day : day,
$timeslotIndex : timeslotIndex, period != null
) and
LectureOfEduClass(
eduClass memberOf $eduClasses,
$day == day,
timeslotIndex == ($timeslotIndex + 1)
)
)
then
scoreHolder.addSoftConstraintMatch(kcontext,- $studentGroupAndEduClass.getStudents().size());
end
希望对您有所帮助,