<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>Why not retracting?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hello,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I have the following rules; one removes "Prices" that do not have the required "Economic Level" from working memory, the other calculates a "Costs":-</FONT></P>
<UL>
<P><FONT SIZE=2 FACE="Courier New">rule "Cost - remove prices that do not have the required 'Economic Level'"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">agenda-group "stamping-costs"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">//</FONT><FONT SIZE=2 FACE="Courier New">salience 1</FONT>
<BR><FONT SIZE=2 FACE="Courier New">when</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">p : Price ( economicLevel != ( Utilities.makeDate(1, 1, 2007) ) )</FONT>
<BR><FONT SIZE=2 FACE="Courier New">then</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">System.out.println("Retracting "+p.toString());</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">retract(p);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">end</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">rule "Cost - calculate cost for 'Stamping process' on a process"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">agenda-group "stamping-costs"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">//</FONT><FONT SIZE=2 FACE="Courier New">salience</FONT> <FONT SIZE=2 FACE="Courier New">2</FONT>
<BR><FONT SIZE=2 FACE="Courier New">when</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">r : ResourceEntry ( m : machine )</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">//</FONT><FONT SIZE=2 FACE="Courier New">p : Price ( economicLevel == ( Utilities.makeDate(1, 1, 2007) ), machine == ( m ) )</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">p : Price ( machine == ( m ) )</FONT>
<BR><FONT SIZE=2 FACE="Courier New">then</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">Cost cost = new Cost(r, p);</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">cost.setCost((float) (r.getUsage() * p.getRate()));</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">assert(cost);</FONT>
<BR><FONT SIZE=2 FACE="Courier New">end</FONT>
</P>
</UL>
<P><FONT SIZE=2 FACE="Arial">The problem is that the "Cost" rule still works upon ALL "Prices" (even those with an incorrect "Economic Level").</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">If I change the line in the "Cost" rule to also check the "Economic Level" the rules work as expected (i.e. "Costs" are only calculated using "Prices" with an "Economic Level" of 01/01/2007).</FONT></P>
<P><FONT SIZE=2 FACE="Arial">I've tried using "salience" levels too (as commented in the above Rules) but this doesn't have any effect either.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">What am I doing wrong?</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Cheers,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Mike</FONT>
</P>
</BODY>
</HTML>