Re: [rules-users] Help with Accumulate function
Thanks Wolfgang. The issue here is that the accumulation has to happen at a higher level in the object hierarchy, "Position" in this case. However, this is no direct link between Position and PostitionPnlAttributionAmount ( which is being accumulated). How do I tackle such a scenario? $attibAmtType will be just one for the condition given, but there could be multiple $posPnlAmt within a Position. Thanks, Dwipin From: Wolfgang Laun To: Rules Users List Date: 04/07/2011 02:08 PM Subject: Re: [rules-users] Help with Accumulate function Sent by: rules-users-boun...@lists.jboss.org Well, this explains it - you'll have to find the selecting combination of $posPnlAmt and $attibAmtType in a unique way, assuming there is just one such combination. -W 2011/4/7 Dwipin C > > 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 > To: Rules Users List > Date: 04/07/2011 01:16 PM > Subject: Re: [rules-users] Help with Accumulate function > Sent by: rules-users-boun...@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 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@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ > rules-users mailing list > rules-users@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 > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users >
Re: [rules-users] Help with Accumulate function
One way to exclude siblings for a fact X is to use a constraint such as "there is no other X with an identifying, comparable id < than the only one I want". X( $id: id, $interesting: interesting ) not X( id < $id ) -W On 7 April 2011 10:37, Wolfgang Laun wrote: > Well, this explains it - you'll have to find the selecting combination > of $posPnlAmt and $attibAmtType in a unique way, assuming there is > just one such combination. > > -W > > > > > 2011/4/7 Dwipin C >> >> 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 >> To: Rules Users List >> Date: 04/07/2011 01:16 PM >> Subject: Re: [rules-users] Help with Accumulate function >> Sent by: rules-users-boun...@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 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@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> ___ >> rules-users mailing list >> rules-users@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 >> >> >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Help with Accumulate function
Well, this explains it - you'll have to find the selecting combination of $posPnlAmt and $attibAmtType in a unique way, assuming there is just one such combination. -W 2011/4/7 Dwipin C > > 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 > To: Rules Users List > Date: 04/07/2011 01:16 PM > Subject: Re: [rules-users] Help with Accumulate function > Sent by: rules-users-boun...@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 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@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ > rules-users mailing list > rules-users@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 > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Help with Accumulate function
The issue here is that the accumulation has to happen at a higher level in the object hierarchy, "Position" in this case. However, this is no direct link between Position and PostitionPnlAttributionAmount ( which is being accumulated). How do I tackle such a scenario? Thanks, Dwipin. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Help-with-Accumulate-function-tp2789194p2789411.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Help with Accumulate function
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 To: Rules Users List Date: 04/07/2011 01:16 PM Subject: Re: [rules-users] Help with Accumulate function Sent by: rules-users-boun...@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 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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Help with Accumulate function
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 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@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Help with Accumulate function
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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users