Drools 创建自定义乐谱
所以我在 drools: 中创建了一个自定义分数
public interface MyScore extends Score<MyScore>
并实现了它。但是我不知道如何使用分数。该配置有一个
<scoreDefinition>
标签,但将除 SIMPLE 或 HARD_AND_SOFT 之外的任何内容放入其中都会产生错误。
如何配置求解器以使用我创建的分数,文档似乎暗示这是可能的,但没有详细说明。
So I've created a custom score in drools:
public interface MyScore extends Score<MyScore>
and have implemented it. However I can't see how to use the score. The config has a
<scoreDefinition>
tag but putting anything inside this other than SIMPLE or HARD_AND_SOFT produces an error.
How can I configure the solver to use the score I've created, the docs seem to imply this is possible but doesn't go into any detail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这原本是可能的(也是一种正常的做法),但存在一个障碍。
我刚刚添加了此文档:
实现自定义分数
要实现自定义分数,您还需要实现自定义 ScoreDefinition。扩展 AbstractScoreDefinition(最好通过复制粘贴 HardAndSoftScoreDefinition 或 SimpleScoreDefinition)并从那里开始。
接下来,在 SolverConfig.xml 中挂钩自定义 ScoreDefinition:
障碍
我将针对 5.3 或 5.4 修复一个障碍:
ScoreDefinitionConfig 有以下代码:
解决该问题的一种方法是扩展 ScoreDefinitionConfig 并覆盖该方法,如手册中使用自定义选择器、接受器或觅食器部分中所述。
This was meant to be possible (and a normal practice), but there's a roadblock.
I just added this documentation:
Implementing a custom Score
To implement a custom Score, you 'll also need to implement a custom ScoreDefinition. Extend AbstractScoreDefinition (preferable by copy pasting HardAndSoftScoreDefinition or SimpleScoreDefinition) and start from there.
Next, hook you custom ScoreDefinition in your SolverConfig.xml:
The Roadblock
There's a roadblock that I 'll fix for 5.3 or 5.4:
ScoreDefinitionConfig has this code:
One way to deal with that is to extend ScoreDefinitionConfig and overwrite that method, as described in the manual in the section using a custom Selector, Acceptor or Forager.
据我所知,可能不支持自定义分数,这很遗憾......
我检查了 ScoreDefinitionConfig 类,我看到了这个:
那么,除了 SIMPLE 和 HARD_AND_SOFT 之外的任何东西都不能削减它......
对此有什么见解吗?
克罗恩,
路易斯
For what I could see, there could be no support for custom scores, which is a shame...
I checked the ScoreDefinitionConfig class and I saw this:
So, anything other than SIMPLE and HARD_AND_SOFT doesn't cut it...
Any insights on this?
KR,
Luis