Re: JESS: Java objects

2007-08-22 Thread Wolfgang Laun

Noel Huebers wrote

 (defquery searchcontext
   (declare (variables ?name ?task ?val))
   (context
(username ?name)
(action Bewertet)
(task ?task)
(value ?val)))

 Now I want to delete the some facts. How do I get a fact from the
 queryresult '?result' ?

 ;(deffunction delformerattempts(?n ?t ?v)
 ;(bind ?results (run-query* searchcontext ?n ?t ?v))
 ;(while (?results next))
 ;(retract ?results get))


All you have to do is extend the pattern in the query with a binding for 
the entire fact:


(defquery searchcontext
  (declare (variables ?name ?task ?val))
  ?context - (context
  (username ?name)
  (action Bewertet)
  (task ?task)
  (value ?val)))

And then you access it with the get method:
(deffunction delformerattempts (?n ?t ?v)
   (bind ?results (run-query* searchcontext ?n ?t ?v))
   (while (?results next)
 (retract (?results get context 

But wouldn't it be more convenient to rearrange things so that the 
context fact maintains a counter, with new Bewertet events being 
counted right there. Here's how:


(clear)

(deftemplate Base   (slot username)(slot action)(slot value)(slot task))
(deftemplate Context extends Base (slot count (default 1)))
(deftemplate Event   extends Base (slot stamp ))

(defrule IncrementCount
   ?event - (Event (username ?s)(action Bewertet)(value ?v)(task ?t))
   ?context - (Context (username ?s)(action Bewertet)(value ?v)(task 
?t)(count ?c))

   =
   (modify ?context (count (++ ?c)))
   (retract ?event)
)

(defrule FirstTime
   ?event - (Event (username ?s)(action Bewertet)(value ?v)(task ?t))
   (not (Context (username ?s)(action Bewertet)(value ?v)(task ?t)))
   =
   (assert (Context (username ?s)(action Bewertet)(value ?v)(task ?t)))
   (retract ?event)
)

(deffacts ecs
   (Event (username Max)(action Bewertet)(value 3)(task 
Thesis)(stamp 1))
   (Event (username Max)(action Bewertet)(value 3)(task 
Thesis)(stamp 2))
   (Event (username Max)(action Bewertet)(value 3)(task 
Thesis)(stamp 3))

)

(reset)
(run)

kr
Wolfgang





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: Java objects

2007-08-20 Thread Wolfgang Laun

Noël Huebers wrote:


Hi,

I'm new to the Jess language and have some questions.

1. I work with Java object. I stored them in Jess with store and
assert/fetch commands.
But I could not call there member in the lhs of my rule. No function calls
allowed, right? So, for every object I made a rule to insert a Jess
template. This works fine, but is this way of mapping Java objects to Jess
facts and then discarding the object the best way to work with java objects?
 

store and fetch are just a way of storing and retrieving arbitrary data. 
If you want to use Java objects in rules, look into the topic of shadow 
facts, see section 5.3. Shadow facts: reasoning about Java objects.



2. I am trying to implement a counter-logic for specific slot combinations.
First, everytime a fact is inserted I check if there is already a procounter
fact. If not I create one. This works fine. The next rule should recognize
when a fact (EContext) is inserted and the counter (procounter) already
exists. In this case, the count slot should only be modified. I try to
compare bounded vars ?s ?v ?t from EContext to procounter slots, but I think
Jess simply overwrites the binding. Can you help me with the correct syntax?
Is there a better logic to implement a counter?

If you have one fact (EContext (studentname Max) (action 
bewertet)(value 3)(task Thesis)) it won't be possible to ever 
assert another fact just like this one. This might be the cause of 
modpro failing to fire. Consider adding another slot to EContext such as 
a date or time stamp, and then you might see an increase. Notice that 
the rule might benefit from adding the option (declare (no-loop TRUE)).




Best regards,

Noel Huebers

***CODE***

(defrule modpro ; counter erhöhen
   (and
   (EContext
   (studentname ?s)
   (action bewertet)
   (value ?v)
   (task ?t))
   ?pro - (procounter
   (name ?s)
   (task ?t)
   (val ?v)
   (count ?x))
   )
=
(modify ?pro
   (count (+ ?x 1))) ;increase counter
(printout t Counter für  ?s ?t ?v  erhöhen!!! crlf))

 





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: Java objects

2007-08-19 Thread Noël Huebers
Hi,

I'm new to the Jess language and have some questions.

1. I work with Java object. I stored them in Jess with store and
assert/fetch commands.
But I could not call there member in the lhs of my rule. No function calls
allowed, right? So, for every object I made a rule to insert a Jess
template. This works fine, but is this way of mapping Java objects to Jess
facts and then discarding the object the best way to work with java objects?

2. I am trying to implement a counter-logic for specific slot combinations.
First, everytime a fact is inserted I check if there is already a procounter
fact. If not I create one. This works fine. The next rule should recognize
when a fact (EContext) is inserted and the counter (procounter) already
exists. In this case, the count slot should only be modified. I try to
compare bounded vars ?s ?v ?t from EContext to procounter slots, but I think
Jess simply overwrites the binding. Can you help me with the correct syntax?
Is there a better logic to implement a counter?

Best regards,

Noel Huebers

***CODE***

(defrule modpro ; counter erhöhen
(and
(EContext
(studentname ?s)
(action bewertet)
(value ?v)
(task ?t))
?pro - (procounter
(name ?s)
(task ?t)
(val ?v)
(count ?x))
)
=
(modify ?pro
(count (+ ?x 1))) ;increase counter
(printout t Counter für  ?s ?t ?v  erhöhen!!! crlf))


Re: JESS: Java objects

2007-08-19 Thread Ernest Friedman-Hill


On Aug 14, 2007, at 5:20 AM, Noël Huebers wrote:


Hi,

I'm new to the Jess language and have some questions.

1. I work with Java object. I stored them in Jess with store and  
assert/fetch commands.
But I could not call there member in the lhs of my rule. No  
function calls allowed, right? So, for every object I made a rule  
to insert a Jess template. This works fine, but is this way of  
mapping Java objects to Jess facts and then discarding the object  
the best way to work with java objects?




I'm afraid I don't quite understand what you're asking. If you're  
pointing out that in Jess, you have to add objects to working memory  
(insert a Jess template) before rules can act directly on them,  
then yes, that's correct. I'm not sure what you mean about discarding  
something.



2. I am trying to implement a counter-logic for specific slot  
combinations. First, everytime a fact is inserted I check if there  
is already a procounter fact. If not I create one. This works fine.  
The next rule should recognize when a fact (EContext) is inserted  
and the counter (procounter) already exists. In this case, the  
count slot should only be modified. I try to compare bounded vars ? 
s ?v ?t from EContext to procounter slots, but I think Jess simply  
overwrites the binding. Can you help me with the correct syntax? Is  
there a better logic to implement a counter?




What you've shown looks correct; you probably want to include a  
(declare (no-loop TRUE)) to the rule to avoid an infinite loop.


-
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]




Re: Fw: JESS: Java Objects

2000-08-16 Thread ejfried

I think Aditya Deshpande wrote:
 
  Hi,
  I have to give a run every time I want the activation of rules to take
  place. Is there any way that I can get the rule engine running all the
 time
  and the rules get automatically fired as and when the facts are loaded
 into
  the knowledge base.

The (run-until-halt) function is documented in the manual; see
http://herzberg.ca.sandia.gov/jess/docs/functions.html#run-until-halt .


 
  Also I can't get the Rete.assert(Fact f) to start working.
  Here is the code dump
 
fact.setSlotValue("ntype",new Value("email",RU.SLOT));


RU.SLOT was an internal type; the only mention of it in the Jess 5
manual is this line in a table:

 final public static int SLOT = 16384; ; (internal use)

In Jess 6, it no longer even exists. If you want the ntype slot to
hold an atom, use RU.ATOM; if a String, RU.STRING.


 
  Also any pointers on how to use Observer interface using the JessEvent and
  JessEventListener.
 

Jess doesn't use the Observer interface. The manual (Jess 5 section
4.10) discusses using event listeners at some length.

Do you see a common theme to these answers? Not to be rude, but maybe
you need to make a cup of tea, put your feet up, lean back, and read
through the whole manual once. 


-
Ernest Friedman-Hill  
Distributed Systems ResearchPhone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
Org. 8920, MS 9012  [EMAIL PROTECTED]
PO Box 969  http://herzberg.ca.sandia.gov
Livermore, CA 94550


-
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: Java Objects

2000-08-14 Thread Aditya Deshpande



How do I do this in JESS:Implement factory 
kind of a pattern wherein based on the property of ajavabean I get a class 
from JESS returneRegardsAditya


Re: JESS: Java Objects

2000-08-14 Thread ejfried

Do you just mean something like:

(deffunction make-widget (?bean)
  (bind ?type (get ?bean aProperty))
  (if (eq ?type "FOO") then
(return (new Foo))
   else (if (eq ?type "BAR") then
(return (new Bar))
   else (if (eq ?type "BAZ") then
(return (new Baz)
  (return (new NoneOfTheAbove)))

Pretty much exactly as you would do it in Java, yes?


I think Aditya Deshpande wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
 How do I do this in JESS:
 
 Implement factory kind of a pattern wherein based on the property of a
 javabean I get a class from JESS returne
 
 Regards
 Aditya
 
 



-
Ernest Friedman-Hill  
Distributed Systems ResearchPhone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
Org. 8920, MS 9012  [EMAIL PROTECTED]
PO Box 969  http://herzberg.ca.sandia.gov
Livermore, CA 94550
-
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: Java Objects

2000-08-14 Thread Aditya Deshpande

Precisely. Thanks. need to know is that do I need to store this object using
"store" to be retreived by the Java Application or is there a direct way of
doing this.
The basic need is to create an object based on a certain pattern and
return it to tha Java Program which has invoked JESS.

Regards
Aditya
- Original Message -
From: [EMAIL PROTECTED]
To: Aditya Deshpande [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, August 14, 2000 6:18 PM
Subject: Re: JESS: Java Objects


 Do you just mean something like:

 (deffunction make-widget (?bean)
   (bind ?type (get ?bean aProperty))
   (if (eq ?type "FOO") then
 (return (new Foo))
else (if (eq ?type "BAR") then
 (return (new Bar))
else (if (eq ?type "BAZ") then
 (return (new Baz)
   (return (new NoneOfTheAbove)))

 Pretty much exactly as you would do it in Java, yes?


 I think Aditya Deshpande wrote:
 [Charset iso-8859-1 unsupported, filtering to ASCII...]
  How do I do this in JESS:
 
  Implement factory kind of a pattern wherein based on the property of a
  javabean I get a class from JESS returne
 
  Regards
  Aditya
 
 



 -
 Ernest Friedman-Hill
 Distributed Systems ResearchPhone: (925) 294-2154
 Sandia National LabsFAX:   (925) 294-2234
 Org. 8920, MS 9012  [EMAIL PROTECTED]
 PO Box 969  http://herzberg.ca.sandia.gov
 Livermore, CA 94550
 -
 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: java objects in Jess not updating

2000-06-27 Thread Erik Huestis

Something that I forgot to mention in the previous post is that a
(reset) fails with an 'error in routine Rete.broadcastEvent while
executing (reset) while executing (batch diag.clp)...'

I am sending the propertyChangeEvents after I modify the appropriate
properties, as shown in these two set procs (below).  I was not using
the static keyword, and adding dynamic to my defclass statements does
not change things.  

Is there anything else that could be causing this behavior?  

Thanks,
Erik Huestis


  public void setSalary(float f)
  {
Float old = new Float(this.salary);
this.salary = f;
this.pcs.firePropertyChange("salary", old, new Float(f));
  }

  public void setQualification(String s)
  {
String old = this.qualification;
this.qualification = s;
System.out.println("Changing qualification to " + s + " and firing
propertyChange event...old=" + old + ", new=" + s);
this.pcs.firePropertyChange("qualification", old, s);
  }



[EMAIL PROTECTED] wrote:
 
 Two possibilities.
 
 1) Jess only works properly if you write your PropertyChangeEvents
 "correctly." The letter of the law is, according to the Java Beans
 spec, that at the time the event is received, the property in the Bean
 has already been changed. Jess depends on this. Unfortunately the most
 convenient way to implement PropertyChangedEvents sets the Bean's
 property AFTER the event is sent. Use a temporary variable to stash
 the old value, then set the new one, then send the event.
 
 2) If you've got that right, you might have used (defclass X static)
 for some reason. The 'static' here implies that updated values will
 only be fetched from a Bean at (reset) time.
 
 I think Erik Huestis wrote:
  I have a program set up in which several java objects are shadowed in
  Jess, and there are several rules set up to modify those objects.
  However, after the modify command executes, a (facts) command does not
  show the updated values.  A java getXXX command gives the updated
  values.
 
  The object does firePropertyChange when appropriate.  I am certain that
  there is something blatantly obvious which I am overlooking.  Any ideas
  would be much appreciated.
 
 
  The initialization steps that I go through look like:
 
  this.engine = new Rete();
this.engine.addUserpackage(new MiscFunctions());
this.engine.addUserpackage(new jess.ReflectFunctions());
this.engine.executeCommand("(batch " + DEFAULT_LIBRARY + ")");
this.engine.reset();
 
 
  I then go on to take a set of defclass statements from an Enumeration
  and execute them.
 
 
  for...
  {
...
  this.engine.executeCommand(cmd);
...
  }
 
  I then send a reset.
 
  ...
this.engine.executeCommand("(reset)");
  ...
 
  I then batch a file containing a bunch of rules.
 
  ...
this.engine.executeCommand("(batch " + this.fileName + ")");
  ...
 
  I then reset again just for good measure.
 
  ...
this.engine.executeCommand("(reset)");
  ...
 
  I then execute a whole bunch of definstance Funcalls taken from an
  Enumeration.
 
  for ...
  {
try
{
  Funcall cmd = (Funcall) en.nextElement();
  cmd.execute(this.engine.getGlobalContext());
}
...
 
  I then send a run command.
 
  ...
this.engine.run();
  ...
 
  My rules look like:
 
  (defrule new-engineer
"for all engineers, set properties"
?emp - (Employee (qualification "Engineer"))
=
(modify ?emp (salary (float 5)))
(printout t "Engineer salary changed to 5" crlf))
 
 
 
  Thank You Much,
  Erik Huestis
  -
  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]
  -
 
 
 -
 Ernest Friedman-Hill
 Distributed Systems ResearchPhone: (925) 294-2154
 Sandia National LabsFAX:   (925) 294-2234
 Org. 8920, MS 9012  [EMAIL PROTECTED]
 PO Box 969  http://herzberg.ca.sandia.gov
 Livermore, CA 94550
 -
 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 

Re: JESS: Java objects and Jess facts.

1998-07-08 Thread David Young

 "Ernest" == Ernest Friedman-Hill [EMAIL PROTECTED] writes:

Ernest Hi Lewis, Thanks for the example - this might well explain the
Ernest other problem you were having. The problem here lies in the
Ernest way that your property mutators are written...

Along similar lines, the Java objects in our expert system have
properties that complex containers (hash tables, lists), rather than
"atoms" (int, String). Since changing one of these properties is
really a matter of adding or removing elements from the container, it
isn't clear to me how the property-change mechanism should be
handled. Could you please clarify the technique? Thanks much.

Regards,

-- 

-
David E. Young
Fujitsu Network Communications  "I claim not to have controlled
([EMAIL PROTECTED])events, but confess plainly
 that events have controlled me."
  -- Abraham Lincoln (1864)
"Apology is Policy"
-
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
-



Re: JESS: Java objects and Jess facts.

1998-07-08 Thread David Young

 "Ernest" == Ernest Friedman-Hill [EMAIL PROTECTED] writes:

Ernest Hi David, Well, the Java Beans spec includes the notion of
Ernest 'indexed properties', or properties which are arrays that are
Ernest accessed one-element-at-a-time, but Jess doesn't do anything
Ernest with these; I'm actually not sure how the mapping would work...

Hello Ernest. In our particular case, Jess' current behavior is
innocuous (even desirable); i.e. the fact that modifying the contents
of a Hashtable property doesn't trigger the property change mechanism
is just dandy with me. However, I can envision situations where such
changes might be of interest to certain rules that would like to rely
on the semantics of 'modify'.

I can't at this time offer a suggestion, but I will be thinking about
it. If anyone else has any ideas, I'd love to hear about them. Thanks
for your help.


Regards,

-- 

-
David E. Young
Fujitsu Network Communications  "I claim not to have controlled
([EMAIL PROTECTED])events, but confess plainly
 that events have controlled me."
  -- Abraham Lincoln (1864)
"Apology is Policy"
-
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
-



Re: JESS: Java objects and Jess facts.

1998-07-07 Thread Bamba Ndiaye

Hi, I am away on home leave in the US. If this E-mail is private, it will 
automatically forwarded to my private E-mail address: [EMAIL PROTECTED] 
Thanks
-
Original Text
From: Ernest Friedman-Hill [EMAIL PROTECTED], on 7/6/98 
10:47 AM:
I think [EMAIL PROTECTED] wrote:
 
 ... When an instance of a fact, created using definstance, is modified, 
 the old fact is retracted, _but_ the modified fact is never asserted. 
 In the excerpt below, when the modify is executed the DM_Query fact 
 is lost. 
 

Hi Lewis,

As the following excerpt shows, a trivial test case works for me:
--
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 4.1b3 7/1/98

Jess (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess (definstance simple (new jess.examples.simple.Simple "Foo"))
TRUE
Jess (defrule test-rule
  ?f - (simple)
  =
  (modify ?f (truth TRUE)))
TRUE
Jess (reset)
TRUE
Jess (facts)
f-0   (initial-fact)
f-1   (simple (truth FALSE) (class External-Address:java.lang.Class)
  (name "Foo") (fraction 0.0) (serial 0)
  (OBJECT External-Address:jess.examples.simple.Simple))
For a total of 2 facts.
TRUE
Jess (run)
TRUE
Jess (facts)
f-0   (initial-fact)
f-2   (simple (truth TRUE) (class External-Address:java.lang.Class)
  (name "Foo") (fraction 0.0) (serial 0)
  (OBJECT External-Address:jess.examples.simple.Simple))
For a total of 2 facts.
TRUE
Jess
--

 The same thing happens regardless of how the fact is modified, as 
 above using (set ?qfr record ?srr), or calling setRecord() in Java.

4.1b3 fixed a bug whereby modifying a definstance fact using a bogus
property name could cause the fact to be retracted without the new
version being asserted... are you using 4.1b3? If you are not,
download it and give it a try. In any case, make sure that there
really is a public method named getRecord() with no arguments that
returns non-void in the class you're matching, and make sure Jess
knows about it (run the 'facts' command and look at all the slots in
the definstance facts.) Let me know what you find out.

 
 The RHS of some rules call user functions which use 
 
 aReteEngine.executeCommand(theCommand);
 
 to assert new facts. Could this be causing problems in the rete code 
 or data structures?
 

This should be OK; it's equivalent to calling (assert) on the RHS of a
rule, which is perfectly legal. Now if you're doing it on the -LHS- of
a rule, or if you're calling functions that modify a matched object on
the LHS of a rule, well, I think the README warns about that...

-
Ernest Friedman-Hill  
Distributed Systems ResearchPhone: (510) 294-2154
Sandia National LabsFAX:   (510) 294-2234
Org. 8920, MS 9214  [EMAIL PROTECTED]
PO Box 969  http://herzberg.ca.sandia.gov
Livermore, CA 94550

-
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. 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. List problems? Notify [EMAIL PROTECTED]
-



Re[2]: JESS: Java objects and Jess facts.

1998-07-07 Thread Lewis_Hart


I was not able to reproduce the problem in a simple example, however, something 
appears to be happening that I don't understand. The Java and rule files used 
in the trial below are attached. (Note the java files should be Thing1.java and 
Thing2.java, cc-mail does not like long file names). 
 
The problem is that the modification to the (definstance... created facts does 
not seem to be permanent. The ShowMe rule clearly show that the source and 
record field have been set in Java, but the last (facts) output show that those 
slots are nil in Jess. This is a similar problem, perhaps they are related.
 
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation 
Jess Version 4.1b3 7/1/98
 
Jess (batch "rules.clp")
TRUE
Jess (reset)
TRUE
Jess (facts)
f-0   (initial-fact)
f-1   (Thing2 (source nil) (class External-Address:java.lang.Class) (OBJECT 
External-Address:Thing2))
f-2   (Thing1 (source nil) (class External-Address:java.lang.Class) (record 
nil) (OBJECT External-Address:Thing1))
For a total of 3 facts.
TRUE
Jess (run)
(Query (Source Thing1) (Record (Query (Source Thing2) )) ) 
(Query (Source Thing2) )TRUE
Jess (facts)
f-0   (initial-fact)
f-4   (Thing2 (source nil) (class External-Address:java.lang.Class) (OBJECT 
External-Address:Thing2))
f-5   (Thing1 (source nil) (class External-Address:java.lang.Class) (record 
nil) (OBJECT External-Address:Thing1))
For a total of 3 facts.
TRUE
Jess
 
Opinions are strictly those of the author and 
do not necessarily reflect those of GRCI. 
__ 
Lewis Hart   GRC International 
703-506-5938 1900 Gallows Rd 
[EMAIL PROTECTED]   Vienna, VA 22182
 
__ Reply Separator _
Subject: Re: JESS: Java objects and Jess facts.
Author:  Ernest Friedman-Hill [EMAIL PROTECTED] at GRC_INET 
Date:7/6/98 10:47 AM
 
 
I think [EMAIL PROTECTED] wrote: 
 
 ... When an instance of a fact, created using definstance, is modified, 
 the old fact is retracted, _but_ the modified fact is never asserted. 
 In the excerpt below, when the modify is executed the DM_Query fact 
 is lost. 
 
 
Hi Lewis,
 
As the following excerpt shows, a trivial test case works for me: 
-- 
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation 
Jess Version 4.1b3 7/1/98
 
Jess (defclass simple jess.examples.simple.Simple) 
jess.examples.simple.Simple
Jess (definstance simple (new jess.examples.simple.Simple "Foo")) 
TRUE
Jess (defrule test-rule
  ?f - (simple)
  =
  (modify ?f (truth TRUE)))
TRUE
Jess (reset)
TRUE
Jess (facts)
f-0   (initial-fact)
f-1   (simple (truth FALSE) (class External-Address:java.lang.Class)
  (name "Foo") (fraction 0.0) (serial 0)
  (OBJECT External-Address:jess.examples.simple.Simple))
For a total of 2 facts.
TRUE
Jess (run)
TRUE
Jess (facts)
f-0   (initial-fact)
f-2   (simple (truth TRUE) (class External-Address:java.lang.Class)
  (name "Foo") (fraction 0.0) (serial 0)
  (OBJECT External-Address:jess.examples.simple.Simple))
For a total of 2 facts.
TRUE
Jess
--
 
 The same thing happens regardless of how the fact is modified, as 
 above using (set ?qfr record ?srr), or calling setRecord() in Java.
 
4.1b3 fixed a bug whereby modifying a definstance fact using a bogus 
property name could cause the fact to be retracted without the new 
version being asserted... are you using 4.1b3? If you are not, 
download it and give it a try. In any case, make sure that there 
really is a public method named getRecord() with no arguments that 
returns non-void in the class you're matching, and make sure Jess 
knows about it (run the 'facts' command and look at all the slots in 
the definstance facts.) Let me know what you find out.
 
 
 The RHS of some rules call user functions which use 
 
 aReteEngine.executeCommand(theCommand); 
 
 to assert new facts. Could this be causing problems in the rete code 
 or data structures?
 
 
This should be OK; it's equivalent to calling (assert) on the RHS of a 
rule, which is perfectly legal. Now if you're doing it on the -LHS- of 
a rule, or if you're calling functions that modify a matched object on 
the LHS of a rule, well, I think the README warns about that...
 
- 
Ernest Friedman-Hill  
Distributed Systems ResearchPhone: (510) 294-2154 
Sandia National LabsFAX:   (510) 294-2234 
Org. 8920, MS 9214  [EMAIL PROTECTED] 
PO Box 969  http://herzberg.ca.sandia.gov 
Livermore, CA 94550
 
-

Re: JESS: Java objects and Jess facts.

1998-07-06 Thread Ernest Friedman-Hill

I think [EMAIL PROTECTED] wrote:
 
 ... When an instance of a fact, created using definstance, is modified, 
 the old fact is retracted, _but_ the modified fact is never asserted. 
 In the excerpt below, when the modify is executed the DM_Query fact 
 is lost. 
 

Hi Lewis,

As the following excerpt shows, a trivial test case works for me:
--
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 4.1b3 7/1/98

Jess (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess (definstance simple (new jess.examples.simple.Simple "Foo"))
TRUE
Jess (defrule test-rule
  ?f - (simple)
  =
  (modify ?f (truth TRUE)))
TRUE
Jess (reset)
TRUE
Jess (facts)
f-0   (initial-fact)
f-1   (simple (truth FALSE) (class External-Address:java.lang.Class)
  (name "Foo") (fraction 0.0) (serial 0)
  (OBJECT External-Address:jess.examples.simple.Simple))
For a total of 2 facts.
TRUE
Jess (run)
TRUE
Jess (facts)
f-0   (initial-fact)
f-2   (simple (truth TRUE) (class External-Address:java.lang.Class)
  (name "Foo") (fraction 0.0) (serial 0)
  (OBJECT External-Address:jess.examples.simple.Simple))
For a total of 2 facts.
TRUE
Jess
--

 The same thing happens regardless of how the fact is modified, as 
 above using (set ?qfr record ?srr), or calling setRecord() in Java.

4.1b3 fixed a bug whereby modifying a definstance fact using a bogus
property name could cause the fact to be retracted without the new
version being asserted... are you using 4.1b3? If you are not,
download it and give it a try. In any case, make sure that there
really is a public method named getRecord() with no arguments that
returns non-void in the class you're matching, and make sure Jess
knows about it (run the 'facts' command and look at all the slots in
the definstance facts.) Let me know what you find out.

 
 The RHS of some rules call user functions which use 
 
 aReteEngine.executeCommand(theCommand);
 
 to assert new facts. Could this be causing problems in the rete code 
 or data structures?
 

This should be OK; it's equivalent to calling (assert) on the RHS of a
rule, which is perfectly legal. Now if you're doing it on the -LHS- of
a rule, or if you're calling functions that modify a matched object on
the LHS of a rule, well, I think the README warns about that...

-
Ernest Friedman-Hill  
Distributed Systems ResearchPhone: (510) 294-2154
Sandia National LabsFAX:   (510) 294-2234
Org. 8920, MS 9214  [EMAIL PROTECTED]
PO Box 969  http://herzberg.ca.sandia.gov
Livermore, CA 94550

-
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
-