-
Enhancement
-
Resolution: Obsolete
-
Major
-
None
-
None
-
NEW
-
NEW
ActivationUnMatchListener is part of kie-internal, so its not public API.
ActivationUnMatchListener is only used by OptaPlanner (probably):
jBPM and downstream drools module don't use it:
https://github.com/search?q=org%3Akiegroup+ActivationUnMatchListener&type=Code
Community users probably don't use it either, because no one mentions it on StackOverflow:
https://www.google.be/search?q=%2BActivationUnMatchListener+site:stackoverflow.com&*
The current behaviour of ActivationUnMatchListener is a pain because it doesn't unmatch if a RHS fires again, causing an imbalance. OptaPlanner works around this through a hack (which fails for PLANNER-761).
For example, given this rule
global int score = 0;
rule R
when
Wine(age < 10, $age : age)
then
score += $age;
addUnmatchListener(() -> score -= $age);
end
This works for a normal match and unmatch event:
Wine w = new Wine(3); insert(w); fireAllRules(); => score = 7; w.age = 50; update(w); fireAllRules(); => unmatch triggers => score = 0; // GOOD
So events are like this:
RHS unmatch
However if we have a rematch:
Wine w = new Wine(3); insert(w); fireAllRules(); => score = 7; w.age = 4; update(w); fireAllRules(); => no unmatch triggers => score = 13; // BAD Should be 6. Unmatch should have triggered. w.age = 50; update(w); fireAllRules(); => unmatch triggers => score = 7; // Should be 0.
Because the events are unbalanced:
RHS RHS unmatch
I'd argue that anyone using the ActivationUnMatchListener would want to the have balanced events.
- blocks
-
PLANNER-761 Score DRL: a then side that doesn't always call addConstraintMatch corrupts the score
- Resolved