【问题标题】:How can we call a defrule inside another defrule?我们如何在另一个 defrule 中调用一个 defrule?
【发布时间】:2020-12-24 15:26:32
【问题描述】:

我对 CLIPS 完全陌生,我想知道我们如何在另一个 defrule 中调用一个 defrule。 例如,如果一个规则执行诸如打印或交换之类的常规工作,而另一个规则想要在自己进行模式匹配后调用它;第二条规则如何在其模式匹配部分调用第一个规则? 谢谢

【问题讨论】:

    标签: artificial-intelligence rules rule-engine clips


    【解决方案1】:

    通过断言一个规则激活另一个规则的事实来实现链式规则。

             CLIPS (6.31 6/12/19)
    CLIPS> 
    (defrule start
       =>
       (assert (r1)))
    CLIPS> 
    (defrule rule-1
       (r1)
       =>)
    CLIPS> (watch rules)
    CLIPS> (watch activations)
    CLIPS> (watch facts)
    CLIPS> (agenda)
    0      start: *
    For a total of 1 activation.
    CLIPS> (run)
    FIRE    1 start: *
    ==> f-1     (r1)
    ==> Activation 0      rule-1: f-1
    FIRE    2 rule-1: f-1
    CLIPS> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多