I think Douglas Pearson wrote:
> 
> The rule that causes the problem starts:
> (defrule redux-jess*propose*mission*proposalrule-12
>    (wme (id state) (att sel) (value ?Friendly_1) )
>    (not (wme (id ?Friendly_1) (att stance) (value "Standing") ))
>    (wme (id ?Friendly_1) (att isThreat) (value ?isThreat1&:(neq ?isThreat1
> ?isFriend)) )
>    (wme (id ?Friendly_1) (att isFriend) (value ?isFriend) )
>    (wme (id ?Friendly_1) (att mission) (value ?mission) )
     ...

We can share the blame for this one, how about that? There's an error
in this rule, but rather than reporting it, Jess is trying (and
failing) to compile the rule anyway. This is actually the same kind of
thing that Mitch Christensen reported about a month ago.

The error is that in the third pattern above, you compare ?isThreat1
to ?isFriend, but ?isFriend isn't bound to a value until the next
pattern. Matches are done from top to bottom, and so this really is a
meaningless test.

Rearranging the patterns in the way you did doesn't actually fix the
problem -- it just hides it. You're trading a bogus test which throws
an exception for a bogus test that doesn't, which is arguably
worse. Rearranging the patterns like this:

(defrule redux-jess*propose*mission*proposalrule-12
   (wme (id state) (att sel) (value ?Friendly_1) )
   (not (wme (id ?Friendly_1) (att stance) (value "Standing") ))
   (wme (id ?Friendly_1) (att isFriend) (value ?isFriend) )
   (wme (id ?Friendly_1) (att isThreat) (value ?isThreat1&:(neq ?isThreat1 ?isFriend)) 
)
   (wme (id ?Friendly_1) (att mission) (value ?mission) )
   ...

*does* fix the problem. 

Incidentally, the pattern with the "neq" could be written more
efficiently as

   (wme (id ?Friendly_1) (att isThreat) (value ?isThreat1&~?isFriend))

This means the same thing, but it's going to be faster. It's always
better to use direct matching rather than calling a function when you
can.

In any event, as I said, Jess should be catching the undefined
variable problem when it compiles the rule, so I'm logging this as a
bug. Thanks for the report.


---------------------------------------------------------
Ernest Friedman-Hill  
Science and Engineering PSEs        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