您好,我想在Clips中创建一个专家系统,但是当Plant只触发一次规则时,它触发的次数是该规则所指定的特征内重合的次数,有没有办法让此规则仅触发事实中每株植物一次?
我尝试使用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>