[rules-users] Help with Accumulate function

Wolfgang Laun wolfgang.laun at gmail.com
Thu Apr 7 03:44:16 EDT 2011


Repeated firing may be due to there being more than one scope for
accumulating
the sum, as selected by the patterns leading up to the accumulate.

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.

-W


On 7 April 2011 08:44, dwipin <dwipin.c at tcs.com> wrote:

> Hi,
>  I am having trouble implementing this rule with the accumulate function.
> My rule requirement is -
> Aggregate all PnlAttributionAmounts with a type of "UNEXPLAINED" for all
> Positions for a given day.
>
> Below is the code I have for this -
>
> $position : Position(date == $currDate)
> $posScn : PositionScenario(scenario == 'SCEN-EOD', position == $position )
> $posScnGrp : PositionScenarioCurrencyGroup(positionScenario == $posScn,
> currencyType == CurrencyTypes.TRANSACTIONAL)
> $posPnlAmt : PositionPnlAmount(pnlAmountType == "DTD",
> positionScenarioCurrencyGroup == $posScnGrp)
> $attibAmtType : AttributionAmountType(attributionAmountType ==
> "UNEXPLAINED/RESIDUALPNL")
>
> $totalPnlAttibAmt : BigDecimal()
>        from accumulate(
>                PositionPnlAttributionAmount(positionPnlAmount ==
> $posPnlAmt, attributionAmountType == $attibAmtType, $pnlAttibAmt :
> financialValue)
>                ,sum($pnlAttibAmt)
>        )
>
> eval ($totalPnlAttibAmt > 1000)
>
> When I do it this way, the rule gets executed 6 times, basically for every
> fact that evaluated to true. How do I restrict this? The rule should be
> executed only if the final eval results in true.
>
> Thanks for any help,
> Dwipin.
>
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Help-with-Accumulate-function-tp2789194p2789194.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110407/34a39374/attachment.html 


More information about the rules-users mailing list