Hi
everybody,
I wonder if there is
a better way to implement a kind of "fall-through" rule : my R1 rule is fired
when two conditions are set, but if this is not the case, I need to discard the
new asserted fact (it won't be used anymore).
I wrote the
following code, which works, but I'm not satisfied. Is there another way to do
it?
Just consider that a
NOT condition like (defrule R1-not ?f <- (F1 (s1 ?x)) (not (F2 (s1 ?x)))
=> (something to be done)) would in a way do the same thing without salience,
but in my case, I have many patterns, not only two ( (OR (NOT (p1)) (NOT
(p2)) ... ) is not a valid construction).
Thanks a lot for any
-positive or negative - answer.
(deftemplate F1
(slot s1 (type INTEGER))
)
(slot s1 (type INTEGER))
)
(deftemplate F2
(slot s1 (type INTEGER))
)
(slot s1 (type INTEGER))
)
(defrule R1 (declare (salience 100))
?f <- (F1 (s1 ?x))
(F2 (s1 ?x))
=>
(printout t "R1 executed" crlf)
(retract ?f))
(defrule fall-through (declare (salience 1))
?f <- (F1 (s1 ?x))
=>
(printout t "F1 retracted (fall-through)" crlf)
(retract ?f))
?f <- (F1 (s1 ?x))
=>
(printout t "F1 retracted (fall-through)" crlf)
(retract ?f))
Emmanuel L�charny, IKTEK
06 08 33 32 61, www.iktek.com
