1

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 Answers1

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.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120