Optaplanner多线程尝试产生了“缺少基准".定制移动 [英] Optaplanner multithreading attempt yielded "missing rebase" on custom move

查看:90
本文介绍了Optaplanner多线程尝试产生了“缺少基准".定制移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Optaplanner库从7.5更新到7.9,以与不同的Nurserstering代码一起使用,并使用发行说明(例如,某些方法名称已更改)成功地重建和重新运行.然后,我在求解器配置xml中添加了"moveThreadCount" 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

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

解决方案

我建议阅读这篇出色的博客文章: <moveThreadCount>AUTO</moveThreadCount>

Running then immediately threw an error: 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.

I do have a number of custom moves. I did not see any reference to the need to add a rebase() method in the release notes, nor do I see a reference to rebase() in the current (newer) documentation section on building custom moves. https://docs.optaplanner.org/7.12.0.Final/optaplanner-docs/html_single/index.html#customMoves

Would someone please point me the right way? Thanks!

解决方案

I would suggest reading this excellent blog post: http://www.optaplanner.org/blog/2018/07/03/AGiantLeapForwardWithMultithreadedIncrementalSolving.html as it gives a more in depth explanation of how multithreaded solving works.

I also suggest to read the javadoc on the rebase method, it should point you in the right direction: 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-

Here's an example:

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));
    }

}

这篇关于Optaplanner多线程尝试产生了“缺少基准".定制移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆