I think wrote:
> Hello -
>
> I'm trying to learn how to properly get Jess and my Java code to work together. To
>do so I've come up with what I believe should be a fairly simple test.
>
> I created a 2 classes, Person and Address. Person has an attribute age and the
>aappropriate accessors, and also has an address and the appropriate accessors.
>Address has, for now, only one attribute, state, and the accessors. In addition,
>Person has an attribute comment and its accessors.
>
> I want to have a rule that says basically:
>
> If a person is over 25 and lives in NY, set the comment to "Got one".
Option 1: (Must definstance both Person and Address)
(defrule foo
(Person (age ?X&:(> ?X 2%)) (address ?A))
(Address (OBJECT ?A) (state "NY))
=>
(set the comment to "Got One"))
Option 2: (Only Person needs to be definstanced)
(defrule foo
(Person (age ?X&:(> ?X 2%)) (address ?A&:(eq (get ?A address) "NY")))
=>
(set the comment to "Got One"))
>
> What I thought I would do is create a Rete object from my Java program, create an
>instance of Person and its Address, and then store the Person object into the Rete
>object. However, I cannot figure out exactly what the rule should look like,
>specifically the LHS.
>
> Do I need to do a definstance, or will Jess associate the stored
> object to a fact?
You need to do a defclass and a definstance. If by "stored object" you
mean an argument to Rete.store(), then no, Jess doesn't look at those
objects at all.
And once Jess knows the object, how do I write a LHS of a rule to say that it should
get the Person's Address's state? I've managed to do something like "If a person is
over 25 set the comment" but I don't know if that was really correct since I had a
startup rules that asserted facts from stored objects, but that wouldn't work well in
a real system.
>
See above.
> Thanks for your help...I hope this is descriptive enough. It's obviously a very
>simplified version of what I really want to ultimately do.
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (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]
---------------------------------------------------------------------