[rules-users] Help with Accumulate function

Dwipin C dwipin.c at tcs.com
Thu Apr 7 03:58:19 EDT 2011


Without the accumulate function, following is the fire occurrence- 

$position : Position() - 2
$posScn : PositionScenario(scenario == 'SCEN-EOD', position == $position ) 
- 2 ( with all above facts)
$posScnGrp : PositionScenarioCurrencyGroup(positionScenario == $posScn, 
currencyType == CurrencyTypes.TRANSACTIONAL) - 2 ( with all above facts)
$posPnlAmt : PositionPnlAmount(pnlAmountType == "DTD", 
positionScenarioCurrencyGroup == $posScnGrp) - 3 ( with all above facts)

$attibAmtType : AttributionAmountType(attributionAmountType == 
"UNEXPLAINED/RESIDUALPNL") - 2 (just this fact)

All of them together without the accumulate fires it 6 times.


Dwipin




From:
Wolfgang Laun <wolfgang.laun at gmail.com>
To:
Rules Users List <rules-users at lists.jboss.org>
Date:
04/07/2011 01:16 PM
Subject:
Re: [rules-users] Help with Accumulate function
Sent by:
rules-users-bounces at lists.jboss.org



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
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110407/d41b553e/attachment.html 


More information about the rules-users mailing list