RE: JESS: Java 1.5 enums

2007-07-27 Thread Krasnigor, Scott L (N-AST)
I believe you need to surround the enum with ( ), e.g. (property1 
(MyEnum.xyz)). Enums are treated like method calls. The ( ) causes a call to 
your enum class to get the associated value for the enum. Hope this works for 
you.

 

 



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Skeptic 2000
Sent: Thursday, July 26, 2007 11:18 PM
To: jess-users@sandia.gov
Subject: JESS: Java 1.5 enums

 

 
Hi,
 
As shown on JessWiki, I use the import functions to get my enum class in Jess 
:

(import xx.yy.zz.MyEnum)
 
then I try to match a slot of a shadow fact to one of the enum field :

(defrule rule1
(MyShadowFact (OBJECT ?o) (property1 MyEnum.xyz))
= ...
)
 
What I'm doing wrong ?

Thanks.
 
JFL
 
 
 



Soyez parmi les premiers à essayer Windows Live Mail. 
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
 



JESS: modifying facts

2007-07-18 Thread Krasnigor, Scott L (N-AST)
I have track kinematic data in working memory. When a track's kinematics
are updated, I need to modify the associated kinematic data in working
memory. I tried using the add method, however, looking at the watch
statements, new facts were being created instead of modifying the
existing facts. I realized the user is creating new kinematic objects
for each update instead of using existing objects so that I am unable to
use add to update existing kinematic facts in working memory. I am
curious what would be the most efficient way to perform this update.
Thanks for any assistance.

 

Scott



RE: JESS: trying to save a bad CLP file crashes JessDE

2007-05-22 Thread Krasnigor, Scott L (N-AST)
It has happened to me. It is pretty random when it occurs, but I have
experienced eclipse hanging on a save for a .clp file. When I restart
eclipse, the changes were saved so it is more of a annoyance. 

 

Scott L. Krasnigor 
Sr. Principal Engineer/Scientist 
Advanced Sciences  Technologies, LLC. 
Lockheed Martin - MS2 
' 856-359-3094 
* [EMAIL PROTECTED] 
* 780-3 

 



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jason Morris
Sent: Tuesday, May 22, 2007 4:49 AM
To: jess-users@sandia.gov
Subject: JESS: trying to save a bad CLP file crashes JessDE

 

Hi Ernest,

 

When I try to save a CLP file that is in a bad state (not parsing
correctly) JessDE has a pesky propensity to lockup and take down Eclipse
(on my box admittedly) in both 3.2 and 3.2.2 versions.  Version 3.2.2
was worse.  I'm 99% sure it's not the code itself that's doing it.  Take
any valid CLP file of moderate size, whack a ) or two out, let the
parser gag, then try to save and see what happens.  I would expect
JessDE to have the same behavior as Eclipse when editing a bad java
file -- it's not a problem to save it in that state. 

 

Now before you say, Uh, fix the bug first and THEN save let me say
that one of the habits that I've gotten into is to immediately hit
Ctrl+S (Save) whenever: 

 

a) I stop coding to take a break or reflect.

b) Something unexpected happens in my code while coding.

c) Any other error happens that doesn't crash the IDE I'm using at the
time.

 

This habit has saved me thousands of lines of code, so I'm reluctant to
change it.  :-)  This brings up a few things:

 

1) Has this happened to anyone else?  Can anyone reproduce this
phenomenon? (I'll give Ernest the benefit of the doubt, of course).

2) Is there a practical size limit to a CLP file beyond which one
should, as a best practice, break it into smaller files (i.e, by
modules)?

3) Is there a way (or should there be if not) to suspend JessDE parsing
and treat it more like validation which you can toggle on and off?

 

Cheers,

Jason

---
Jason C. Morris
Worcester Polytechnic Institute Phone: (508) 831-5006
Department of Computer Science  FAX:   (508) 831-5776 
Fuller Laboratories - Room 312  [EMAIL PROTECTED]
Artificial Intelligence Lab (AIRG)
100 Institute Road
Worcester, MA 01609-2280
--- 



RE: JESS: how to remove rules from the engine

2007-03-22 Thread Krasnigor, Scott L (N-AST)
You can use (undefrule rule-name) within Jess or
undefrule(rule-name) method contained in the Rete class in java. 

 

 



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Mrinal Khanvilkar
Sent: Thursday, March 22, 2007 1:56 PM
To: jess-users@sandia.gov
Subject: JESS: how to remove rules from the engine

 

hi All,

 

how do you remove the rules from the engine. I have the rule names with
me. Can i retract the rules the same way we retract facts.

if the rules cannot be removed then can we disable them?

 

any suggestions?

 

regards,

Mrinal



JESS: removing modules

2007-03-02 Thread Krasnigor, Scott L (N-AST)
In our application, we are dynamically creating and removing rules from
the engine. We are sent a set of rules that are associated with a
certain module based on parameters passed to us along with the rules. We
are notified when a rule is no longer needed and we remove the rule (or
rules) from the engine. What we would like to do is when a module no
longer contains rules; we want to remove that module from the engine.
I've searched through the documentation/book/api but did not see a way
to remove a module from the engine. I noticed in the mailing list that
someone retrieved an iterator of modules and removed a particular one
from the iterator using iterator.remove(). Is this the best way of
removing modules or is there a more efficient way to accomplish this?
Also, is there a simple way to determine if a module contains any rules?
Thanks for any assistance.

 

Scott

 



RE: JESS: How do I determine Jess engine has finished firing rules

2007-02-09 Thread Krasnigor, Scott L (N-AST)


The easiest thing to do is add a rule with a low salience (I use -1000)
that will always match and add whatever action on the rhs that you want
to use to signal all rules are done being processed. This rule will
always be added to the end of the agenda, so when it fires, you know
there are no more rules waiting to be fired.



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shi Paul
Sent: Friday, February 09, 2007 1:46 PM
To: jess-users@sandia.gov
Subject: Re: JESS: How do I determine Jess engine has finished firing
rules

Hi,
Actually I have created its own thread and then in that thread I call 
rete.runUntilHalt. Then I run into this issue just mentioned, can you
give 
me some more specifics about the solution as how to determin if the
engine 
is not busy and can safely be stopped? I'd imagine that the main thread 
could just wait on some semaphore the jess thread operates or call into
some 
API which does the same thing.

Thanks,
Paul


From: Ernest Friedman-Hill [EMAIL PROTECTED]
Reply-To: jess-users@sandia.gov
To: jess-users@sandia.gov
Subject: Re: JESS: How do I determine Jess engine has finished firing
rules
Date: Fri, 9 Feb 2007 13:19:29 -0500


On Feb 9, 2007, at 12:15 PM, Shi Paul wrote:

Hi there,
Is there an API to determine the rule engine has completed its  work.
I'd 
like to call rete.halt() to stop the engine, but I'm  wondering what
if 
the engine is still firing rules when I call  that. Can anybody shed
some 
lights on it?


Jess doesn't create any threads on its own. If you call rete.run(),
then 
run() returns when, and only when, there are no more rules to  fire. If
you 
have multiple threads, then you can set up your own  notification
scheme 
based on that.


-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


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]



_
http://local.live.com/default.aspx?v=2cp=43.658648~-79.383962style=rl
vl=15tilt=-90dir=0alt=-1000scene=3702663cid=7ABE80D1746919B4!1329


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]



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]




JESS: Decorators

2007-01-18 Thread Krasnigor, Scott L (N-AST)
I am curious what the implications are of defclassing a class with many
decorators associated with it? I need to be able to match various
attributes of the class that are part of the decorators. Is there a
correct/best way to handle this case? Any advice would be appreciated.
Thanks.

 

Scott

 



RE: JESS: Mixing facts from Java and Jess script

2006-12-19 Thread Krasnigor, Scott L (N-AST)
He does close it on the third line, but that is what the problem is. The
way the rule is defined below, the mon template should contain slots for
reading, tstamp and posLshift. However, based on the error, the mon
template generated by the defclass call does not contain the posLshift
slot. So the last close-parenthesis after the posLshift line needs to be
placed after the tstamp slot (assuming tstamp is part of the mon
template). This will associate the reading and tstamp slots with the mon
template and the truth_val slot with the posLshift template.


Scott

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of J Michael Dean
Sent: Tuesday, December 19, 2006 10:06 AM
To: jess-users@sandia.gov
Subject: Re: JESS: Mixing facts from Java and Jess script

But I think he closes this on the third line.

On Dec 18, 2006, at 9:11 PM, Ernest Friedman-Hill wrote:

 On Dec 18, 2006, at 10:13 PM, Mike Stacey wrote:


 (defrule TA::Initiates
  (mon (reading ?r:(= ?r 143))
  (tstamp ?t:( ?t 0))
  (posLshift (truth_val false)))
  =
  (assert posLshift(truth_val 1))
  (printout t Initiates: Data ?r bpm, timestamp ?t, Fluent truth
 count:crlf))


 Error is:

 Jess reported an error in routine Jesp.parsePattern
 while executing (batch rules/ec-1.clp).
 Message: No such slot posLshift in template MAIN::mon at token
 'posLshift'.


 There's a missing close-parenthesis on the first line (three open,  
 only two close) so Jess thinks you mean to test the contents of the  
 tstamp and posLshift slots in a mon fact.

 The JessDE is pretty good at helping you spot this sort of problem.  
 Besides formatting your code so that your errors are more obvious,  
 this kind of error will lead to a train wreck with all sorts of  
 error markers from this point on in the file, giving you a strong  
 hint that something is wrong. If you can't use the JessDE, use the  
 Lisp mode in any programmer's editor -- it will know how to format  
 Jess code to point out this error.

 -
 Ernest Friedman-Hill
 Advanced Software Research  Phone: (925) 294-2154
 Sandia National LabsFAX:   (925) 294-2234
 PO Box 969, MS 9012 [EMAIL PROTECTED]
 Livermore, CA 94550 http://www.jessrules.com
 
 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 owner-jess- 
 [EMAIL PROTECTED]
 


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]


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: Fact object not in working memory error

2006-08-31 Thread Krasnigor, Scott L (N-AST)








My guess would be that the Focus is in MAIN (or some other module that you might have defined) and
not in STATE-CLEANUP where the fact resides (I am assuming that the fact
resides in STATE_CLEANUP since that is where the rule that caused the error
resides). Do a (watch focus) to see where the focus is at the
time of the error.



Scott





Scott L. Krasnigor 
Principal
Engineer/Scientist 
Advanced
Sciences  Technologies, LLC. 
Lockheed Martin
- MS2 
' 856-359-3094 
* [EMAIL PROTECTED] 
* 780-3 













From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hasan Khan
Sent: Thursday, August 31, 2006
12:07 PM
To: jess-users@sandia.gov
Subject: JESS: Fact object not in
working memory error





Hello,

I get the following error when trying to execute the code:



(defrule STATE-CLEANUP::Clean2 remove all facts
generated for a pid

 (declare (salience -508))

 ?f1 -
(MAIN::domain-state-req-cleanup(pid ?pid))

 ?f2 - (STATE-PROCESSING::valid-action(pid
?pid))


=

 (modify ?f2 (object nil))

 (retract ?f2)

 )

The stack trace of the error is:



Caused by: Jess reported an error in routine modify


while executing (modify ?f2 (object nil))


while executing defrule STATE-CLEANUP::Clean2.

 Message: Fact object not in working memory
(STATE-PROCESSING::valid-action (oid 17449694) (pid gen113) (object
Java-Object:fleetcycle.domain.es.taskCardAssignment.TaskCardGroupAssignment)
(action taskCardAssignment.removeTaskCardGroupAssignment) (name
removeTaskCardGroupAssignment) (allowed TRUE) (parentState nil)
(validationErrors nil)).


at jess.FactList.modifyRegularFact(FactList.java:306)


at jess.FactList.modify(FactList.java:242)


at jess.Rete.modify(Rete.java:492)


at jess.Modify.call(Modify.java:31)


at jess.FunctionHolder.call(FunctionHolder.java:31)


at jess.Funcall.execute(Funcall.java:257)


at jess.Defrule.fire(Defrule.java:252)


at jess.Activation.fire(Activation.java:84)


at jess.Agenda.run(Agenda.java:259)


at jess.Agenda.run(Agenda.java:235)


at jess.Rete.run(Rete.java:1360)


at fleetcycle.model.framework.rules.RulesProcessCleanup.cleanUp(RulesProcessCleanup.java:42)



Any help would be really appreciated.

Thanks

Hasan











Confidentiality Notice:
**
This E-mail and any attachments thereto, are intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information. If you are not the intended recipient of this E-mail,
you are hereby notified any dissemination, distribution or copying of this
E-mail, and any attachments thereto, is strictly prohibited. If you receive
this E-mail in error, please immediately notify me by reply E-mail or telephone
at (218) 723-7887 and permanently delete the original and any copy of this
E-mail, and any printout thereof. 










RE: JESS: Help with error

2006-06-22 Thread Krasnigor, Scott L (N-AST)
Not a problem. Is there a simple fix I can implement. I am trying to
prototype a failover capability and I am dead in the water without the
bsave/bload functionality working. I have the source code. I will be
happy to figure out a temporary fix if you can just point me in the
right direction. Thanks.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of friedman_hill ernest j
Sent: Thursday, June 22, 2006 9:43 AM
To: jess-users@sandia.gov
Subject: Re: JESS: Help with error

I think Krasnigor, Scott L (N-AST) wrote:
 I am getting the following exception when trying to do a bsave. It is 
 occurring when the bsave method is executing oss.writeObject(m_rules).

 I don't understand what could be causing this and am looking for any 
 insight into the issue. I am running Jess version 70b7 from a java 
 application. I will be happy to provide more detail if needed. Thanks.

Looks like this is caused by new rules being activated during the call
to bsave, presumably because working memory is being modified on
another thread. I'm surprised this has never come up before, because
thinking of it, it seems that bsave() should probably lock the agenda
and working memory while it runs -- but it does not. Thanks for
reporting this.



 
 Jess reported an error in routine bsave
   while executing (bsave enginedata).
   Message: Error during execution.
   Program text: ( bsave enginedata )  at line 1.
   at jess.Funcall.execute(Funcall.java:328)
   at jess.Jesp.parseAndExecuteFuncall(Jesp.java:2261)
   at jess.Jesp.parseExpression(Jesp.java:436)
   at jess.Jesp.promptAndParseOneExpression(Jesp.java:291)
   at jess.Jesp.parse(Jesp.java:270)
   at jess.Rete.eval(Rete.java:2051)
   at jess.Rete.eval(Rete.java:2006)
   at control.Controller.run(Controller.java:67)
   at java.lang.Thread.run(Unknown Source) Caused by: 
 java.util.ConcurrentModificationException
   at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
   at java.util.HashMap$EntryIterator.next(Unknown Source)
   at java.util.HashMap$EntryIterator.next(Unknown Source)
   at java.util.HashMap.writeObject(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
 Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
   at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
   at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown
 Source)
   at java.io.ObjectOutputStream.writeObject0(Unknown Source)
   at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
   at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
   at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown
 Source)
   at java.io.ObjectOutputStream.writeObject0(Unknown Source)
   at java.io.ObjectOutputStream.writeObject(Unknown Source)
   at java.util.TreeMap.writeObject(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
 Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
   at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
   at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown
 Source)
   at java.io.ObjectOutputStream.writeObject0(Unknown Source)
   at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
   at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
   at java.util.Collections$SynchronizedMap.writeObject(Unknown
 Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
 Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
   at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
   at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown
 Source)
   at java.io.ObjectOutputStream.writeObject0(Unknown Source)
   at java.io.ObjectOutputStream.writeObject(Unknown Source)
   at jess.Rete.bsave(Rete.java:1768)
   at jess.Dumper.call(DumpFunctions.java:43)
   at jess.FunctionHolder.call(FunctionHolder.java:31)
   at jess.Funcall.execute(Funcall.java:320)
   ... 8 more
 
 Scott L. Krasnigor
 Principal Engineer/Scientist
 Advanced Sciences  Technologies, LLC.
 Lockheed Martin - MS2
 ' 856-359-3094
 * [EMAIL PROTECTED]
 * 780-1A
 



-
Ernest Friedman

JESS: Bload question

2006-01-19 Thread Krasnigor, Scott L (N-AST)
Title: Bload question






I performed a bsave from an engine that contains only shadow facts (and some simple rules). If I do a bload with that file into a new engine, are the facts that are loaded via the bload command remain shadow facts? Or do I need to re-definstance them in order to see modifications to the facts in working memory from my java app? Thanks.

Scott






RE: JESS: Jess70b5 and Eclipse 3.1.1

2006-01-10 Thread Krasnigor, Scott L (N-AST)
Did you try to run eclipe with -clean after extracting the files? This worked 
for me. 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jean-Frangois 
Lebeau
Sent: Tuesday, January 10, 2006 2:32 PM
To: jess-users@sandia.gov
Subject: JESS: Jess70b5 and Eclipse 3.1.1

Hi,

I'm a new JESS user, I'm trying to install the eclipse plug-in of Jess70b5 into 
Eclipse 3.1.1 and it doesn't seem to work. (Nothing new after I extract the 
files and I run eclipse again).

Is there a version issue here ?

Thanks for help.

Jean-Frangois Lebeau
Universiti of Sherbrooke, Qc, Canada.


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]




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]




JESS: Modifying JavaBeans

2005-08-31 Thread Krasnigor, Scott L (N-AST)
Title: Modifying JavaBeans






Sorry to bother everyone. I am trying to play around with JESS embedded in Java to get an understanding of JESS. I created a simple Java bean which contains two properties: range and qualRng. I create the fact within Jess utilizing defclass and definstance. Executing engine.facts() shows that the fact has been created in Jess's memory with the appropriate slots. I created a simple rule to check to see if range is below 20, if true, modify the qualRng slot to TRUE. I added code to main() decrement the initial value of range in order to fire the rule. Watching the results shows that the range slot decrements properly and the rule fires, but the qualRng field never gets updated to show TRUE. I am sure it is something simple, but I just don't see the problem. I've modified the RHS of the rule with all the different iterations I could think of but to no avail. The code is listed below (minus the java bean class). Thanks for your assistance.

import jess.*;


public class testFacts 

{

 public static void main(String[] args) 

 {

  Value fact;

  try

  {

   Rete engine = new Rete();

   engine.watchAll();


   engine.defclass(testTrkClass, testTrack, null);

   testTrack trkOne = new testTrack(30, 45, 5);

   fact = engine.definstance(testTrkClass, trkOne, true);

   

   // Load rules clip file

   engine.executeCommand((batch testTrk.clp));

   engine.run();

   

   // change range until it triggers a dummy doct rule


   int i;

   for(i = trkOne.getRange(); i  5; i--)

   {

trkOne.setRange(i);

try 

{

 Thread.sleep(500);

}

catch (InterruptedException ie){}

   }

  }

  catch (JessException je)

  {

   System.out.print(An error occurred at line  + je.getLineNumber());

   System.out.println( which looks like  + je.getProgramText());

   System.out.println(Message:  + je.getMessage());

  }

 }


}


The clp file:


(defrule dummy-range-doctrine

 ;; set qualRng to true if trk is in range

 ?fact - (testTrkClass (range ?x:(= ?x 20)))

 =

 (modify ?fact (qualRng TRUE)))




Scott L. Krasnigor

Principal Engineer/Scientist

Atlantic Science  Technology

Lockheed Martin - MS2

' 856-359-3094

* [EMAIL PROTECTED]

* 770-2





RE: JESS: Modifying JavaBeans

2005-08-31 Thread Krasnigor, Scott L (N-AST)
Thanks. Works like a champ. I had a feeling that it was something
simple. 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, August 31, 2005 1:31 PM
To: jess-users@sandia.gov
Subject: Re: JESS: Modifying JavaBeans

Hi Scott, 

Rules only fire during a call to run(). Your call to run() returns
immediately because when you call it, there are no rules eligible to
fire yet. Then you make some changes to the fact, and the
PropertyChangeEvents update the working memory, but you never call
run() again, so even when it is activated, the rule never fires.

You could call run() in your for loop, and then the rule would fire and
update the slot as expected. Note that it makes sense for this rule to
fire only once -- no reason to fire once the qualRng slot is TRUE, so
you might write the pattern like this:


 (defrule dummy-range-doctrine
 ;; set qualRng to true if trk is in range
 ?fact - (testTrkClass (range ?x:(= ?x 20)) (qualRng ~TRUE))
 =
 (modify ?fact (qualRng TRUE)))


I think Krasnigor, Scott L (N-AST) wrote:
 Sorry to bother everyone. I am trying to play around with JESS 
 embedded in Java to get an understanding of JESS. I created a simple 
 Java bean which contains two properties: range and qualRng. I create 
 the fact within Jess utilizing defclass and definstance. Executing 
 engine.facts() shows that the fact has been created in Jess's memory 
 with the appropriate slots. I created a simple rule to check to see if

 range is below 20, if true, modify the qualRng slot to TRUE. I added 
 code to
 main() decrement the initial value of range in order to fire the rule.
 Watching the results shows that the range slot decrements properly and

 the rule fires, but the qualRng field never gets updated to show TRUE.

 I am sure it is something simple, but I just don't see the problem. 
 I've modified the RHS of the rule with all the different iterations I 
 could think of but to no avail. The code is listed below (minus the 
 java bean class). Thanks for your assistance.
 
 import jess.*;
 
 public class testFacts
 {
   public static void main(String[] args) 
   {
   Value fact;
   try
   {
   Rete engine = new Rete();
   engine.watchAll();
 
   engine.defclass(testTrkClass, testTrack,
null);
   testTrack trkOne = new testTrack(30, 45, 5);
   fact = engine.definstance(testTrkClass,
 trkOne, true);
   
   // Load rules clip file
   engine.executeCommand((batch testTrk.clp));
   engine.run();
   
   // change range until it triggers a dummy doct
rule
 
   int i;
   for(i = trkOne.getRange(); i  5; i--)
   {
   trkOne.setRange(i);
   try 
   {
   Thread.sleep(500);
   }
   catch (InterruptedException ie){}
   }
   }
   catch (JessException je)
   {
   System.out.print(An error occurred at line  + 
 je.getLineNumber());
   System.out.println( which looks like  +
je.getProgramText());
   System.out.println(Message:  +
 je.getMessage());
   }
   }
 
 }
 
 The clp file:
 
 (defrule dummy-range-doctrine
 ;; set qualRng to true if trk is in range
 ?fact - (testTrkClass (range ?x:(= ?x 20)))
 =
 (modify ?fact (qualRng TRUE)))
 
 
 
 Scott L. Krasnigor
 Principal Engineer/Scientist
 Atlantic Science  Technology
 Lockheed Martin - MS2
 ' 856-359-3094
 * [EMAIL PROTECTED]
 * 770-2
 



-
Ernest Friedman-Hill  
Advanced Software Research  Phone: (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]



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]