首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >推理无效

推理无效
EN

Stack Overflow用户
提问于 2014-12-22 16:41:49
回答 1查看 85关注 0票数 0

我对口水比较陌生。我有这样的规则:

代码语言:javascript
复制
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

以及:

代码语言:javascript
复制
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评估这是有效的,我可以看到打印在控制台中的消息。有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-23 10:25:11

此规则需要重写为

代码语言:javascript
复制
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 truelock-on-active true

请注意,您可以将第一条规则写成

代码语言:javascript
复制
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不编译。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27606798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档