« Return to Thread: JESS: Problem with slot-specific?

JESS: Problem with slot-specific?

by Aaron Novstrup :: Rate this Message:

Reply to Author | View in Thread

I'm not sure whether this is a bug, or just a misunderstanding on my
part.  With the code below, I expect to have "Boiling!!!" printed to the
console during the second (run) call.  Instead, the detect-boiling rule
fires but the alert-user rule does not.  However, the example works as
expected if I replace the modify on the RHS of detect-boiling with a
retract+assert.

(deftemplate thermometer
    (declare (slot-specific TRUE))
    (slot reading))

(deftemplate water
    (slot state))

(defrule detect-boiling
    (thermometer {reading > 100})
    ?b <- (water (state ~boiling))
    =>
    (modify ?b (state boiling))
    )

(defrule alert-user
    (water (state boiling))
    =>
    (printout t "Boiling!!!" crlf)
    )

(reset)
(watch all)
(assert (water (state cool)))
(bind ?f (assert (thermometer (reading 98))))
(run)

(modify ?f (reading 105))
(run)

Execution trace:
Jess, the Rule Engine for the Java Platform
Copyright (C) 2008 Sandia Corporation
Jess Version 7.1p1 8/6/2008

 ==> f-1 (MAIN::water (state cool))
 ==> f-2 (MAIN::thermometer (reading 98))
 <== Focus MAIN
 <=> f-2 (MAIN::thermometer (reading 105))
==> Activation: MAIN::detect-boiling :  f-2, f-1
FIRE 1 MAIN::detect-boiling f-2, f-1
 <=> f-1 (MAIN::water (state boiling))


begin:vcard
fn:Aaron Novstrup
n:Novstrup;Aaron
org:Stottler Henke Associates Inc.
adr;dom:;;1107 NE 45th St;Seattle;WA;98105
email;internet:anovstrup@...
title:AI Software Engineer
tel;work:206.545.2941
tel;cell:805.701.9786
x-mozilla-html:FALSE
url:www.stottlerhenke.com
version:2.1
end:vcard

 « Return to Thread: JESS: Problem with slot-specific?