If you have *either*<br>   Fact1( $m : month, $s1 : score )<br>   Fact2( month == $m, $s2 : score )<br><br>*or*<br>   Fact1( $m : month, $s1 : score )<br>
   Fact2( month == $m, $s2 : score )<br>   Fact3( month == $m, score == $1 + $2 )<br><br>then you can easily write two rules that (a) detect the<br>first case and progress to the second one (without insertLogical),<br>and (b) detect an aberration from the second one and fix the<br>
score sum.<br><br>-W<br><br><br><br><div class="gmail_quote">On 4 August 2010 12:28, Stephen Mcgruer <span dir="ltr">&lt;<a href="mailto:s0840449@sms.ed.ac.uk">s0840449@sms.ed.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey,<br>
<br>
We have the following situation: Fact1 and Fact2 both have a &#39;score&#39;<br>
property. They also both have a &#39;month&#39; property. When a Fact1 and a<br>
Fact2 have the same month (at most there will only be one such pairing<br>
for each month), a Fact3 is created with a score made from adding the<br>
two base Facts scores:<br>
<br>
rule &quot;ExampleRule&quot;<br>
        dialect &quot;mvel&quot;<br>
        when<br>
             Fact1( fact1Month : month, fact1Score : score &gt; 0)<br>
             Fact2( month == fact1Month, fact2Score : score &gt; 0)<br>
         then<br>
             Fact3 fact3 = new Fact3();<br>
             fact3.setScore( fact1Score + fact2Score);<br>
             insertLogical(fact3);<br>
end<br>
<br>
Our problem is that if fact1Score or fact2Score is now changed, a new<br>
Fact3 with a new score is created, *but* the old Fact3 is of course<br>
not removed - the conditions in its when still hold true as well (the<br>
new score is still above 0).<br>
<br>
Can anyone think of a way to make sure that if either fact1Score or<br>
fact2Score is changed, then the old fact3 is removed from memory?<br>
<br>
The only way we could at all think to do this is to add a timestamp to<br>
fact3, and to have another rule that retracts old fact3s if there is<br>
one with a newer timestamp and the same month... but it seems horribly<br>
messy.<br>
<br>
Thanks,<br>
Stephen<br>
<br>
--<br>
The University of Edinburgh is a charitable body, registered in<br>
Scotland, with registration number SC005336.<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>