[rules-users] Prevent re-evaluation of events in stream mode

Wolfgang Laun wolfgang.laun at gmail.com
Tue Dec 10 00:53:31 EST 2013


accumulate (irrespective of its form and particular coding) is
absolutely fickle and finicky in a changing fact data base. The basic
caveat is that each change to the domain of the accumulat CE starts a
new game.

Forget accumulate, roll your own!

Set up a fact type Avg that's capable of holding the running average
for an account (and other data that may be useful). One rule inserts
an Avg if it isn't there for a new Transactions and initializes the
average. Another rule should just extend the average while the count
is below 100. And for the 101st Transaction to arrive,  the third rule
checks the amount and modifies the average, too. Obviously, you'll
have to keep 100 amounts in Avg as well in order to remove the
contribution of the 1st Transaction, or you just continue to extend
the average.

Note that this permits you to drop Transactions from the system
earlier than with accumulate, which should more than compensate for
the additional memory requirements due to Avg for each observed
account.

Average may be a poor threshold for raising an alarm, but I suspect
you haven't been showing all of your cards ;-)

-W


On 09/12/2013, sumantp <sumantp at yahoo.com> wrote:
> I forgot to include some output from my test. It shows that the two $600
> transactions do not initially trigger alerts (as expected), the $800 one
> triggers an alert (as expected), but the $100 one results in alerts for the
> first 3 transaction (not expected).
>
> Inserting Account = 1, Amount = 600.0, current average = 600.0
> Inserting Account = 1, Amount = 600.0, current average = 600.0
> Inserting Account = 1, Amount = 800.0, current average = 666.6666666666666
> 	***ALERT***: Higher than average transaction amount (Average =
> 666.6666666666666): Account = 1, Amount = 800.0
> Inserting Account = 1, Amount = 100.0, current average = 525.0
> 	***ALERT***: Higher than average transaction amount (Average = 525.0):
> Account = 1, Amount = 800.0
> 	***ALERT***: Higher than average transaction amount (Average = 525.0):
> Account = 1, Amount = 600.0
> 	***ALERT***: Higher than average transaction amount (Average = 525.0):
> Account = 1, Amount = 600.0
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Prevent-re-evaluation-of-events-in-stream-mode-tp4027171p4027172.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list