Hello,

Thanks a lot for helping me!

It is working if there are only 2 facts in the working memory. If there are
more than 2  facts, the rules will be fired several times.  Is there a way
to  make sure that o1 is associated to fact 1 and o2 is linked to fact 2?

Following does not fire any rule:

  ?o1 <- (fact-id 1) (S ?s1)) 
   ?o2 <- (fact-id 2)(S ?s2)) 
   (test (> ?s1 ?s2)))
=>
...

Thanks a lot!
Andrew


Ernest Friedman-Hill wrote:
> 
> If I understand you correctly, the assertion order matters here;  
> i.e., your "fact 1" is the first one asserted, and "fact 2" is the  
> second. The order in which facts are asserted is normally not a  
> concern, but Jess does track it, and you can make a rule conditional  
> on it; you might do something like this. Let's call the object type  
> "O" and the slot "S":
> 
> (defrule rule-1
>    ?o1 <- (O (S ?s1))
>    ?o2 <- (O (S ?s2))
>    (test (and (> ?o2 ?o1) (> ?s1 ?s2)))
>    => ...
> 
> Comparing ?o1 and ?o2 here assures that the object with the higher  
> fact index (i.e., the one that was asserted later) is the one with  
> the lower value in S.
> 
> 
> On Oct 1, 2007, at 11:01 PM, ameng wrote:
> 
>>
>> Hello,
>> From java program, I added a couple of shadow facts of same object  
>> type into
>> working memory in particular order. When defining a rule, how I can  
>> do thing
>> like:
>>
>> value of slot 1 in fact1 > value of slot 1 in fact 2
>> =>
>> doing something
>>
> 
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs                FAX:   (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]
> --------------------------------------------------------------------
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-access-slot-value-of-several-shadow-facts-of-same-type.-tf4552571.html#a13008274
Sent from the Jess mailing list archive at Nabble.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]
--------------------------------------------------------------------

Reply via email to