Class SolverManager

  • All Implemented Interfaces:
    EventListener, org.optaplanner.core.api.solver.event.SolverEventListener<VehicleRoutingSolution>

    @Component("optaweb-solver-manager")
    class SolverManager
    extends Object
    implements org.optaplanner.core.api.solver.event.SolverEventListener<VehicleRoutingSolution>
    Manages a solver running in a different thread.

    Does following:

    • Starts solver by running Solver.solve(Object problem) in a thread that's not the caller's thread.
    • Stops the solver (synchronously).
    • Adds problem fact changes to the solver.
    • Propagates any exception that happens in Solver.solver() (in a different thread) to the thread that interacts with SolverManager.
    • Listens for best solution changes and publishes new best solutions via RouteChangedEventPublisher.
    • Constructor Detail

      • SolverManager

        @Autowired
        SolverManager​(org.optaplanner.core.api.solver.Solver<VehicleRoutingSolution> solver,
                      org.springframework.core.task.AsyncListenableTaskExecutor executor,
                      RouteChangedEventPublisher routeChangedEventPublisher,
                      org.springframework.context.ApplicationEventPublisher eventPublisher)