Hi,
If it helps, I should point out that your two rules are guaranteed to
fire in the order you want -even if they don't declare salience
values-, as long as the default "depth" conflict resolution strategy
is installed, and as long as all the preconditions exist before either
rule has a chance to fire. See manual section 2.8.1.3 on conflict
resolution. The manual is not explicit on this, and it probably should
be, but for the purposes of conflict resolution, each facts is
assigned a time when it is installed. The times that are compared in
the conflict resolution phase are a monotonically increasing function
of the times the facts are asserted. In particular, a rule that was
activated because of facts a and b together is considered to have been
activated at a later time than one that was activated due to fact a
alone, regardless of whether fact b was asserted before or after fact
a.
I think =?iso-8859-1?Q?Emmanuel_L=E9charny?= wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 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))
> )
>
> (deftemplate F2
> (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))
>
> Emmanuel L_charny, IKTEK
> 06 08 33 32 61, www.iktek.com
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------