Repeated firing may be due to there being more than one scope for accumulating<br>the sum, as selected by the patterns leading up to the accumulate.<br><br>If you take only the patterns preceding the accumulate - how often does this fire and for which elements? You need a single combination of $posPnlAm and $attibAmtType.<br>
<br>-W<br><br><br><div class="gmail_quote">On 7 April 2011 08:44, dwipin <span dir="ltr"><<a href="mailto:dwipin.c@tcs.com">dwipin.c@tcs.com</a>></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;">
Hi,<br>
I am having trouble implementing this rule with the accumulate function.<br>
My rule requirement is -<br>
Aggregate all PnlAttributionAmounts with a type of "UNEXPLAINED" for all<br>
Positions for a given day.<br>
<br>
Below is the code I have for this -<br>
<br>
$position : Position(date == $currDate)<br>
$posScn : PositionScenario(scenario == 'SCEN-EOD', position == $position )<br>
$posScnGrp : PositionScenarioCurrencyGroup(positionScenario == $posScn,<br>
currencyType == CurrencyTypes.TRANSACTIONAL)<br>
$posPnlAmt : PositionPnlAmount(pnlAmountType == "DTD",<br>
positionScenarioCurrencyGroup == $posScnGrp)<br>
$attibAmtType : AttributionAmountType(attributionAmountType ==<br>
"UNEXPLAINED/RESIDUALPNL")<br>
<br>
$totalPnlAttibAmt : BigDecimal()<br>
from accumulate(<br>
PositionPnlAttributionAmount(positionPnlAmount ==<br>
$posPnlAmt, attributionAmountType == $attibAmtType, $pnlAttibAmt :<br>
financialValue)<br>
,sum($pnlAttibAmt)<br>
)<br>
<br>
eval ($totalPnlAttibAmt > 1000)<br>
<br>
When I do it this way, the rule gets executed 6 times, basically for every<br>
fact that evaluated to true. How do I restrict this? The rule should be<br>
executed only if the final eval results in true.<br>
<br>
Thanks for any help,<br>
Dwipin.<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Help-with-Accumulate-function-tp2789194p2789194.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Help-with-Accumulate-function-tp2789194p2789194.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>