“不”的概念意义关键词;对象之间的评估

发布于 2025-01-04 02:06:36 字数 574 浏览 5 评论 0原文

我试图在 Drools Planner 项目中找到一个具有最小 totalBucketTotal 对象。我根据示例代码改编了它。

rule "insertMinimumBucketTotal"
when
   $b : BucketTotal($total : total)
   not BucketTotal(total > $total) // CONFUSED HERE
then
   insertLogical(new MinimumBucketTotal($total));
end

就我的推理而言,这意味着“找到 BucketTotal 对象 $b,这样就不存在另一个 BucketTotal 对象,其 total大于$b总计”。

事实证明,这意味着相反(我纠正了它)。


请解释 Drools 如何推理该语句来查找 $b

I am trying to find a BucketTotal object which has the smallest total in a Drools Planner project. I adapted this from example code.

rule "insertMinimumBucketTotal"
when
   $b : BucketTotal($total : total)
   not BucketTotal(total > $total) // CONFUSED HERE
then
   insertLogical(new MinimumBucketTotal($total));
end

As far as my reasoning went, it meant "find BucketTotal object $b, such that there doesnt exist another BucketTotal object whose total is greater than total of $b".

Turns out, it meant the opposite (and I corrected it).


Please explain how Drools reasons that statement to find $b.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可爱暴击 2025-01-11 02:06:36

确实你的事情令人困惑。 “不”的意思是“不存在”。因此,如果您想找到最小总数,您可以这样做:

rule "minimum"
when
   BucketTotal( $min : total )
   not BucketTotal( total < $min )
then
   // do something with $min
end

上述通常是性能更高的方法,但如果您愿意,也可以使用累积:

rule "minimum"
when
    accumulate( BucketTotal( $total : total ),
                $min : min( $total ) )
then
    // do something with $min
end

Indeed your are confusing things. "not" means "not exists". So if you want to find the minimum total you can do:

rule "minimum"
when
   BucketTotal( $min : total )
   not BucketTotal( total < $min )
then
   // do something with $min
end

The above is usually the more performant way of doing it, but you can also use accumulate if you prefer:

rule "minimum"
when
    accumulate( BucketTotal( $total : total ),
                $min : min( $total ) )
then
    // do something with $min
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文