根据我在“匹配”步骤中的理解,几个规则可能会被“启用”,因为它们的条件被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>
发布于 2014-11-07 15:15:56
冲突解决不能阻止这两种规则的触发-它只是确定哪个是首先触发的。如果您只希望这两条规则中的一条触发,那么您应该撤回所选规则的RHS中的testfact1
,或者通过其他方法(例如,使用控制事实)将另一条规则从议程中删除。
https://stackoverflow.com/questions/26800973
复制相似问题