JESS: [JESS]: Removing rules from a session.

View: New views
7 Messages — Rating Filter:   Alert me  

JESS: [JESS]: Removing rules from a session.

by ivo jonker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone here at the JESS group!
 
Is it possible to dispose all defined rules in the current jess session? (sort of the (reset) for rules.)
 
The reason i'm asking is that i'd like to be able to refresh the rule-base during runtime of our application.
 
Kind regards,
Ivo Jonker

Re: JESS: [JESS]: Removing rules from a session.

by Wolfgang Laun :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This Jess snippet will get rid of all your rules and queries

   (bind ?iter ((engine) listDefrules))
   (while (?iter hasNext)
     (bind ?rule (?iter next))
     (undefrule (?rule getName)))

If the object returned from the iterator is instanceof Defrule/Defquery
it is a rule/query, so you could restrict deletions to either subclass.

kr
Wolfgang

ivo jonker wrote:

> Hello everyone here at the JESS group!
>
> Is it possible to dispose all defined rules in the current jess
> session? (sort of the (reset) for rules.)
>
> The reason i'm asking is that i'd like to be able to refresh the
> rule-base during runtime of our application.
>
> Kind regards,
> Ivo Jonker




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: [JESS]: Removing rules from a session.

by ivo jonker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a lot, this is exactly what i was looking for.
 
I've just ordered the book: Jess in action and it should arrive shortly. I'm looking forward to it and i know it will be usefull.
 
Anyway, while i'm at it. I was wondering how JESS would be suitable for using Time as a fact. I believe jess is not able to respond 100% real-time, so i guess it's useless using time as a fact when testing for changes into seconds... I might be wrong though.
 
 
 


 
2008/5/6 Wolfgang Laun <Wolfgang.Laun@...>:
This Jess snippet will get rid of all your rules and queries

 (bind ?iter ((engine) listDefrules))
 (while (?iter hasNext)
   (bind ?rule (?iter next))
   (undefrule (?rule getName)))

If the object returned from the iterator is instanceof Defrule/Defquery
it is a rule/query, so you could restrict deletions to either subclass.

kr
Wolfgang


ivo jonker wrote:

Hello everyone here at the JESS group!

Is it possible to dispose all defined rules in the current jess
session? (sort of the (reset) for rules.)

The reason i'm asking is that i'd like to be able to refresh the
rule-base during runtime of our application.

Kind regards,
Ivo Jonker




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------




Re: JESS: [JESS]: Removing rules from a session.

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On May 8, 2008, at 9:24 AM, ivo jonker wrote:

> Thanks a lot, this is exactly what i was looking for.
>
> I've just ordered the book: Jess in action and it should arrive  
> shortly. I'm looking forward to it and i know it will be usefull.
>
> Anyway, while i'm at it. I was wondering how JESS would be suitable  
> for using Time as a fact. I believe jess is not able to respond 100%  
> real-time, so i guess it's useless using time as a fact when testing  
> for changes into seconds... I might be wrong though.
>
>


It works fairly well, actually. You have a fact like

(time (seconds 87268726))

and then have a thread, either written in Java or in Jess, which keeps  
a reference to this Fact object and uses Rete.modify() or (modify) to  
update the "seconds" slot periodically. Then your rules can just match  
that slot however they like and when the fact is updated the matches  
are evaluated.


---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 ejfried@...
Livermore, CA 94550                 http://www.jessrules.com




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: [JESS]: Removing rules from a session.

by ivo jonker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I see. That sounds good.
 
Does this mean Jess automatically evaluates the rules when i call the Modify for every second i update the Time?
 

 
2008/5/8 Ernest Friedman-Hill <ejfried@...>:

On May 8, 2008, at 9:24 AM, ivo jonker wrote:

Thanks a lot, this is exactly what i was looking for.

I've just ordered the book: Jess in action and it should arrive shortly. I'm looking forward to it and i know it will be usefull.

Anyway, while i'm at it. I was wondering how JESS would be suitable for using Time as a fact. I believe jess is not able to respond 100% real-time, so i guess it's useless using time as a fact when testing for changes into seconds... I might be wrong though.




It works fairly well, actually. You have a fact like

(time (seconds 87268726))

and then have a thread, either written in Java or in Jess, which keeps a reference to this Fact object and uses Rete.modify() or (modify) to update the "seconds" slot periodically. Then your rules can just match that slot however they like and when the fact is updated the matches are evaluated.


---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 ejfried@...
Livermore, CA 94550                 http://www.jessrules.com





--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------




Re: JESS: [JESS]: Removing rules from a session.

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On May 8, 2008, at 10:03 AM, ivo jonker wrote:

> I see. That sounds good.
>
> Does this mean Jess automatically evaluates the rules when i call  
> the Modify for every second i update the Time?

Pattern matching is driven by working memory changes, and it's very  
smart about what to re-test. That's the whole point of the "Rete  
algorithm" on which Jess is ultimately based. When the time is  
updated, patterns that check the time in some way may be re-evaluated.  
Jess does the minimum possible amount of computation.



>
>
>
> 2008/5/8 Ernest Friedman-Hill <ejfried@...>:
>
> On May 8, 2008, at 9:24 AM, ivo jonker wrote:
>
> Thanks a lot, this is exactly what i was looking for.
>
> I've just ordered the book: Jess in action and it should arrive  
> shortly. I'm looking forward to it and i know it will be usefull.
>
> Anyway, while i'm at it. I was wondering how JESS would be suitable  
> for using Time as a fact. I believe jess is not able to respond 100%  
> real-time, so i guess it's useless using time as a fact when testing  
> for changes into seconds... I might be wrong though.
>
>
>
>
> It works fairly well, actually. You have a fact like
>
> (time (seconds 87268726))
>
> and then have a thread, either written in Java or in Jess, which  
> keeps a reference to this Fact object and uses Rete.modify() or  
> (modify) to update the "seconds" slot periodically. Then your rules  
> can just match that slot however they like and when the fact is  
> updated the matches are evaluated.
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs                FAX:   (925) 294-2234
> PO Box 969, MS 9012                 ejfried@...
> Livermore, CA 94550                 http://www.jessrules.com
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users  
> you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...
> .
> --------------------------------------------------------------------
>
>
>

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 ejfried@...
Livermore, CA 94550                 http://www.jessrules.com




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: [JESS]: Removing rules from a session.

by Henrique Lopes Cardoso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I thought the question was more related with putting the engine to run.
I guess that after each modify a (run) must be invoked.

What about (run-until-halt)? Will rules be evaluated in every working
memory update? What if the time fact update is faster than the
"activation semaphore": would the first modify be lost (in which rules
firing on it is concerned)?

Henrique


Ernest Friedman-Hill wrote:

> On May 8, 2008, at 10:03 AM, ivo jonker wrote:
>
>> I see. That sounds good.
>>
>> Does this mean Jess automatically evaluates the rules when i call the
>> Modify for every second i update the Time?
>
> Pattern matching is driven by working memory changes, and it's very
> smart about what to re-test. That's the whole point of the "Rete
> algorithm" on which Jess is ultimately based. When the time is
> updated, patterns that check the time in some way may be re-evaluated.
> Jess does the minimum possible amount of computation.
>
>
>
>>
>>
>>
>> 2008/5/8 Ernest Friedman-Hill <ejfried@...>:
>>
>> On May 8, 2008, at 9:24 AM, ivo jonker wrote:
>>
>> Thanks a lot, this is exactly what i was looking for.
>>
>> I've just ordered the book: Jess in action and it should arrive
>> shortly. I'm looking forward to it and i know it will be usefull.
>>
>> Anyway, while i'm at it. I was wondering how JESS would be suitable
>> for using Time as a fact. I believe jess is not able to respond 100%
>> real-time, so i guess it's useless using time as a fact when testing
>> for changes into seconds... I might be wrong though.
>>
>>
>>
>>
>> It works fairly well, actually. You have a fact like
>>
>> (time (seconds 87268726))
>>
>> and then have a thread, either written in Java or in Jess, which
>> keeps a reference to this Fact object and uses Rete.modify() or
>> (modify) to update the "seconds" slot periodically. Then your rules
>> can just match that slot however they like and when the fact is
>> updated the matches are evaluated.



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------