Hi,

I don't understand why 'good' is better than
'bad'?
The only advantage i see is if you know that only
the first variable (eg A) has a condition. 

What if you have a condition for every variable,
or 
condition for the first and the last (this could
occur
if you are writing a lot of rules and you want to
keep
the same order among the variables). Then, is it
still
more efficient to use the '&:' operator than the
'if'?

I could imagine also that when a rule has several
conditions for a single variable it is - if not
faster -
more "handy" to use 'if' when structuring.

What if variables are dependent?

To avoid problems like this, is it not better 
in *general* to use if-statements in RHS?

Last: is there a (forthcoming) book 
on Jess that deals with its later versions?
Something like an updated version of 
Mark Watson's book Artificial Intelligence for
Java 
would be interesting. The current release is 
becoming out of date with respect to Jess and
integration with Java.

ThomasW
[EMAIL PROTECTED]

%
% condition not only in the first variables
%
(defrule bad
        (A ?a)
        (B ?b)
        (C ?c)
        (D ?d)
        (E ?e)
        =>
        (if (eq ?a nothing) then ...)
        (if (eq ?e nothing) then ...)
)
% OR 
(defrule good (A ?a&:(eq ?a nothing)) (B ?b) (C
?c) (D ?d) (E ?e&:(eq ?e nothing)) => ...)
%
% several conditions for same variable
%
(defrule bad
        (A ?a)
        (B ?b)
        (C ?c)
        (D ?d)
        (E ?e)
        =>
        (if     (< ?a nothing) 
                (> ?a something) 
                (<= ?a everything)
                (>= ?a somethingelse)
                (not ?a everythingelse) 
                then ...
        )
)
% OR 
(defrule good (A ?a&:(  (< ?a nothing) 
                        (> ?a something) 
                        (<= ?a everything)
                        (>= ?a somethingelse)
                        (not ?a everythingelse)   
      )  ) (B ?b) (C ?c) (D ?d) (E ?e) => ...
)
%
% variables dependent
%
(defrule bad
        (A ?a)
        (B ?b)
        (C ?c)
        (D ?d)
        (E ?e)
=>
(if     (< ?a ?e) 
        (> ?a ?d) 
        (<= ?a ?c)
        (>= ?a ?b)
        (not ?a 0) 
        then ...
))
% OR 
(defrule good (A ?a&:(  (< ?a ?e) 
                        (> ?a ?d) 
                        (<= ?a ?c)
                        (>= ?a ?b)
                        (not ?a 0)   
      )  ) (B ?b) (C ?c) (D ?d) (E ?e) => ...
)

--- "Ernest J. Friedman-Hill"
<[EMAIL PROTECTED]> wrote:
> It is virtually always better to do all your
> tests on the LHSs of your
> rules. For a rule with one one CE, like this
> one, it doesn't matter
> much, but for a rule like
> 
>       (defrule good (A ?a&:(eq ?a nothing)) (B
> ?b) (C ?c) => ...)
>       (defrule bad (A ?a) (B ?b) (C ?c) => (if
> (eq ?a nothing ) ...)
> 
> the difference can be huge. Making "good"
> faster than "bad" is, in fact,
> the whole point of the Rete algorithm.
> 
> I think Christo Andonyadis wrote:
> > 
> > Which is better/faster:
> > 
> > (something ?s)
> > =>
> > (if (eq ?s nothing) then
> >     (assert (somethingelse nothingatall))
> > )
> > 
> > OR
> > 
> > (something ?s&:(eq ?s nothing))
> > =>
> > (assert (somethingelse nothingatall))
> >
>
---------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe
> jess-users [EMAIL PROTECTED]'
> > in the BODY of a message to
> [EMAIL PROTECTED], NOT to the
> > list. List problems? Notify
> [EMAIL PROTECTED]
> >
>
---------------------------------------------------------------------
> > 
> > 
> 
> 
>
---------------------------------------------------------
> Ernest Friedman-Hill  
> Distributed Systems Research        Phone:
> (925) 294-2154
> Sandia National Labs                FAX:  
> (925) 294-2234
> Org. 8920, MS 9214                 
> [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. List problems? Notify
> [EMAIL PROTECTED]
>
---------------------------------------------------------------------
> 

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to