Drools 推理不起作用

Drools 推理不起作用,drools,inference,Drools,Inference,我不太会流口水。我有这些规则: 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(

我不太会流口水。我有这些规则:

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
以及:

对于规则2或规则3,什么都不会发生。其中一个应该是真的,但没有打印任何内容,好像推断的IsMarque无法评估。如果我对IsMaqrue评估进行了评论,那么我可以看到控制台中打印的消息。
有什么想法吗?

这个规则需要重写为

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
如果已显示所有内容,则无
无循环真值
锁定活动真值

请注意,您也可以将第一条规则编写为

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属性的CEs等其他规则。由于您在规则
“添加品牌波利尼西亚扩展税”
中使用了此“脏更新”,所以它似乎没有问题


请发布完整的规则-#1无法编译。

无论是什么原因使您在活动时使用锁定?把这个拿走除此之外,您无法确定第一条规则是否在extPolynesie为真的Demarche上触发,这是规则2和规则3所必需的。如果您仍然存在激活锁定被删除的问题:请添加代码插入事实。如果我移除激活锁定,则我的规则处于无限循环中。是的,我确信我的demarche是extPolynesie=true,在我的DB中,我只有一个demarche(其中extPolynesie为true)循环:如果是这样的话,你还没有在右边展示你所做的一切-1extPolynesie:也许有一天西医会有另一个研究?你最好证明你的约束。我已经编辑了我的帖子来显示缺失的部分,我对已评估的数据进行了更改,这就是为什么我处于无限循环中。是的,显然有一天我会有一个extPolynesie=false,但现在我只是想让它工作thx,实际上我已经使用了一个全局列表来添加我的税,但这是一个好方法,不更新评估对象,放弃no循环并锁定active。Thx:)
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