流口水专家/求解器 - 5.0.1 匹配
我对流口水还很陌生,我遇到了一些我无法真正理解的问题。 我正在尝试解决分配问题,但由于某种原因,我的 LHS 之一像这样,
$leftAlloc: SlotAllocation($leftRes: resource ) $rightAlloc: SlotAllocation(this != $leftAlloc, resource == $leftRes)
第二个语句与任何内容都不匹配,即使我确信工作内存中存在匹配项。 如果我用以下代码更改上面的代码,它就可以正常工作
$leftAlloc: SlotAllocation($leftRes: resource ) $rightAlloc: SlotAllocation(this != $leftAlloc, eval(resource == $leftRes))
有人可以向我解释一下吗?
谢谢!
I am fairly new to drools and I'm running into some issues I can't really understand.
I'm trying to solve an allocation problem and one of my LHS goes like this
$leftAlloc: SlotAllocation($leftRes: resource ) $rightAlloc: SlotAllocation(this != $leftAlloc, resource == $leftRes)
for some reason the second statement does not match anything even thou I'm sure there is a match in the working memory. If I change the code above with the following it works fine
$leftAlloc: SlotAllocation($leftRes: resource ) $rightAlloc: SlotAllocation(this != $leftAlloc, eval(resource == $leftRes))
Can anybody explain this to me?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能最好在 drools 用户邮件列表上询问这个问题(如果您不想乱扔邮箱,请使用新闻组阅读器连接到 news.gmane.org)。
至于你的问题:这真的很奇怪。 我只看到一个不太可能的解释:
首先你应该知道DRL中的
resource == $leftRes)
实际上会调用getResource().equals($leftRes)
,所以它是不是相同/指针检查,而是等于检查。另一方面,
eval(resource == $leftRes)
将使用相同/指针检查。因此,这个不太可能的理论是,您的 Resource 类覆盖了
Object.equals
方法,并且当它是同一实例时甚至不返回 true...PS:如果您有,请在用户邮件列表上继续此讨论还有更多问题,您也希望得到解答。
You're probably better off asking this question on the drools user mailing list (use a newsgroup reader to connect to news.gmane.org if you don't want to litter your mailbox).
As for your question: that's really strange. I see only one improbable explanation:
First you should know that
resource == $leftRes)
in the DRL will actually callgetResource().equals($leftRes)
, so it's not a same/pointer check but an equals check.On the other hand,
eval(resource == $leftRes)
will use a same/pointer check.So that improbably theory is that your Resource class overwrites the
Object.equals
method and doesn't even return true when it's the same instance...PS: Continue this discussion on the user mailing list if you have further questions and you want those answered too.