How to know Optaplanner solving has ended?

心已入冬 提交于 2019-12-12 22:27:19

问题


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

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


回答1:


When the Solver.solve() method returns.

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.



来源:https://stackoverflow.com/questions/25534039/how-to-know-optaplanner-solving-has-ended

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!