JESS: problems when using a clear

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

JESS: problems when using a clear

by Joao Carlos Mourao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm trying to implement a method to restart the rule engine by using the
clear command. The idea is before running, clear everything (using
clear), add all the facts available, and run the engine with the command
(run-until-halt). Although, every time i make use of clear command, the
rule engine blocks, and even if i insert new rules or facts, no rule
becomes active, its seems that is blocked. The procedure that i follow
is with two functions, start and stop, like following:

start:
    (clear)
    (insert-rules-and-templates-using-batch)
    (reset)
    (run-until-halt)
    (start-thread-for-inserting-shadow-facts)

stop:
    (halt)

Can anyone tell me what i'm doing wrong?

Thanks in advance,

Joao

------------------------
unclassified


------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it.
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden.
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s).
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------


begin:vcard
fn;quoted-printable:Jo=C3=A3o Mour=C3=A3o
n;quoted-printable;quoted-printable:Mour=C3=A3o;Jo=C3=A3o
org:Thales;Above Water Systems
adr:;;;Hengelo;;;Netherlands
email;internet:joao.mourao@...
title:THALES NETHERLANDS B.V.
tel;work:2640
note:-unclassified mail-
version:2.1
end:vcard


RE: JESS: problems when using a clear

by LAUN, Wolfgang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Run-until-halt remains running until some code on some RHS (or in
another thread, maybe) calls halt. So, it would be better to start the
thread-for-inserting-shadow-facts before the run-until-halt call.

-W

-----Original Message-----
From: owner-jess-users@... [mailto:owner-jess-users@...]
On Behalf Of Joao Carlos Mourao
Sent: Dienstag, 18. August 2009 09:41
To: jess-users@...
Subject: JESS: problems when using a clear

Hello,

I'm trying to implement a method to restart the rule engine by using the
clear command. The idea is before running, clear everything (using
clear), add all the facts available, and run the engine with the command
(run-until-halt). Although, every time i make use of clear command, the
rule engine blocks, and even if i insert new rules or facts, no rule
becomes active, its seems that is blocked. The procedure that i follow
is with two functions, start and stop, like following:

start:
    (clear)
    (insert-rules-and-templates-using-batch)
    (reset)
    (run-until-halt)
    (start-thread-for-inserting-shadow-facts)

stop:
    (halt)

Can anyone tell me what i'm doing wrong?

Thanks in advance,

Joao

------------------------
unclassified


------------------------------------------------------------------------
------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the
sender and delete it.
Any unauthorized copying, disclosure or distribution of this email or
its attachment(s) is forbidden.
Thales Nederland BV will not accept liability for any damage caused by
this email or its attachment(s).
Thales Nederland BV is seated in Hengelo and is registered at the
Chamber of Commerce under number 06061578.
------------------------------------------------------------------------
------------------------------------



--------------------------------------------------------------------
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: problems when using a clear

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Based just on this pseudocode, the two things I can say is that after  
the call to (clear), if the function "insert-rules-and-templates-using-
batch" were a deffunction, it would be undefined; same for "start-
thread-for-inserting-shadow-facts". Also, it seems odd that you're  
running the engine with run-until-halt before adding your facts on the  
next line; normally you'd want to do that in the other order.  But as  
I said, since this isn't real code, it's hard to say what's wrong.  
"clear", in general, should return the Jess engine to its initial  
state, and everything should continue to work fine after that (except  
that everything previously defined is gone, of course.)



On Aug 18, 2009, at 3:41 AM, Joao Carlos Mourao wrote:

> Hello,
>
> I'm trying to implement a method to restart the rule engine by using  
> the
> clear command. The idea is before running, clear everything (using
> clear), add all the facts available, and run the engine with the  
> command
> (run-until-halt). Although, every time i make use of clear command,  
> the
> rule engine blocks, and even if i insert new rules or facts, no rule
> becomes active, its seems that is blocked. The procedure that i follow
> is with two functions, start and stop, like following:
>
> start:
>    (clear)
>    (insert-rules-and-templates-using-batch)
>    (reset)
>    (run-until-halt)
>    (start-thread-for-inserting-shadow-facts)
>
> stop:
>    (halt)
>
> Can anyone tell me what i'm doing wrong?
>
> Thanks in advance,
>
> Joao
>
> ------------------------
> unclassified
>

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, 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: problems when using a clear

by Joao Carlos Mourao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ernest Friedman-Hill wrote: "if the function
"insert-rules-and-templates-using-batch" were a deffunction, it would be
undefined"

The insert-rules-and-templates-using-batch is a clp file containing
templates, rules, queries, deffuctions (why not), everything that i need
to have in my knowledge system. I inserted using the batch function
(seems pretty clear this lines to me).

Ernest Friedman-Hill wrote: "Also, it seems odd that you're running the
engine with run-until-halt before adding your facts on the next line;
normally you'd want to do that in the other order."

Not in this case Ernest, my facts are not coming from the program but
from external source, and the idea is as new data arrives (shadow
facts), start to reason about it (it like a pooling process, when
something arrives i dispatch it to the rule-based system). New facts are
constantly arrived to the program, so i prefer to load everything before
i start the process of subscribing the program input.

Unfortunately i cannot send you the code, but i can explain better.
-> when i use (clear) the rule based engine gets clean of every fact,
rules, etc, which is ok;
-> then i insert the templates and rules, using the batch call, and i
can see that everything gets loaded in the system (again ok);
->the problem comes in the agenda, i was expecting when i do
(run-until-halt) the system will start to reason about the facts (which
are inserted parallel, but - i checked - are correctly inserted), but
instead nothing happens. It seems that the (run-until-halt) as no
effect. The agenda is empty, and no rule is active.

Other important note is that when i don't use clear, and just start the
system from scratch (batch - reset - and run-until-halt), the rule-based
system works perfectly. The problem arises when i put a clear in the
beginning of the chain process.

My version of jess is 7.1p2, i was working with the 7.0 but i changed on
hope to solve this problem. Still remains.

Regards,

Joao




On 18-08-2009 15:05, Ernest Friedman-Hill wrote:

> Based just on this pseudocode, the two things I can say is that after
> the call to (clear), if the function
> "insert-rules-and-templates-using-batch" were a deffunction, it would
> be undefined; same for "start-thread-for-inserting-shadow-facts".
> Also, it seems odd that you're running the engine with run-until-halt
> before adding your facts on the next line; normally you'd want to do
> that in the other order.  But as I said, since this isn't real code,
> it's hard to say what's wrong. "clear", in general, should return the
> Jess engine to its initial state, and everything should continue to
> work fine after that (except that everything previously defined is
> gone, of course.)
>
>
>
> On Aug 18, 2009, at 3:41 AM, Joao Carlos Mourao wrote:
>
>> Hello,
>>
>> I'm trying to implement a method to restart the rule engine by using the
>> clear command. The idea is before running, clear everything (using
>> clear), add all the facts available, and run the engine with the command
>> (run-until-halt). Although, every time i make use of clear command, the
>> rule engine blocks, and even if i insert new rules or facts, no rule
>> becomes active, its seems that is blocked. The procedure that i follow
>> is with two functions, start and stop, like following:
>>
>> start:
>>    (clear)
>>    (insert-rules-and-templates-using-batch)
>>    (reset)
>>    (run-until-halt)
>>    (start-thread-for-inserting-shadow-facts)
>>
>> stop:
>>    (halt)
>>
>> Can anyone tell me what i'm doing wrong?
>>
>> Thanks in advance,
>>
>> Joao
>>
>> ------------------------
>> unclassified
>>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, 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@....
> --------------------------------------------------------------------
>

------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it.
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden.
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s).
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------


begin:vcard
fn;quoted-printable:Jo=C3=A3o Mour=C3=A3o
n;quoted-printable;quoted-printable:Mour=C3=A3o;Jo=C3=A3o
org:Thales;Above Water Systems
adr:;;;Hengelo;;;Netherlands
email;internet:joao.mourao@...
title:THALES NETHERLANDS B.V.
tel;work:2640
note:-unclassified mail-
version:2.1
end:vcard


Re: JESS: problems when using a clear

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Aug 20, 2009, at 4:24 AM, Joao Carlos Mourao wrote:

>
> Other important note is that when i don't use clear, and just start  
> the
> system from scratch (batch - reset - and run-until-halt), the rule-
> based
> system works perfectly. The problem arises when i put a clear in the
> beginning of the chain process.
>



Well, putting aside the problem that "(start-thread-for-inserting-
shadow-facts)" should never be called, let me ask you this: what is  
the "clear" for? What is defined before the "clear", and why do you  
need to clear it? And are you absolutely sure that you're restoring  
everything that needs to be restored after the "clear?"



---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, 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: problems when using a clear

by Joao Carlos Mourao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The clear is used for running the system multiple times. For example,
the user starts the program, gets his results, and then wants to repeat
the process (maybe with other input data). I want to ensure that
everything from the last use gets clean. That's why i need a clear.
In the current version, the user will have to restart the application,
because there is information in the working memory that will probably
make conflicts with the new data (and we don't want that).
But this is not even important. Doesn't matter if i need to use, or i
have to use it, i simply wanna use it, and since is an available jess
command, why not? The question to make is: why when i use a clear
statement the system doesn't work, and if i don't use it works perfectly?

Also I don't understand where is the big problem for inserting shadow
facts through a concurrent thread. The rules, templates and functions
are loaded into jess. I want to insert facts (shadow facts), and see
what results i get. I really don't see anything awkward.

Some people had contact me in order to get more information about how i
implement the process. Here it goes some more information:

- My rete is a java object, using jessWin.getRete().
- I load the templates and rules through the batch function, using
rete.batch("file.clp).
- I also use the clear through the rete interface, like rete.clear().
- For run-until-halt, i use the function eval from rete, like:
rete.eval("(run-until-halt)") -> this is executed in a separated thread.

The stopping part is not important for now, since i get the error when i
tried to run jess.

Regard,

Joao

-unclassified


On 20-08-2009 15:09, Ernest Friedman-Hill wrote:

> On Aug 20, 2009, at 4:24 AM, Joao Carlos Mourao wrote:
>
>>
>> Other important note is that when i don't use clear, and just start the
>> system from scratch (batch - reset - and run-until-halt), the rule-based
>> system works perfectly. The problem arises when i put a clear in the
>> beginning of the chain process.
>>
>
>
>
> Well, putting aside the problem that
> "(start-thread-for-inserting-shadow-facts)" should never be called,
> let me ask you this: what is the "clear" for? What is defined before
> the "clear", and why do you need to clear it? And are you absolutely
> sure that you're restoring everything that needs to be restored after
> the "clear?"
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, 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@....
> --------------------------------------------------------------------
>

------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it.
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden.
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s).
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------


begin:vcard
fn;quoted-printable:Jo=C3=A3o Mour=C3=A3o
n;quoted-printable;quoted-printable:Mour=C3=A3o;Jo=C3=A3o
org:Thales;Above Water Systems
adr:;;;Hengelo;;;Netherlands
email;internet:joao.mourao@...
title:THALES NETHERLANDS B.V.
tel;work:2640
note:-unclassified mail-
version:2.1
end:vcard


Re: JESS: problems when using a clear

by JimYates :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Why not use a marker and then a reset.  This will clear all facts asserted since the marker was set.  

On Thu, Aug 20, 2009 at 9:12 AM, Joao Carlos Mourao <joao.mourao@...> wrote:
The clear is used for running the system multiple times. For example, the user starts the program, gets his results, and then wants to repeat the process (maybe with other input data). I want to ensure that everything from the last use gets clean. That's why i need a clear.
In the current version, the user will have to restart the application, because there is information in the working memory that will probably make conflicts with the new data (and we don't want that).
But this is not even important. Doesn't matter if i need to use, or i have to use it, i simply wanna use it, and since is an available jess command, why not? The question to make is: why when i use a clear statement the system doesn't work, and if i don't use it works perfectly?

Also I don't understand where is the big problem for inserting shadow facts through a concurrent thread. The rules, templates and functions are loaded into jess. I want to insert facts (shadow facts), and see what results i get. I really don't see anything awkward.

Some people had contact me in order to get more information about how i implement the process. Here it goes some more information:

- My rete is a java object, using jessWin.getRete().
- I load the templates and rules through the batch function, using rete.batch("file.clp).
- I also use the clear through the rete interface, like rete.clear().
- For run-until-halt, i use the function eval from rete, like: rete.eval("(run-until-halt)") -> this is executed in a separated thread.

The stopping part is not important for now, since i get the error when i tried to run jess.

Regard,

Joao

-unclassified


On 20-08-2009 15:09, Ernest Friedman-Hill wrote:
On Aug 20, 2009, at 4:24 AM, Joao Carlos Mourao wrote:


Other important note is that when i don't use clear, and just start the
system from scratch (batch - reset - and run-until-halt), the rule-based
system works perfectly. The problem arises when i put a clear in the
beginning of the chain process.




Well, putting aside the problem that "(start-thread-for-inserting-shadow-facts)" should never be called, let me ask you this: what is the "clear" for? What is defined before the "clear", and why do you need to clear it? And are you absolutely sure that you're restoring everything that needs to be restored after the "clear?"



---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, 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@....
--------------------------------------------------------------------



------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------



Re: JESS: problems when using a clear

by Joao Carlos Mourao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Jim, I had this in mine too. Although, since i started to use
clear, and it is not working, i wanted to know why is not working,
because maybe there is a bug, or something wrong with the procedure that
i make, and i would like to understand the problem (i suppose the
philosophy of an engineer is to understand the thing in the complete
way, not just to say that like this works and like this doesn't work).
Even for jess community will be good understand why this kind of things
don't work. Maybe, still is summer season, this also probably
explains... Anyway, i will not insist more.

But thanks again for the advice, regards,

Joao

On 20-08-2009 17:37, Jim Yates wrote:

> Why not use a marker and then a reset.  This will clear all facts
> asserted since the marker was set.  
>
> On Thu, Aug 20, 2009 at 9:12 AM, Joao Carlos Mourao
> <joao.mourao@...
> <mailto:joao.mourao@...>> wrote:
>
>     The clear is used for running the system multiple times. For
>     example, the user starts the program, gets his results, and then
>     wants to repeat the process (maybe with other input data). I want
>     to ensure that everything from the last use gets clean. That's why
>     i need a clear.
>     In the current version, the user will have to restart the
>     application, because there is information in the working memory
>     that will probably make conflicts with the new data (and we don't
>     want that).
>     But this is not even important. Doesn't matter if i need to use,
>     or i have to use it, i simply wanna use it, and since is an
>     available jess command, why not? The question to make is: why when
>     i use a clear statement the system doesn't work, and if i don't
>     use it works perfectly?
>
>     Also I don't understand where is the big problem for inserting
>     shadow facts through a concurrent thread. The rules, templates and
>     functions are loaded into jess. I want to insert facts (shadow
>     facts), and see what results i get. I really don't see anything
>     awkward.
>
>     Some people had contact me in order to get more information about
>     how i implement the process. Here it goes some more information:
>
>     - My rete is a java object, using jessWin.getRete().
>     - I load the templates and rules through the batch function, using
>     rete.batch("file.clp).
>     - I also use the clear through the rete interface, like rete.clear().
>     - For run-until-halt, i use the function eval from rete, like:
>     rete.eval("(run-until-halt)") -> this is executed in a separated
>     thread.
>
>     The stopping part is not important for now, since i get the error
>     when i tried to run jess.
>
>     Regard,
>
>     Joao
>
>     -unclassified
>
>
>     On 20-08-2009 15:09, Ernest Friedman-Hill wrote:
>
>         On Aug 20, 2009, at 4:24 AM, Joao Carlos Mourao wrote:
>
>
>             Other important note is that when i don't use clear, and
>             just start the
>             system from scratch (batch - reset - and run-until-halt),
>             the rule-based
>             system works perfectly. The problem arises when i put a
>             clear in the
>             beginning of the chain process.
>
>
>
>
>         Well, putting aside the problem that
>         "(start-thread-for-inserting-shadow-facts)" should never be
>         called, let me ask you this: what is the "clear" for? What is
>         defined before the "clear", and why do you need to clear it?
>         And are you absolutely sure that you're restoring everything
>         that needs to be restored after the "clear?"
>
>
>
>         ---------------------------------------------------------
>         Ernest Friedman-Hill
>         Informatics & Decision Sciences, Sandia National Laboratories
>         PO Box 969, MS 9012, Livermore, CA 94550
>         http://www.jessrules.com
>
>
>
>
>
>
>
>         --------------------------------------------------------------------
>         To unsubscribe, send the words 'unsubscribe jess-users
>         you@... <mailto:you@...>'
>         in the BODY of a message to majordomo@...
>         <mailto:majordomo@...>, NOT to the list
>         (use your own address!) List problems? Notify
>         owner-jess-users@... <mailto:owner-jess-users@...>.
>         --------------------------------------------------------------------
>
>
>
>     ------------------------------------------------------------------------------------------------------------
>     Disclaimer:
>
>     If you are not the intended recipient of this email, please notify
>     the sender and delete it. Any unauthorized copying, disclosure or
>     distribution of this email or its attachment(s) is forbidden.
>     Thales Nederland BV will not accept liability for any damage
>     caused by this email or its attachment(s). Thales Nederland BV is
>     seated in Hengelo and is registered at the Chamber of Commerce
>     under number 06061578.
>     ------------------------------------------------------------------------------------------------------------
>
>

------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it.
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden.
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s).
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------


begin:vcard
fn;quoted-printable:Jo=C3=A3o Mour=C3=A3o
n;quoted-printable;quoted-printable:Mour=C3=A3o;Jo=C3=A3o
org:Thales;Above Water Systems
adr:;;;Hengelo;;;Netherlands
email;internet:joao.mourao@...
title:THALES NETHERLANDS B.V.
tel;work:2640
note:-unclassified mail-
version:2.1
end:vcard


Re: JESS: problems when using a clear

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 21, 2009, at 5:29 AM, Joao Carlos Mourao wrote:

> Thanks Jim, I had this in mine too. Although, since i started to use
> clear, and it is not working, i wanted to know why is not working,
> because maybe there is a bug, or something wrong with the procedure  
> that
> i make, and i would like to understand the problem (i suppose the
> philosophy of an engineer is to understand the thing in the complete
> way, not just to say that like this works and like this doesn't work).



I totally agree -- I like to get to the bottom of things, which is why  
I was asking questions about the real application. In general, of  
course, "clear" clears everything, and it works fine. It's probably  
clearing too much for your application, which is where the problem is  
coming in -- i.e., after the "clear", something is disconnected that  
was set up at the beginning of your application; for example, the  
event mask, or some listeners, or routers, or something. That's why  
typically people don't use "clear" here: working memory markers would  
serve, as one person suggested, or otherwise "(undefinstance *)"  
followed by a full reset to remove all your facts.


---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, 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@....
--------------------------------------------------------------------