[rules-users] Rule firing problem - must be missing somethingobvious
Anstis, Michael (M.)
manstis1 at ford.com
Tue Nov 27 09:31:18 EST 2007
You are not telling the rule engine that GlucoseDecisionState has been
updated. You might also like to think about how the GlucoseDecisionState and
GlucoseDecision are related. If you have multiple instances of either class
the rules' behaviour might be unexpected (your RHS's suggest the two are
related but your LHS patterns suggest they are unrelated).
_____
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of J Michael Dean
Sent: 27 November 2007 13:41
To: rules-users at lists.jboss.org
Subject: [rules-users] Rule firing problem - must be missing
somethingobvious
I am passing a glucose decision object with a value of 12, and have a state
object that starts out with its flag set false. The desired behavior is
that the value will be recognized as "extremeHypoglycemia" by the first
rule, and then the second rule will recommend giving a glucose bolus.
When I pass both objects in without "true" to cause automatic updating, then
the first rule fires, the output is
false
Fired detect extreme hypoglycemia
true
and then the program stops. It does not fire the second rule.
When I add true to the insertion of these objects, then the program
recurses, and still never hits the second rule. Interestingly, the output is
true
Fired detect extreme hypoglycemia
true
true
Fired detect extreme hypoglycemia
true
...
ETC.
rule "First rule: Detect extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision( serumGlucoseConcentration < 40 )
decisionState : GlucoseDecisionState(extremeHypoglycemia == false)
then
System.out.println("Fired detect extreme hypoglycemia");
System.out.println(decisionState.isExtremeHypoglycemia());
decisionState.setExtremeHypoglycemia(true);
decision.setRationaleText(decision.getRationaleText() +
"Extreme hypoglycemia (Current glucose is " +
decision.getSerumGlucoseConcentration() +" mg/dL).\n");
System.out.println(decisionState.isExtremeHypoglycemia());
update(decision);
end
rule "Second rule: Give glucose bolus for extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision()
decisionState : GlucoseDecisionState(extremeHypoglycemia == true )
then
System.out.println("Fired glucose bolus rule");
decisionState.setRecommendedGlucoseBolus(true);
decision.setRationaleText(decision.getRationaleText() +
"Glucose bolus recommended because of extreme hypoglycemia.\n");
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071127/4a8b5213/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4159 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20071127/4a8b5213/attachment.bin
More information about the rules-users
mailing list