Package org.optaplanner.core.impl.solver
Class DefaultSolverJob<Solution_,ProblemId_>
- java.lang.Object
- 
- org.optaplanner.core.impl.solver.DefaultSolverJob<Solution_,ProblemId_>
 
- 
- Type Parameters:
- Solution_- the solution type, the class with the- PlanningSolutionannotation
- ProblemId_- the ID type of a submitted problem, such as- Longor- UUID.
 
 public final class DefaultSolverJob<Solution_,ProblemId_> extends Object implements SolverJob<Solution_,ProblemId_>, Callable<Solution_> 
- 
- 
Constructor SummaryConstructors Constructor Description DefaultSolverJob(DefaultSolverManager<Solution_,ProblemId_> solverManager, Solver<Solution_> solver, ProblemId_ problemId, Function<? super ProblemId_,? extends Solution_> problemFinder, Consumer<? super Solution_> finalBestSolutionConsumer, BiConsumer<? super ProblemId_,? super Throwable> exceptionHandler)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Solution_call()Solution_getFinalBestSolution()Waits if necessary for the solver to complete and then returns the final bestPlanningSolution.ProblemId_getProblemId()SolverStatusgetSolverStatus()Returns whether theSolveris scheduled to solve, actively solving or not.DurationgetSolvingDuration()Returns theDurationspent solving since the last start.voidsetFuture(Future<Solution_> future)voidterminateEarly()Terminates the solver or cancels the solver job if it hasn't (re)started yet.
 
- 
- 
- 
Constructor Detail- 
DefaultSolverJobpublic DefaultSolverJob(DefaultSolverManager<Solution_,ProblemId_> solverManager, Solver<Solution_> solver, ProblemId_ problemId, Function<? super ProblemId_,? extends Solution_> problemFinder, Consumer<? super Solution_> finalBestSolutionConsumer, BiConsumer<? super ProblemId_,? super Throwable> exceptionHandler) 
 
- 
 - 
Method Detail- 
getProblemIdpublic ProblemId_ getProblemId() - Specified by:
- getProblemIdin interface- SolverJob<Solution_,ProblemId_>
- Returns:
- never null, a value given to SolverManager.solve(Object, Function, Consumer)orSolverManager.solveAndListen(Object, Function, Consumer)
 
 - 
getSolverStatuspublic SolverStatus getSolverStatus() Description copied from interface:SolverJobReturns whether theSolveris scheduled to solve, actively solving or not.Returns SolverStatus.NOT_SOLVINGif the solver already terminated.- Specified by:
- getSolverStatusin interface- SolverJob<Solution_,ProblemId_>
- Returns:
- never null
 
 - 
terminateEarlypublic void terminateEarly() Description copied from interface:SolverJobTerminates the solver or cancels the solver job if it hasn't (re)started yet.Does nothing if the solver already terminated. Waits for the termination or cancellation to complete before returning. During termination, a bestSolutionConsumercould still be called (on a consumer thread), before this method returns.- Specified by:
- terminateEarlyin interface- SolverJob<Solution_,ProblemId_>
 
 - 
getFinalBestSolutionpublic Solution_ getFinalBestSolution() throws InterruptedException, ExecutionException Description copied from interface:SolverJobWaits if necessary for the solver to complete and then returns the final bestPlanningSolution.- Specified by:
- getFinalBestSolutionin interface- SolverJob<Solution_,ProblemId_>
- Returns:
- never null, but it could be the original uninitialized problem
- Throws:
- InterruptedException- if the current thread was interrupted while waiting
- ExecutionException- if the computation threw an exception
 
 - 
getSolvingDurationpublic Duration getSolvingDuration() Description copied from interface:SolverJobReturns theDurationspent solving since the last start. If it hasn't started it yet, it returnsDuration.ZERO. If it hasn't ended yet, it returns the time between the last start and now. If it has ended already, it returns the time between the last start and the ending.- Specified by:
- getSolvingDurationin interface- SolverJob<Solution_,ProblemId_>
- Returns:
- the Durationspent solving since the last (re)start, at least 0
 
 
- 
 
-