<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>RE: Why not retracting?</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2>Thanks Jeff - I guess Rules Engines were common New Years
resolution (I'm about 2 weeks in too) ;-)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2>I understood that the LHS side was operated upon when Facts
were asserted which, I think, creates the RHS Activation in the Agenda.
However I also thought that if the RHS modified Facts in the Working Memory (by
retracting, asserting or modifying them) the "Two Phase Execution" (Agenda,
Section 1.6.5) reassessed which rules needed "firing" (activation?) and hence
some of the "Cost - calculate cost for 'Stamping process' on a process" rules
(in my example below) would be disposed of. Is the activation not being dropped
(perhaps because the "machine == ( m )" condition is still met all be it that
the Price to which it relates as been disposed of?). </FONT></SPAN><SPAN
class=435194516-26012007><FONT face=Arial color=#0000ff size=2>I thought we were
encouraged to write rules that didn't need to be ran in any particular order
whereas I now find myself having to run some before others?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2>I'm not ranting at you Jeff, I'm just
confused.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=435194516-26012007><FONT face=Arial
color=#0000ff size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Grimshaw,
Jeffrey<BR><B>Sent:</B> 26 January 2007 16:34<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> RE: [rules-users] RE: Why not
retracting?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr align=left><SPAN class=497272416-26012007><FONT face=Arial
color=#0000ff size=2>Hi Michael. I've only been using JBoss Rules for
about 2 weeks, so keep that in mind when reading my reply.
</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=497272416-26012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=497272416-26012007><FONT face=Arial
color=#0000ff size=2>The way I understand it works is that facts are evaluated
against the LHS of all the rules in the ruleset as they are
asserted. That is, when a fact is added to the WorkingMemory, the engine
determines which rules apply to that fact. You may expect
that evaluation to take place when the rules are "run". This may
have something to do with the behavior you are seeing.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=497272416-26012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=497272416-26012007><FONT face=Arial
color=#0000ff size=2>For more info on what I'm talking about, see section
1.6.4.2 of the user docs. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=497272416-26012007><FONT face=Arial
color=#0000ff size=2><A
href="http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.5/html/index.html">http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.5/html/index.html</A></FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=497272416-26012007><FONT face=Arial color=#0000ff
size=2>Cheers,</FONT></SPAN></DIV><!-- Converted from text/rtf format -->
<P><SPAN lang=en-us><FONT face=Arial color=#0000ff size=2>--Jeff</FONT></SPAN>
</P>
<DIV> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Anstis,
Michael (M.)<BR><B>Sent:</B> Friday, January 26, 2007 8:08 AM<BR><B>To:</B>
Rules Users List<BR><B>Subject:</B> [rules-users] RE: Why not
retracting?<BR></FONT><BR></DIV>
<DIV></DIV><!-- Converted from text/rtf format -->
<P><FONT face=Arial color=#0000ff size=2>By way of an update; if the
retraction is made within a different Agenda Group the rules work as
expected.</FONT> </P>
<P><FONT face=Arial color=#0000ff size=2>However the problem of the retraction
having no obvious affect when operated within the same Agenda Group
remains.</FONT> </P>
<P><FONT face=Arial color=#0000ff size=2>Is this a bug?</FONT> </P>
<UL>
<P><FONT face=Tahoma size=1>_____________________________________________
</FONT><BR><B><FONT face=Tahoma size=1>From: </FONT></B> <FONT
face=Tahoma size=1>Anstis, Michael (M.) </FONT><BR><B><FONT
face=Tahoma size=1>Sent: </FONT></B> <FONT face=Tahoma size=1>26
January 2007 11:32</FONT> <BR><B><FONT face=Tahoma
size=1>To: </FONT></B> <FONT face=Tahoma
size=1>'Rules Users List'</FONT> <BR><B><FONT face=Tahoma
size=1>Subject: </FONT></B> <FONT
face=Tahoma size=1>Why not retracting?</FONT> </P>
<P><FONT face=Arial size=2>Hello,</FONT> </P>
<P><FONT face=Arial size=2>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 face="Courier New" size=2>rule "Cost - remove prices that do not
have the required 'Economic Level'"</FONT> <BR><FONT face="Courier New"
size=2>agenda-group "stamping-costs"</FONT> <BR><FONT face="Courier New"
size=2>//</FONT><FONT face="Courier New" size=2>salience 1</FONT>
<BR><FONT face="Courier New" size=2>when</FONT>
<BR> <FONT face="Courier New"
size=2>p : Price ( economicLevel != ( Utilities.makeDate(1, 1, 2007) )
)</FONT> <BR><FONT face="Courier New" size=2>then</FONT>
<BR> <FONT face="Courier New"
size=2>System.out.println("Retracting "+p.toString());</FONT>
<BR> <FONT face="Courier New"
size=2>retract(p);</FONT> <BR><FONT face="Courier New" size=2>end</FONT>
</P>
<P><FONT face="Courier New" size=2>rule "Cost - calculate cost for
'Stamping process' on a process"</FONT> <BR><FONT face="Courier New"
size=2>agenda-group "stamping-costs"</FONT> <BR><FONT face="Courier New"
size=2>//</FONT><FONT face="Courier New" size=2>salience</FONT> <FONT
face="Courier New" size=2>2</FONT> <BR><FONT face="Courier New"
size=2>when</FONT> <BR> <FONT
face="Courier New" size=2>r : ResourceEntry ( m : machine )</FONT>
<BR> <FONT face="Courier New"
size=2>//</FONT><FONT face="Courier New" size=2>p : Price ( economicLevel
== ( Utilities.makeDate(1, 1, 2007) ), machine == ( m ) )</FONT>
<BR> <FONT face="Courier New"
size=2>p : Price ( machine == ( m ) )</FONT> <BR><FONT face="Courier New"
size=2>then</FONT> <BR> <FONT
face="Courier New" size=2>Cost cost = new Cost(r, p);</FONT>
<BR> <FONT face="Courier New"
size=2>cost.setCost((float) (r.getUsage() * p.getRate()));</FONT>
<BR> <FONT face="Courier New"
size=2>assert(cost);</FONT> <BR><FONT face="Courier New" size=2>end</FONT>
</P></UL>
<P><FONT face=Arial size=2>The problem is that the "Cost" rule still works
upon ALL "Prices" (even those with an incorrect "Economic Level").</FONT>
</P>
<P><FONT face=Arial size=2>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 face=Arial size=2>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 face=Arial size=2>What am I doing wrong?</FONT> </P>
<P><FONT face=Arial size=2>Cheers,</FONT> </P>
<P><FONT face=Arial size=2>Mike</FONT> </P></UL></BLOCKQUOTE></BODY></HTML>