Let's say I have 2 rooms:
- Room A with penalty 10
- Room B with penalty 5
Both are inserted into the WM and never change.
Let's say I have 1 exam:
- Exam X which starts out assigned to Room A.
It's inserted into the WM, but it will change when rules are fired.
Let's say I have this rule:
rule "roomPenalty"
when
$exam : Exam();
then
Object cause = $exam;
int weight = $exam.getRoom().getPenalty();
insertLogical(new Penalty(cause, weight);
end
After my first fireAllRules, there is 1 logical asserted Penalty(10).
Next, I switch Exam X to Room B (instead of Room A) and I fire all Rules.
The _same_ rule applies on the _same_ fact and a logical asserted
Penalty(5) is inserted.
How do I enable the following different use cases?
1) Keep Penalty(10), discard Penalty(5)
2) Remove Penalty(10), add Penalty(5)
3) Keep Penalty(10), add Penalty(5)
What happens if:
1) Penalty's equals/hashcode only uses "cause"?
2) Penalty's equals/hashcode uses both "cause" and "weight"?
--
With kind regards,
Geoffrey De Smet