<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:#606420;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink="#606420">

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hello,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am a new Drools user working my way through the examples.&nbsp;
To test my understanding of how the rules work, I modified the StateExampleUsingSalience.drl
file used in the </span></font><font size=2 color=black face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:black;background:silver'>StateExampleWithDynamicRules</span></font><font
size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:black'> example</span></font><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>.&nbsp; The result of my change conflicted
with my understanding of how the rules should work.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I made two modifications in the StateExampleUsingSalience.drl
file.&nbsp; The two modifications (shown below) are the commenting out of the two
lines in the RHS portion of the &#8220;B to D&#8221; rule.&nbsp; My
understanding of how this would affect the result was:&nbsp; because the &#8220;D&#8221;
State object never changes state to &#8220;State.FINISHED&#8221; the RHS
portion of the &#8220;D to E&#8221; rule (shown below) would not execute because
the first pattern in the LHS would fail to find a State object in working
memory that met the criteria of the constraint groups defined within it.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>My question is:&nbsp; Why does the &#8220;D
to E&#8221; rule in the </span></font><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>StateExampleDynamicRules.drl execute
the statements in the RHS portion of the rule?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>From StateExampleUsingSalience.drl:&nbsp; My changes in this
file are the two lines commented out in the RHS portion.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#960000"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#960000;font-weight:bold'>rule</span></font></b><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;B to
D&quot;</span></font><font size=2 face="Courier New"><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><b><font size=2
color="#960000" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#960000;font-weight:bold'>when</span></font></b><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; State(name
== </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;B&quot;</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>, state == State.FINISHED )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d
: State(name == </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;D&quot;</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>, state == State.NOTRUN )</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><b><font size=2
color="#960000" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#960000;font-weight:bold'>then</span></font></b><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2 color=olive face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:olive'>//System.out.println(d.getName() + &quot;
finished&quot; );</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2 color=olive face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:olive'>//d.setState( State.FINISHED );</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal><b><font size=2 color="#960000" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#960000;font-weight:
bold'>end<o:p></o:p></span></font></b></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>From StateExampleDynamicRules.drl:&nbsp; This is the rule
where I expected the RHS portion to NOT get executed because there aren&#8217;t
any State objects in working memory that have their name == &#8220;D&#8221; and
its state == State.FINISHED because the setState( State.FINISHED ) was never
executed on the &#8220;D&#8221; state object.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#960000"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#960000;font-weight:bold'>rule</span></font></b><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;D to
E&quot;</span></font><font size=2 face="Courier New"><span style='font-size:
10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><b><font size=2
color="#960000" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#960000;font-weight:bold'>when</span></font></b><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; State(name
== </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;D&quot;</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>, state == State.FINISHED )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e
: State(name == </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;E&quot;</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>, state == State.NOTRUN )</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><b><font size=2
color="#960000" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#960000;font-weight:bold'>then</span></font></b><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(e.getName()
+ </span></font><font size=2 color=green face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;
finished&quot;</span></font><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> );</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.setState(
State.FINISHED );</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal><b><font size=2 color="#960000" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#960000;font-weight:
bold'>end<o:p></o:p></span></font></b></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>After my modifications, the output was:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>A finished</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>B finished</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>C finished</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>E finished<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>I did not expect the &#8220;E finished&#8221;
message to be printed.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Regards,</span></font><font face=Arial><span
style='font-family:Arial'><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Daren</span></font><font face=Arial><span style='font-family:
Arial'><o:p></o:p></span></font></p>

</div>

</body>

</html>