[rules-users] Implementing Refraction with Drools

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jan 22 11:18:17 EST 2013


The AgendaFilter you propose is bound to cause problems if rules
are intended to fire repeatedly. I have a demo consisting of a single rule,
to be fired many times with varying data; certain patterns are bound
to occur again. Adding the proposed agenda filter produces an
incorrect result.

Also note the statistics:
3906 activations were encountered (Set.count() at the end)
3593 activations remain in the List at the end of the run
313 activations were skipped due to the filter.

The number of remaining activations is an strong indication
that this approach may result in a memory leak.

-W


On 22/01/2013, magaram <magaram at deltadentalmi.com> wrote:
> Thanks for pointing me to the post Davide.
>
> >From a performance perspective I agree there are concerns. I have provided
> some numbers of what I saw
> for situations firing several rules over several tuples at the end of this
> post -
>
> However, I ran some self loop and complex loop scenarios through this
> approach and they seemed to hold. Can you elaborate on why this does not
> solve the refraction scenario?
>
> The way I understand refraction is -
>
>        This term comes from the neurobiological observation of a refractory
>
> period for a neuron, which means that the neuron is not able to fire
> immediately without first going through a relaxation process.  In a
> similar way, OPS5 will not allow the same instantiation in the conflict
>
> set from firing twice in a row.  This prevents the inference engine from
>
> entering into an infinite loop.
>
> I was reading through  apost from Mark Proctor on this when I had the idea
> of investigating this approach.
>
> http://blog.athico.com/2010/07/slot-specific-and-refraction.html
>
>
> ----------Log snip starts -----------------------
> <21 Jan 17:23:45> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Creating KnowledgeBuilder] = 2
> <21 Jan 17:23:46> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Loading DROOLS ruleset into KnowledgeBuilder] =
> 809
> <21 Jan 17:23:46> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Creating Knowledgebase] = 1
> <21 Jan 17:23:46> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Loading KnowledgeBase with KnowledgePackages from
> KnowledgeBuilder] = 110
> <21 Jan 17:23:46> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Creating StatefulKnowledgeSession for
> KnowledgeBase] = 0
> <21 Jan 17:23:46> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Asserting Facts into StatefulKnowledgeSession] =
> 24
> Encountered activation [Activation rule=BORA00105, act#=4,
> salience=9998978,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:43:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00105, act#=4, salience=9998978,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:43:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00110, act#=5,
> salience=9998975,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:43:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00110, act#=5, salience=9998975,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:43:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00115, act#=9,
> salience=9998973,
> tuple=[fact 0:8:11412609:2335260:8:null:[Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:43:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00115, act#=9, salience=9998973,
> tuple=[fact 0:8:11412609:2335260:8:null:[Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:43:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00105, act#=4,
> salience=9998978,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00105, act#=4, salience=9998978,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00110, act#=5,
> salience=9998975,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00110, act#=5, salience=9998975,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00115, act#=9,
> salience=9998973,
> tuple=[fact 0:8:11412609:2335260:8:null:[Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00115, act#=9, salience=9998973,
> tuple=[fact 0:8:11412609:2335260:8:null:[Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00135, act#=6,
> salience=9998969,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00135, act#=6, salience=9998969,
> tuple=[fact 0:33:2335229:2335229:33:DEFAULT:Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00140, act#=8,
> salience=9998968,
> tuple=[fact 0:11:10123092:2335260:11:null:[Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00140, act#=8, salience=9998968,
> tuple=[fact 0:11:10123092:2335260:11:null:[Oid = 15661383, Adj ReasonAdd,
> Adjusted BC Oid = 8150302]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00205, act#=11,
> salience=9998965, tuple=[fact 0:37:9594878:9594878:37:DEFAULT:Oid =
> 15661382, Adj ReasonTerm, Adjusted BC Oid = 8150309]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00205, act#=11, salience=9998965,
> tuple=[fact 0:37:9594878:9594878:37:DEFAULT:Oid = 15661382, Adj ReasonTerm,
> Adjusted BC Oid = 8150309]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00210, act#=12,
> salience=9998962, tuple=[fact 0:37:9594878:9594878:37:DEFAULT:Oid =
> 15661382, Adj ReasonTerm, Adjusted BC Oid = 8150309]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00210, act#=12, salience=9998962,
> tuple=[fact 0:37:9594878:9594878:37:DEFAULT:Oid = 15661382, Adj ReasonTerm,
> Adjusted BC Oid = 8150309]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Encountered activation [Activation rule=BORA00215, act#=17,
> salience=9998960, tuple=[fact 0:12:17846274:9594909:12:null:[Oid =
> 15661382,
> Adj ReasonTerm, Adjusted BC Oid = 8150309]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> Removing activation[Activation rule=BORA00215, act#=17, salience=9998960,
> tuple=[fact 0:12:17846274:9594909:12:null:[Oid = 15661382, Adj ReasonTerm,
> Adjusted BC Oid = 8150309]]
> [fact 0:2:881692:881692:2:DEFAULT:Oid= 8150317, BPSD = 03/01/2009, BPED =
> 03/31/2009, RD = 02/26/2009]
> [fact
> 0:3:21094514:21094514:45:DEFAULT:com.deltadental.billing.output.rules.BillingOutputRuleContext at 141e072]
> ]
> <21 Jan 17:23:46> <INFO> <com.deltadental.claims.rules.engine.RuleEngine>
> Time taken for operation [Firing rules in StatefulKnowledgeSession] = 24
>
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Implementing-Refraction-with-Drools-tp4021705p4021720.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