Hello Ernest,

> There's a subtle difference between the solutions Jason and Wolfgang
> posted; you're basically using Jason's, but apparently you want
> Wolfgang's.
>
>
> Jason's and yours will fire for facts for which no single other fact
> has *both* a higher index1 and a lower index2. You're using a single
> "not" pattern, which restricts these two conditions to applying to a
> single other facts.
>
> Wolfgang's will for facts for which *no other fact* has a higher
> index1, and *no other fact* has a higher index2. He uses two separate
> "not" patterns to describe these two conditions, so each is
> considered separately.
>
> Make sense?

It makes a lot of sense. Thank you for your explanation. In fact, I did not 
read Wolfgang's solution enough carefully. Sorry Wolfgang.

Best regards,

Nicolas.


> On Oct 18, 2007, at 8:30 AM, Nicolas Fortin wrote:
>
>>
>> Hello everybody and specially to Jason and Wolfgang. Thank you for
>> your help guys.
>>
>> First, concerning what you said Jason, I don't want to hunt fact
>> with the highest index1 and lowest index2 among all instances of an
>> arbitrary number of fact template (e.g. My-Template, Queue, etc.).
>> I did a typo (damn copy and paste), you should have seen only My-
>> Template. So forget the Queue template.
>>
>> Second, I have already done an example as you said guys, but what
>> puzzled me is that the result is not really what I expected. So
>> let's say I have:
>>
>> (deftemplate MAIN::My-Template
>> (slot id (type INTEGER))
>> (slot index1 (type INTEGER))
>> (slot index2 (type INTEGER)))
>>
>> (reset)
>>
>>
>> (assert (MAIN::My-Template
>> (id 1) (index1 1) (index2 0)))
>> (assert (MAIN::My-Template
>> (id 2) (index1 1) (index2 0)))
>> (assert (MAIN::My-Template
>> (id 3) (index1 0) (index2 0)))
>>
>>
>> (defrule MAIN::greatest-one-smallest-two
>> "Find the My-Template with greatest index1 and smallest index2"
>> (MAIN::My-Template
>> (id ?id1)
>> (index1 ?index1_1)
>> (index2 ?index2_1))
>> (not (MAIN::My-Template
>> (id ~?id1)
>> (index1 ?index1_2&:(>= ?index1_2 ?index1_1))
>> (index2 ?index2_2&:(< ?index2_2 ?index2_1 ))))
>> =>
>> (printout t
>> "No My-Template fact has both a larger index1 and a smallest index2
>> than fact # " ?id1 crlf)
>> (printout t
>> " index1: " ?index1_1 " index2: " ?index2_1 crlf))
>>
>> (run)
>>
>> The output is not what I want, since the third fact (id 3)
>> activates the rule. As far as I can understand it should not,
>> because its index1 slot is not the greatest. In this example, I
>> would be expected that only the first and the second facts activate
>> this rule, since they both have the greatest index1 and the
>> smallest index2. Maybe I am wrong, but it seems for me that Jess is
>> performing a *or* rather than an *and* in this example. What is wrong?
>>
>> Thanks again.
>>
>> Nicolas
>>
>>
>>
>> Date: Thu, 18 Oct 2007 02:56:18 -0400From:
>> [EMAIL PROTECTED]: [EMAIL PROTECTED]: Re: JESS:
>> How can I write this rule?
>> Hi NIcolas,
>> A rule like this seems to work for me:(defrule greatest-one-
>> smallest-two "Find the My-Template with greatest index1 and
>> smallest index2" (MAIN::My-Template (id ?id1)(index1 ?i1_1)
>> (index2 ?i1_2)) (not (MAIN::My-Template
>> (id ~?id1)
>> (index1 ?i2_1&:(>= ?i2_1 ?i1_1))
>> (index2 ?i2_2&:(< ?i2_2 ?i1_2 )))) => (printout t
>> "No My-Template fact has both a larger index1 and a smallest
>> index2 than fact # " ?id1 crlf) (printout t
>> " index1: " ?i1_1 " index2: " ?i1_2 crlf))It seems a bit
>> more complicated if you want to hunt for a particular fact with the
>> highest index1 and lowest index2 among all instances of an
>> arbitrary number of fact templates ( i.e., my-template, queue,
>> etc.) that share these two slots in common
>
> ---------------------------------------------------------
> 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]
--------------------------------------------------------------------
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