根据我在“匹配”步骤中的理解,一些规则可能会被“启用”,因为它们的条件满足了 WM 中的事实。不过,我认为在冲突解决步骤中,只会触发议程中的一项规则。
现在我有一个程序,其中在议程中启用了两条规则,并且在运行步骤中两条规则都被解雇了!不是应该只解雇一条规则吗?
CLIPS> (defrule testrule1 (declare (salience 1))
(testfact1) (testfact2) => (printout t "testrule1 firing." crlf))
CLIPS> (defrule testrule2
(testfact1) => (printout t "testrule2 firing." crlf))
CLIPS> (assert (testfact1) (testfact2))
==> f-1 (testfact1)
==> Activation 0 testrule2: f-1
==> f-2 (testfact2)
==> Activation 1 testrule1: f-1,f-2
<Fact-2>
CLIPS> (agenda)
1 testrule1: f-1,f-2
0 testrule2: f-1
For a total of 2 activations.
CLIPS> (run)
FIRE 1 testrule1: f-1,f-2
testrule1 firing.
FIRE 2 testrule2: f-1
testrule2 firing.
CLIPS>
最佳答案
冲突解决不会阻止两条规则的触发 - 它只是确定先触发哪个规则。如果您只想触发两个规则之一,那么您应该在所选规则的右侧撤消 testfact1
,或者通过其他方式从议程中删除另一个规则(例如,使用控件事实)。
关于clips - 冲突解决步骤触发 CLIPS 中的两条规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26800973/