Everything seems to be consistent with a problem in the PropertyChangeEvent generated by a call to the setAdviceText() method of the GlucoseDecision class. If a JavaBean offers PropertyChangeListener support, then Jess depends on it working correctly. For "static" definstances, if you call "modify" Jess modifies both the shadow fact and the underlying JavaBean. For dynamic ones (ones with PropertyChangeListener support) Jess modifies only the Bean and relies on the ensuing PropertyChangeEvent to update working memory. Either the event should contain the correct before and after values, or it must be fired after the actual property change is made. So can I see "GlucoseDecision.setAdviceText()?"

Alternatively, your Bean could be what Jess awkwardly calls a "non- value class", ultimately meaning a class that defines a hashCode() method whose value changes over time. This can cause various oddities to occur. Tell Jess about this using the set-nonvalue-class function.

On Dec 8, 2006, at 6:51 AM, Mike Dean wrote:

The trace is below. The last part of each trace is a retraction of the
fact after updating the shadow object.  To me it looks like there is
only one actual modification of f-1 which makes no sense. If this code
never had worked, I would be less puzzled because I would know I never
kludged it successfully in the first place.

First trace is patient with low glucose ON insulin.  You will see that
the fact ends up with a calculated recommendedGlucoseBolus, so that got
updated, but I don't see the actual change in f-1 in the trace (should
have occured in give-glucose-extreme). The second trace is same patient
with low glucose but not on insulin.


 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText "")
(carbohydrateStatus 1) (class <Java-Object:java.lang.Class>)
(currentInsulinDripRate 12.0) (decisionTimeStamp
<Java-Object:java.util.GregorianCalendar>) (declineComment "")
(glucoseChangePerHour nil) (id nil) (minutesToNextEvaluation 999999)
(observationDate <Java-Object:java.util.GregorianCalendar>)
(otherComment "") (patient
<Java-Object:edu.utah.cdmcc.entities.Patient>) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
<Java-Object:java.beans.PropertyChangeSupport>)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "") (recommendedGlucoseBolus 0.0)
(recommendedInsulinBolus 0.0) (recommendedInsulinDripRate 0.0)
(rulesFiredText "") (serumGlucoseConcentration 12) (userAction
"Pending") (valid TRUE) (version 0) (OBJECT
<Java-Object:edu.utah.cdmcc.entities.GlucoseDecision>))
==> Activation: MAIN::is-child :  f-1
==> Activation: MAIN::current-glucose-range :  f-1
==> Activation: MAIN::is-insulin-on-or-off :  f-1
 ==> f-2 (MAIN::currentGlucoseBelowRange)
==> Activation: MAIN::mild-hypoglycemia-definition :  f-2, f-1
==> Activation: MAIN::moderate-hypoglycemia-definition :  f-2, f-1
==> Activation: MAIN::extreme-hypoglycemia-definition :  f-2, f-1
 ==> f-3 (MAIN::extremeHypoglycemia)
==> Activation: MAIN::give-glucose-extreme :  f-3, f-1
 ==> f-4 (MAIN::recommendedGlucoseBolus)
 ==> f-5 (MAIN::pediatric)
 ==> f-6 (MAIN::insulinOn)
==> Activation: MAIN::hypoglycemia-need-insulin-off :  f-2, f-6
 ==> f-7 (MAIN::needInsulinOff)
==> Activation: MAIN::recommend-off-insulin :  f-7, f-1
 ==> f-8 (MAIN::recommendedInsulinOff)
 <== Focus MAIN
<=> f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText "Turn OFF
the insulin drip.") (carbohydrateStatus 1) (class
<Java-Object:java.lang.Class>) (currentInsulinDripRate 12.0)
(decisionTimeStamp <Java-Object:java.util.GregorianCalendar>)
(declineComment "") (glucoseChangePerHour nil) (id nil)
(minutesToNextEvaluation 999999) (observationDate
<Java-Object:java.util.GregorianCalendar>) (otherComment "") (patient
<Java-Object:edu.utah.cdmcc.entities.Patient>) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
<Java-Object:java.beans.PropertyChangeSupport>)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "The patient is receiving insulin despite being
hypoglycemic.") (recommendedGlucoseBolus 15.17) (recommendedInsulinBolus
0.0) (recommendedInsulinDripRate 0.0) (rulesFiredText "")
(serumGlucoseConcentration 12) (userAction "Pending") (valid TRUE)
(version 0) (OBJECT
<Java-Object:edu.utah.cdmcc.entities.GlucoseDecision>))
<== f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText "Turn OFF
the insulin drip.") (carbohydrateStatus 1) (class
<Java-Object:java.lang.Class>) (currentInsulinDripRate 12.0)
(decisionTimeStamp <Java-Object:java.util.GregorianCalendar>)
(declineComment "") (glucoseChangePerHour nil) (id nil)
(minutesToNextEvaluation 999999) (observationDate
<Java-Object:java.util.GregorianCalendar>) (otherComment "") (patient
<Java-Object:edu.utah.cdmcc.entities.Patient>) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
<Java-Object:java.beans.PropertyChangeSupport>)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "The patient is receiving insulin despite being
hypoglycemic.") (recommendedGlucoseBolus 15.17) (recommendedInsulinBolus
0.0) (recommendedInsulinDripRate 0.0) (rulesFiredText "")
(serumGlucoseConcentration 12) (userAction "Pending") (valid TRUE)
(version 0) (OBJECT
<Java-Object:edu.utah.cdmcc.entities.GlucoseDecision>))



 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText "")
(carbohydrateStatus 1) (class <Java-Object:java.lang.Class>)
(currentInsulinDripRate 0.0) (decisionTimeStamp
<Java-Object:java.util.GregorianCalendar>) (declineComment "")
(glucoseChangePerHour nil) (id nil) (minutesToNextEvaluation 999999)
(observationDate <Java-Object:java.util.GregorianCalendar>)
(otherComment "") (patient
<Java-Object:edu.utah.cdmcc.entities.Patient>) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
<Java-Object:java.beans.PropertyChangeSupport>)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "") (recommendedGlucoseBolus 0.0)
(recommendedInsulinBolus 0.0) (recommendedInsulinDripRate 0.0)
(rulesFiredText "") (serumGlucoseConcentration 12) (userAction
"Pending") (valid TRUE) (version 0) (OBJECT
<Java-Object:edu.utah.cdmcc.entities.GlucoseDecision>))
==> Activation: MAIN::is-child :  f-1
==> Activation: MAIN::current-glucose-range :  f-1
==> Activation: MAIN::is-insulin-on-or-off :  f-1
 ==> f-2 (MAIN::currentGlucoseBelowRange)
==> Activation: MAIN::mild-hypoglycemia-definition :  f-2, f-1
==> Activation: MAIN::moderate-hypoglycemia-definition :  f-2, f-1
==> Activation: MAIN::extreme-hypoglycemia-definition :  f-2, f-1
 ==> f-3 (MAIN::extremeHypoglycemia)
==> Activation: MAIN::give-glucose-extreme :  f-3, f-1
 ==> f-4 (MAIN::recommendedGlucoseBolus)
 ==> f-5 (MAIN::pediatric)
 ==> f-6 (MAIN::insulinOff)
 <== Focus MAIN
 <=> f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText
"Administer glucose (0.50 gm/kg = 15.17 grams).") (carbohydrateStatus 1)
(class <Java-Object:java.lang.Class>) (currentInsulinDripRate 0.0)
(decisionTimeStamp <Java-Object:java.util.GregorianCalendar>)
(declineComment "") (glucoseChangePerHour nil) (id nil)
(minutesToNextEvaluation 999999) (observationDate
<Java-Object:java.util.GregorianCalendar>) (otherComment "") (patient
<Java-Object:edu.utah.cdmcc.entities.Patient>) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
<Java-Object:java.beans.PropertyChangeSupport>)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "The patient is extremely hypoglycemic (< 40 mg/dL).")
(recommendedGlucoseBolus 15.17) (recommendedInsulinBolus 0.0)
(recommendedInsulinDripRate 0.0) (rulesFiredText "")
(serumGlucoseConcentration 12) (userAction "Pending") (valid TRUE)
(version 0) (OBJECT
<Java-Object:edu.utah.cdmcc.entities.GlucoseDecision>))
 <== f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText
"Administer glucose (0.50 gm/kg = 15.17 grams).") (carbohydrateStatus 1)
(class <Java-Object:java.lang.Class>) (currentInsulinDripRate 0.0)
(decisionTimeStamp <Java-Object:java.util.GregorianCalendar>)
(declineComment "") (glucoseChangePerHour nil) (id nil)
(minutesToNextEvaluation 999999) (observationDate
<Java-Object:java.util.GregorianCalendar>) (otherComment "") (patient
<Java-Object:edu.utah.cdmcc.entities.Patient>) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
<Java-Object:java.beans.PropertyChangeSupport>)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "The patient is extremely hypoglycemic (< 40 mg/dL).")
(recommendedGlucoseBolus 15.17) (recommendedInsulinBolus 0.0)
(recommendedInsulinDripRate 0.0) (rulesFiredText "")
(serumGlucoseConcentration 12) (userAction "Pending") (valid TRUE)
(version 0) (OBJECT
<Java-Object:edu.utah.cdmcc.entities.GlucoseDecision>))


Finally, I show the code below that calls Jess:

        private void fireRulesEngine() {
                emptyTrace.setText("");
                SWTTextWriter invisibleTraceWriter = new
SWTTextWriter(emptyTrace);
                Rete r = GlucosePlugin.getDefault().getRete();
                r.addOutputRouter("traceOut", invisibleTraceWriter);
                try {
                        r.reset();
                        r.setWatchRouter("traceOut");
                } catch (JessException e1) {
                        displayExceptionInformation(e1);
                }
                try {
                        r.add(decision);
                        r.watchAll();
                        r.run();
                        r.updateObject(decision);
                        r.undefinstance(decision);
                        System.out.println(decision.getAdviceText());
                } catch (JessException e) {
                        displayExceptionInformation(e);
                }
                // If no advice resulted from running the inference
engine
                if (decision.getAdviceText().length() == 0) {
                        decision.setAdviceText("No change at this
time.");
                }
                // Get the rule trace text and stick it into the
decision object
                decision.setRulesFiredText(emptyTrace.getText().toString());
                // Fire property change so listeners can act
                GlucosePlugin.getDefault().fireDecisionChanged(decision);
        }

Thank you for your help with this.

- Mike

J. Michael Dean, M.D., M.B.A.
H.A. and Edna Benning Presidential Professor of Pediatrics
Professor of Family and Preventive Medicine
Professor of Biomedical Informatics
Chief, Division of Pediatric Critical Care
Vice Chairman, Department of Pediatrics
University of Utah School of Medicine
--------------------------------------------------------------------
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 owner-jess- [EMAIL PROTECTED]
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research          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]
--------------------------------------------------------------------

Reply via email to