CLIPS 规则触发不止一次
CLIPS Rules trigger more than once
您好,我正在尝试在 Clips 中制作一个专家系统,但是当植物应该只触发一次规则时,它触发的次数与规则中指定的特征一致的次数一样多,有没有办法做到这一点事实中每个植物只触发一次规则?
我尝试使用 test()(通过将所有条件 or() 包含在测试中)语句,但它没有用,它会给我带来工厂模板的麻烦
规则示例
(defrule ruleexp
(or
(Plant (grownt normal))
(Plant (leaf purple))
(Plant (roots burned))
(Plant (fruit dry)))
=>
(printout t "this should print only once" crlf))
您可以使用 exists 条件元素只创建一个激活:
CLIPS (6.31 6/12/19)
CLIPS>
(deftemplate Plant
(slot growth)
(slot leaf)
(slot roots)
(slot fruit))
CLIPS>
(defrule ruleexp
(exists
(or (Plant (growth normal))
(Plant (leaf purple))
(Plant (roots burned))
(Plant (fruit dry))))
=>
(printout t "this should print only once" crlf))
CLIPS>
(assert (Plant (growth normal)
(leaf blue)
(roots burned)
(fruit wet)))
<Fact-1>
CLIPS> (run)
this should print only once
CLIPS>
您好,我正在尝试在 Clips 中制作一个专家系统,但是当植物应该只触发一次规则时,它触发的次数与规则中指定的特征一致的次数一样多,有没有办法做到这一点事实中每个植物只触发一次规则?
我尝试使用 test()(通过将所有条件 or() 包含在测试中)语句,但它没有用,它会给我带来工厂模板的麻烦
规则示例
(defrule ruleexp
(or
(Plant (grownt normal))
(Plant (leaf purple))
(Plant (roots burned))
(Plant (fruit dry)))
=>
(printout t "this should print only once" crlf))
您可以使用 exists 条件元素只创建一个激活:
CLIPS (6.31 6/12/19)
CLIPS>
(deftemplate Plant
(slot growth)
(slot leaf)
(slot roots)
(slot fruit))
CLIPS>
(defrule ruleexp
(exists
(or (Plant (growth normal))
(Plant (leaf purple))
(Plant (roots burned))
(Plant (fruit dry))))
=>
(printout t "this should print only once" crlf))
CLIPS>
(assert (Plant (growth normal)
(leaf blue)
(roots burned)
(fruit wet)))
<Fact-1>
CLIPS> (run)
this should print only once
CLIPS>