I think Rodolfo Martin wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
> Perhaps this question only shows my lack of  knowledge, but I've been 
> playing for a while with Jess and have found that rules are re-activated 
> too easily for me. Any change in a fact that matches any condition on 
> the LHS part of the rule gets the rule activated again. 

Yes, this is traditionally how Rete-based rule engines work.

> 
> The (single-slot-activation) and (no-loop) features of Charlemagne 
> engine helps, but are not enough for me.

It should be -- it's just a question of using it correctly. As a
community, we have to work to figure out the best practices for using
them. One general rule is to use slot-specific deftemplates, and then
to use fact-slot-value on the RHS of a rule to extract the values of
slots you don't want to react to -- i.e., this first rule will loop:

(deftemplate foo (declare (slot-specific TRUE)) (slot bar))

(defrule will-loop
  ?f <- (foo (bar ?X))
  =>
  (modify  ?f (bar (+ ?X 1))))

whereas this one won't:

(defrule will-loop
  ?f <- (foo)
  =>
  (modify  ?f (bar (+ (fact-slot-value ?f X) 1))))

Note that there's no difference in performance between these two
rules. Note that the deciding factor for this is whether the contents
of a slot are actually used for anything on the LHS of the rule --
i.e., if you compared the value of a slot to another slot, then you
wouldn't be able to do this. Note also that in cases where you can't
do this, you generally don't want to -- i.e., modifying the slot
contents would invalidate the activation, so you would indeed want the
Rete network to react. You don't want to start replacing patterns with
"if" functions -- that would be both inefficient and defeat the whole
purpose of this exercise.

> Is possible to change the activation behaviour so the rules only be 
> re-activated by changes on facts that affect the FIRST LHS
> condition?

Not globally, of course, as it would break many other applications! I
could imagine a conditional element called "reactive" something like

(defrule example
  (reactive
    (pattern1 (bar ?X)))
  (pattern2)
  => ...

which would make pattern1 reactive to modifications, but not
pattern2. The problem with this kind of thing is that it's going to
reduce sharing in the Rete network, dragging down performance.

>  From my point of view that will make the rules more clear (the LHS part 
> less cluttered with no loop conditions), and also improves the 
> performance (less LHS processing, less not conditions).

Just because you can't *see* the processing, doesn't mean that it
doesn't go away! Special cases always make things more expensive.



---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to