Solution_
- the solution type, the class with the PlanningSolution
annotationProblemId_
- the ID type of a submitted problem, such as Long
or UUID
.public final class DefaultSolverJob<Solution_,ProblemId_> extends Object implements SolverJob<Solution_,ProblemId_>, Callable<Solution_>
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
Constructor and 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) |
Modifier and Type | Method and Description |
---|---|
Solution_ |
call() |
Solution_ |
getFinalBestSolution()
Waits if necessary for the solver to complete and then returns the final best
PlanningSolution . |
ProblemId_ |
getProblemId() |
SolverStatus |
getSolverStatus()
Returns whether the
Solver is scheduled to solve, actively solving or not. |
void |
setFuture(Future<Solution_> future) |
void |
terminateEarly()
Terminates the solver or cancels the solver job if it hasn't (re)started yet.
|
public 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)
public ProblemId_ getProblemId()
getProblemId
in interface SolverJob<Solution_,ProblemId_>
SolverManager.solve(Object, Function, Consumer)
or SolverManager.solveAndListen(Object, Function, Consumer)
public SolverStatus getSolverStatus()
SolverJob
Solver
is scheduled to solve, actively solving or not.
Returns SolverStatus.NOT_SOLVING
if the solver already terminated.
getSolverStatus
in interface SolverJob<Solution_,ProblemId_>
public void terminateEarly()
SolverJob
Does nothing if the solver already terminated.
Waits for the termination or cancellation to complete before returning.
During termination, a bestSolutionConsumer
could still be called (on a consumer thread),
before this method returns.
terminateEarly
in interface SolverJob<Solution_,ProblemId_>
public Solution_ getFinalBestSolution() throws InterruptedException, ExecutionException
SolverJob
PlanningSolution
.getFinalBestSolution
in interface SolverJob<Solution_,ProblemId_>
InterruptedException
- if the current thread was interrupted while waitingExecutionException
- if the computation threw an exceptionCopyright © 2006–2020 JBoss by Red Hat. All rights reserved.