修改事实时不会再次触发某些规则
Some rule is not fired again when fact is modified
我已经通过将折扣设置为 5 触发了规则。为什么在 'rule 3'
中修改事实(产品)时 'rule 1' 没有再次触发
输出
规则 1
规则 2
规则 3
规则 2
规则 3
规则 2
规则 3
代码
rule "Rule 1"
when
eval(true)
then
System.out.println("Rule 1");
end
rule "Rule 2"
when
$c: Product(discount < 8 && discount > 3)
then
System.out.println("Rule 2");
end
rule "Rule 3"
when
$c: Product(discount < 8 && discount > 3)
then
System.out.println("Rule 3");
modify($c){
setDiscount($c.getDiscount()+1)
}
System.out.println("--------------");
end
在 LHS 模式中不包含事实类型的规则不会受到对未引用类型的任何事实的任何更改的影响。
Product
未在 "Rule 1" 中引用。
我已经通过将折扣设置为 5 触发了规则。为什么在 'rule 3'
中修改事实(产品)时 'rule 1' 没有再次触发输出
规则 1 规则 2 规则 3
规则 2 规则 3
规则 2 规则 3
代码
rule "Rule 1"
when
eval(true)
then
System.out.println("Rule 1");
end
rule "Rule 2"
when
$c: Product(discount < 8 && discount > 3)
then
System.out.println("Rule 2");
end
rule "Rule 3"
when
$c: Product(discount < 8 && discount > 3)
then
System.out.println("Rule 3");
modify($c){
setDiscount($c.getDiscount()+1)
}
System.out.println("--------------");
end
在 LHS 模式中不包含事实类型的规则不会受到对未引用类型的任何事实的任何更改的影响。
Product
未在 "Rule 1" 中引用。