我对口水比较陌生。我有这样的规则:
import models.Demarche;
declare IsMarque
demarche : Demarche
end
rule "Add type Marque taxe"
salience 2
no-loop true
lock-on-active true
when
$d : Demarche( typeDemarche == "Marque" )
then
modify($d){
listTaxes.put(14, 1)
}
insert( new IsMarque( $d ) );
System.out.println("infer marque");
end以及:
rule "Add Marque Polynesie extention taxe"
no-loop true
lock-on-active true
when
$d : Demarche( extPolynesie == true)
IsMarque(demarche == $d)
then
$d.listTaxes.put(17, 1);
System.out.println("marque");
end
rule "Add Not Marque Polynesie extention taxe"
no-loop true
lock-on-active true
when
$d : Demarche( extPolynesie == true)
not(IsMarque(demarche == $d))
then
System.out.println("not marque");
end对于规则2或3,什么都不会发生。其中一个应该是真,但没有打印,就好像无法计算推断的IsMarque一样。如果我评论IsMaqrue评估这是有效的,我可以看到打印在控制台中的消息。有什么想法吗?
发布于 2014-12-23 10:25:11
此规则需要重写为
rule "Add type Marque taxe"
when
$d : Demarche( typeDemarche == "Marque", $t: listTaxes) // I AM GUESSING HERE
not IsMarque(demarche == $d)
then
modify($t){
put(14, 1)
}
insert( new IsMarque( $d ) );
System.out.println("infer marque");
end如果你展示了所有的东西,就没有no-loop true和lock-on-active true 。
请注意,您可以将第一条规则写成
rule "Add type Marque taxe"
when
$d : Demarche( typeDemarche == "Marque")
then
$d.getListTaxes().put(14, 1);
insert( new IsMarque( $d ) );
System.out.println("infer marque");
end如果(且仅当)没有其他规则引用listTaxes属性。由于您在规则"Add Marque Polynesie extention taxe"中使用了这个“脏更新”,所以它似乎没有问题。
请张贴完整的规则- #1不编译。
https://stackoverflow.com/questions/27606798
复制相似问题