我曾尝试在Drools的用户论坛上发帖,但没有得到任何回复(我相信他们只是忙碌),所以我希望能吸引更广泛的观众。
我对我得到的结果非常困惑,因为他们似乎没有给我提供“最佳分数”。以下是一些日志输出:
[construction steps]
2013-03-13 08:00:08,305 [com....] INFO Phase constructionHeuristic ended: step total (60), time spend (2222), best score (-200hard/-2780soft).
[local search steps]
2013-03-13 08:00:21,807 [com....] INFO Phase localSearch ended: step total (42), time spend (15724), best score (0hard/-2495soft).
2013-03-13 08:00:21,807 [com....] INFO Solving ended: time spend (15724), best score (0hard/-2495soft), average calculate count per second (3748).
然而,它给我的结果包含一个破坏的硬约束(即使日志明确指出“解决结束:时间花费(15724),最佳分数(0hard / -2495soft)”) - 它给了我一个结果得分为-200hard / -2495soft(这似乎是施工阶段的硬分数和本地搜索阶段的软分数)。这是怎么回事?我是否遗漏了手册中的内容(我已经阅读过,但我还没有完全消化它)?
这是我的解算器配置的大部分(只是可能相关的部分):
<termination>
<terminationCompositionStyle>OR</terminationCompositionStyle>
<maximumSecondsSpend>60</maximumSecondsSpend>
<scoreAttained>0hard/0soft</scoreAttained>
</termination>
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
<constructionHeuristicPickEarlyType>FIRST_LAST_STEP_SCORE_EQUAL_OR_IMPROVING</constructionHeuristicPickEarlyType>
</constructionHeuristic>
<localSearch>
<termination>
<terminationCompositionStyle>OR</terminationCompositionStyle>
<maximumUnimprovedStepCount>20</maximumUnimprovedStepCount>
<scoreAttained>0hard/0soft</scoreAttained>
</termination>
<unionMoveSelector>
<changeMoveSelector>
<entitySelector>
<entityFilterClass>com.....RequiredTypeEntityFilter</entityFilterClass>
</entitySelector>
</changeMoveSelector>
<swapMoveSelector>
<entitySelector>
<entityFilterClass>com.....RequiredTypeEntityFilter</entityFilterClass>
</entitySelector>
</swapMoveSelector>
</unionMoveSelector>
<acceptor>
<solutionTabuSize>1000</solutionTabuSize>
<planningEntityTabuSize>7</planningEntityTabuSize>
</acceptor>
<forager>
<minimalAcceptedSelection>1000</minimalAcceptedSelection>
</forager>
</localSearch>
提前致谢!
编辑:这里有一些可能有用的信息...如上所述,它表示我的最佳(硬)得分为0,但它给出的解决方案包含一个硬约束违反。我添加了一些代码来打印出约束(使用DroolsScoreDirector来访问WorkingMemory并最终得到ConstraintOccurrences)...这个打印输出也显示了一个硬约束。
ConstraintType: NEGATIVE_HARD, RuleID: endLocationMustMatchStartLocation, Causes:...
答案 0 :(得分:1)
最有可能的是,您的cloneSolution()方法已损坏(或者它调用的entity.clone()方法)。仔细检查那些方法。
In Drools Planner 6.0, you won't need to implement that cloning method.