簡體   English   中英

沖突解決步驟在CLIPS中觸發兩條規則

[英]Conflict resolution step fires two rules in CLIPS

根據我在“匹配”步驟中的理解,可以“啟用”幾個規則,因為WM的事實滿足了它們的條件。 但是,我認為在沖突解決步驟中,只會觸發議程中的一項規則。

現在我有一個程序,其中2個規則被啟用到議程和運行步驟都被解雇! 難道不是只有一條規則會被解雇嗎?

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> 

沖突解決不會阻止兩個規則被觸發 - 它只是確定首先觸發的規則。 如果您只想觸發兩個規則中的一個,那么您應該在所選規則的RHS中收回testfact1 ,或者通過其他方式從議程中刪除其他規則(例如,使用控制事實)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM