Re: JESS: logical and groups of patterns

2004-05-06 Thread ejfried
I think Steffen Luypaert wrote:
> 
> I didnt think of this. But to understand the retraction, one has to see 
> the code of the JessListener Java class. So if u look at the Jesscode, 
> you won't understand or or when the retraction happens. In a sense, it 
> happens 'outside' the reasoning of Jess. 

Actually, you can write event handlers in Jess, too. There's a
jess.JessEventAdapter class that you can use like this:

  Jess> ((engine) setEventMask (get-member jess.JessEvent FACT))
  Jess> (deffunction my-handler (?evt)
   (printout t EVENT: (?evt getObject) crlf))
  TRUE
  Jess> ((engine) addJessListener
  (new jess.JessEventAdapter my-handler (engine)))
  Jess> (assert (foo))
  EVENT:
  


This kind of "multiparadigm" support is one of Jess's real
strengths. Event-driven "rule engines" are what IBM (but nobody else)
usually means when they talk about rules. Jess lets you combine
forward and backward chaining, events, and other stuff all in one
package. 



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (925) 294-2154
Sandia National LabsFAX:   (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]




Re: JESS: logical and groups of patterns

2004-05-06 Thread Steffen Luypaert

> The easiest way to do this would be with an event handler. Just
> watch
> for any FACT events, and if the Fact object is an "account" fact,
> then
> retract the sum fact. A lot simpler than what you showed here.
> 

I didnt think of this. But to understand the retraction, one has to see 
the code of the JessListener Java class. So if u look at the Jesscode, 
you won't understand or or when the retraction happens. In a sense, it 
happens 'outside' the reasoning of Jess. Then again, my rule isn't 
readable whatsoever anyway, so I think I'll stick wity your solution. 
Thanks!

Regards,
Steffen.


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]




Re: JESS: logical and groups of patterns

2004-05-06 Thread ejfried
I think Steffen Luypaert wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]

> Now, the problem isn't to get the correct sum. In a former version of 
> my application I calculated it by getting all accounts with a defquery 
> and then using the returned Iterator object to get the desired sum. My 
> problem is to make the sum fact logically dependent of all account 
> facts used to compute it. If an old account fact is modified or 
> retracted, or a new one is asserted, I want the sum fact to be 
> retracted automatically.

The easiest way to do this would be with an event handler. Just watch
for any FACT events, and if the Fact object is an "account" fact, then
retract the sum fact. A lot simpler than what you showed here.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (925) 294-2154
Sandia National LabsFAX:   (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]