rules - CLIPS: modify-instance does not trigger pattern matching -


having file test.clp:

(defclass testclass (is-a user)     (role concrete)     (pattern-match reactive)     (slot value)     (slot threshold))   (definstances testobjects      (test of testclass     (value 0)     (threshold 3)))  (defrule above-threshold     ?test <- (object (is-a testclass))     (test (> (send ?test get-value) (send ?test get-threshold)))     =>     (printout t "*** above threshold!! ***" crlf)     (refresh below-threshold))  (defrule below-threshold     ?test <- (object (is-a testclass))     (test (> (send ?test get-value) (send ?test get-threshold)))     =>     (printout t "*** normal ***" crlf)     (refresh above-threshold)) 

i load file and:

clips> (reset) clips> (agenda) 0      below-threshold: [test] total of 1 activation. clips> (run)  *** normal *** clips> (modify-instance [test] (value 8)) true clips> (agenda) clips>  

the agenda not show active rule. expect change (modify-instance) value 8 trigger pattern matching , rule "above-threshold" selected running , put in agenda. missing?

from section 5.4.1.7, pattern-matching object patterns, of basic programming guide:

when instance created or deleted, patterns applicable object updated. however, when slot changed, patterns explicitly match on slot affected.

so modify rules explicitly match slots want trigger pattern matching:

(defrule above-threshold     ?test <- (object (is-a testclass)                      (value ?value)                      (threshold ?threshold))     (test (> ?value ?threshold))     =>     (printout t "*** above threshold!! ***" crlf)     (refresh below-threshold))  (defrule below-threshold     ?test <- (object (is-a testclass)                      (value ?value)                      (threshold ?threshold))     (test (< ?value ?threshold))     =>     (printout t "*** normal ***" crlf)     (refresh above-threshold)) 

Comments