Title: Question for Removing old states

;Begin-code
(deftemplate state
        "structure of a state"
        (slot sname)
        (slot stime))

(defrule rule1
        ?fact <- (state (sname ?sn) (stime ?st))
        (test (> (- (time) ?st) 10))
        =>
        (retract ?fact))

(defrule rule2
        ?fact <- (state (sname ?sn) (stime ?st))
        =>
        (if (> (- (time) ?st) 10) then
                (retract ?fact)))

(assert (state (sname s1) (stime (time))))
;End-Code


Hi,
it's the first time i send a question...:-)
I have a problem with this situation:
I want to have a structure called state with a field stime which holds a time-stamp to say when a particular state was generated. (see deftemplate state... )

I also want that states which are, lets say, more than 10 seconds old, be removed from the system.
My system performs an infinite loop, in which states are inserted and the run is executed.
The problem is that when rule1 is loaded and if in that particular instant some state (lets call it s1) is only 5 seconds old, for instance, s1 will never be deleted, not even after it completes 10 seconds of life, because rule1 does not refreshes... it seems that the rule needs some sord of refreshement, so that when (run) is executed all the facts can be considered again...

I tried use rule2, but it didn't solve the question. The only solution i see is to load the rule each time in the loop, but that's a bad solution because it is computationally heavy.

Can you see another solution for this problem?
Is there any command to refresh the rules?

Thanx for the attention.
D�rio





Reply via email to