如何知道Optaplanner解决方案已经结束? [英] How to know Optaplanner solving has ended?

查看:233
本文介绍了如何知道Optaplanner解决方案已经结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经初始化并启动了求解器,我注册了一个侦听器以获取最佳的解决方案更改,但我也想知道解决方案何时结束. 我已经配置了记录器,它可以正确显示求解器何时停止求解(何时满足终止条件或何时终止).我想知道求解器何时完成,以哪种方式结束.

I have initialized and started a solver, I have registered a listener for the best solution change but I would also like to know when solving has ended. I have configured the logger and it correctly shows when the solver has stopped solving (when the termination condition is met or when it is terminated early). I would like to know when the solver has finished, whichever way it ended.

这是我当前用于侦听最佳解决方案更改的代码

Here's my current code for listening for best solution changes

solver.addEventListener(new SolverEventListener() {
    @Override
    public void bestSolutionChanged(BestSolutionChangedEvent bestSolutionChangedEvent) {
        //Get the new best solution
    }
});

我已经浏览了几次文档,但是找不到我需要的东西.有任何想法吗?谢谢. PS:我正在使用Optaplanner 6.0.1 final

I have gone through the documentation several times but couldn't find what I need. Any ideas? Thanks. PS: I'm using Optaplanner 6.0.1 final

推荐答案

Solver.solve()方法返回时.

请注意,当daemon模式显式设置为true时,仅当从另一个线程调用Solver.terminateEarly()时才会发生.否则,它会在Termination说也完成之后发生.

Note when the daemon mode is explicitly set to true, that will only happen if Solver.terminateEarly() is called from another thread. Otherwise it will happen after the Termination says it's done too.

这篇关于如何知道Optaplanner解决方案已经结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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