我有几个域规则(I 'll call them ' preconditions'),我将其描述为Drools Rules . 例如,要将学生视为 HasGoodGrades ,他们必须保持GPA> 3.0 . 我也有规则,这些规则基本上是这些前提条件的布尔逻辑分组 - 例如 IsInHonorRoll . 如果 IsInHonorRoll 为真,则需要满足规则 HasGoodGrades ,或( HasOkGrades AND HasPerfectAttendance ) .
当规则满足时,如何'm handling this is I'm插入 PreconditionResult 事实 . 然后,在这些更大的'grouping'规则中,我正在检查这些 PreconditionResult 事实并在那里执行布尔逻辑:
rule "IsInHonorRoll"
dialect "mvel"
when
$s : Student()
PreconditionResult( id == "HasGoodGrades", student == $s)
or
( PreconditionResult( id == "HasOkGrades", student == $s)
and
PreconditionResult( id == "HasPerfectAttendance", student == $s) )
then
System.out.print("Student is in the Honor Roll.");
end
rule "HasOkGrades"
dialect "mvel"
when
$s : Student( gpa > 2.0 )
then
insert(new PreconditionResult("HasOkGrades", $s))
end
rule "HasGoodGrades"
dialect "mvel"
when
$s : Student( gpa < 3.0 )
then
insert(new PreconditionResult("HasGoodGrades", $s))
end
rule "HasPerfectAttendance"
dialect "mvel"
when
$s : Student( daysAbsent == 0 )
then
insert(new PreconditionResult("HasPerfectAttendance", $s))
end
这似乎有效,但感觉不自然,我确信在Drools中有更好的方法来做这类事情 . 更重要的是,给定足够的这些规则以及足够大且复杂的布尔子句,Drools即使给出非常大的堆大小也会开始出现内存不足错误 .
处理Drools规则的这些布尔逻辑“分组”的最佳方法是什么?谢谢!