Partner, i was in a good mood, so i decided i could try and help you.

So i've taken your simple program, has my own and did this...

(deftemplate ind
 (slot link (type STRING))
 (slot timestamp (type INTEGER))
 (slot value (type INTEGER))
)

(deftemplate system
 (slot name (type STRING))
 (multislot links)
)


(assert (ind (link "LINK001") (timestamp 20) (value 22)))
(assert (ind (link "LINK002") (timestamp 20) (value 20)))
(assert (ind (link "LINK003") (timestamp 20) (value 18)))
(assert (system (name "retail")  (links (create$ "LINK001" "LINK002"
"LINK003"))))

(defrule max
    "Calculate the maximum value"
    ?y <- (system (name ?pname) (links $?links))
    ?x <- (ind (link ?dlink&:(member$ ?dlink ?links)) (timestamp
?dtimestamp) (value ?dvalue))
     =>
        (retract ?x)
        (retract ?y) 
    (printout t "Found pair " ?pname " for link " ?dlink " with
datalag " ?dvalue crlf)
) 

it worked perfectly, hope it helps (im sure it will ehehe)

Jonas (IPS/EST)


On Tue, 28 Dec 2004 16:23:22 -0800, Hitesh Lad <[EMAIL PROTECTED]> wrote:
>  
> 
> Hi, l looked around the mailing list and couldn't find a comparable problem
> to mine. 
> 
> I'm trying to fire a rule when: 
>    1) I have indication facts for all the links of a system 
>    2) The indications should have the same timestamp 
>    3) the returned ?dvalue should be the maximum for all the indication
> facts with the same timestamp 
>  
> 
> With the following facts:
>  
> (assert (indication (link "LINK001") (timestamp 20) (value 22))) 
> (assert (indication (link "LINK002") (timestamp 20) (value 20))) 
> (assert (indication (link "LINK003") (timestamp 20) (value 18))) 
> (assert (system (name "retail")  (links (create$ "LINK001" "LINK002"
> "LINK003")))) 
>  
> 
> I got this far and now I'm stuck: 
> 
> (defrule max 
>     "Calculate the maximum value" 
>     (system (name ?pname) (links $?links)) 
>     (indication (link ?dlink) (value ?dvalue) (timestamp ?dtimestamp)) 
>     (test (member$ ?dlink ?links)) 
>      => 
>     (printout t "Found pair " ?pname " for link " ?dlink " with datalag "
> ?dvalue crlf) 
> ) 
> 
> This only makes sure that the indications have matching system, but not the
> same one. 
> I know this will match the indication 3 times.  I'm not sure how to write
> the pattern to make sure we have an indication for all the links for a
> system with the same timestamp. 
> 
> I want this to fire off and give me a value of 22. 
> 
> Any help is appreciated. 
> 
> + - + - + - + - + - + - + - + - + - + - + - + - + - + - + 
> hitesh lad 
>

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