Wolfgang Laun
Sun, 29 Nov 2009 07:19:48 -0800
On Sun, Nov 29, 2009 at 1:40 AM, Marco Zappatore <marcozappat...@libero.it>wrote:
> > Dear JESS users, > I'm working with shadow facts and my question is the following: > let's suppose I have 3 java beans > 1) A (with slot sA) > 2) B (with slot sB) > 3) C > > the type for the sA slot is the java bean B itself and the type for the sB > slot is C. > > First I definstanced C, then I definstanced B. I used the OBJECT slot of > the > shadow fact C as content for sB and I retracted C. > Finally I definstanced A. I filled again the sA slot with the OBJECT slot > of > the shadow fact B and I retracted B too. > This is a very circuitous way of creating a shadow fact A. Simply creating (using new) the bean object instances of C, then of B and then using definstance for creating the object plus shadow fact for A achieves the same thing. > Now I have to write a rule that has to verify directly in A whether or not > C > is in sB. > > My trials: > > (defrule myRule1 > ?f <- (A (sA ?a &: (instanceof (get-member ?a sB) C)) > => > ;do something) > The way you describe the type and genesis of B, there cannot be any doubt that B's SB contains an object of type C (or null) - so why use instanceof, which is nothing but Java's instanceof operator? Assuming that you really just want to test the class of the value in A's slot sA, and that you have followed the Java Bean convention in naming fields and getters, try the more straightforward: ?f <- (A (sA ?a &: (instanceof (?a getSB) C))) > (defrule myRule2 > ?f <- (A (sA ?a)) > (B (OBJECT ?a) (sB ?b &: (instanceof ?b C))) > => > ;do something) > This fails because you have retracted the B object: there is nothing in WM to match the second CE. And, again, why use instanceof? > > didn't work... > Any errors you are getting, or just failures to match? -W > Any idea? > > Many thanks in advance > Marco Zappatore > -- > View this message in context: > http://old.nabble.com/Multiple-shadow-facts-tp26558321p26558321.html > Sent from the Jess mailing list archive at Nabble.com. > > > > -------------------------------------------------------------------- > To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' > in the BODY of a message to majord...@sandia.gov, NOT to the list > (use your own address!) List problems? Notify owner-jess-us...@sandia.gov. > -------------------------------------------------------------------- > >