Optaplanner 多线程尝试在自定义移动时产生了"missing rebase"



我从 7.5 更新到 7.9 Optaplanner 库以用于护士代码的变体,并使用发行说明(例如,更改了一些方法名称(成功重建和重新运行。 然后,我将"moveThreadCount"xml行(用于多线程(添加到我的求解器配置xml中。 <moveThreadCount>AUTO</moveThreadCount>

然后运行立即抛出错误: Caused by: java.lang.UnsupportedOperationException: The custom move class (class westgranite.staffrostering.solver.move.EmployeeChangeMove) doesn't implement the rebase() method, so multithreaded solving is impossible.

我确实有许多自定义动作。 我在发行说明中没有看到任何关于需要添加 rebase(( 方法的引用,也没有在当前(较新的(文档部分中看到对 rebase(( 的引用。 https://docs.optaplanner.org/7.12.0.Final/optaplanner-docs/html_single/index.html#customMoves

有人可以指出正确的方法吗? 谢谢!

我建议阅读这篇优秀的博客文章:http://www.optaplanner.org/blog/2018/07/03/AGiantLeapForwardWithMultithreadedIncrementalSolving.html 因为它对多线程求解的工作原理进行了更深入的解释。

我还建议阅读有关 rebase 方法的 javadoc,它应该为您指明正确的方向:https://docs.optaplanner.org/7.12.0.Final/optaplanner-javadoc/org/optaplanner/core/impl/heuristic/move/Move.html#rebase-org.optaplanner.core.impl.score.director.ScoreDirector-

下面是一个示例:

public class CloudComputerChangeMove extends AbstractMove<CloudBalance> {
private CloudProcess cloudProcess;
private CloudComputer toCloudComputer;
...
@Override
public CloudComputerChangeMove rebase(ScoreDirector<CloudBalance> destinationScoreDirector) {
return new CloudComputerChangeMove(
destinationScoreDirector.lookUpWorkingObject(cloudProcess),
destinationScoreDirector.lookUpWorkingObject(toCloudComputer));
}
}

最新更新