Drools Planner 规则仅触发一次
我有一个形式的规则,
rule "notBar"
when
$foo : Foo(bar == false)
then
insertLogical(new IntConstraintOccurrence("notBar", ConstraintType.NEGATIVE_SOFT,
$foo));
end
我希望看到每个 Foo 都会触发一次,而 bar 为 false,但该规则仅触发一次。令人困惑的是,如果我将 $foo : Foo(bar == false)
更改为 $foo : Foo()
那么它会为所有 Foo 正确触发。 我缺少什么?
I have a rule of the form
rule "notBar"
when
$foo : Foo(bar == false)
then
insertLogical(new IntConstraintOccurrence("notBar", ConstraintType.NEGATIVE_SOFT,
$foo));
end
I expect to see this fired once for every Foo with bar being false however the rule is only fired once. Confusingly if I change the $foo : Foo(bar == false)
to $foo : Foo()
then it is correctly fired for all Foo's.
What am I missing?
呸。我是个白痴。我的cloneSolution方法正在调用一个复制构造函数,但它没有正确复制bar。
Bah. I'm an idiot. My cloneSolution method was calling a copy constructor which didn't correctly copy bar.