Class DefaultSolver<Solution_>
- Type Parameters:
- Solution_- the solution type, the class with the- PlanningSolutionannotation
- All Implemented Interfaces:
- Solver<Solution_>
Solver.- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected BasicPlumbingTermination<Solution_>protected EnvironmentModeprotected RandomFactoryprotected final SolverScope<Solution_>protected final AtomicBooleanFields inherited from class org.optaplanner.core.impl.solver.AbstractSolverbestSolutionRecaller, logger, phaseList, solverTermination
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultSolver(EnvironmentMode environmentMode, RandomFactory randomFactory, BestSolutionRecaller<Solution_> bestSolutionRecaller, BasicPlumbingTermination<Solution_> basicPlumbingTermination, Termination<Solution_> termination, List<Phase<Solution_>> phaseList, SolverScope<Solution_> solverScope, String moveThreadCountDescription) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddProblemChange(ProblemChange<Solution_> problemChange) Schedules aProblemChangeto be processed.voidaddProblemChanges(List<ProblemChange<Solution_>> problemChangeList) Schedules multipleProblemChanges to be processed.booleanaddProblemFactChange(ProblemFactChange<Solution_> problemFactChange) This method is deprecated.booleanaddProblemFactChanges(List<ProblemFactChange<Solution_>> problemFactChangeList) This method is deprecated.longbooleanChecks if all scheduledProblemChanges have been processed.booleanThis method is deprecated.booleanThis method is thread-safe.booleanThis method is thread-safe.voidouterSolvingEnded(SolverScope<Solution_> solverScope) voidouterSolvingStarted(SolverScope<Solution_> solverScope) voidsetMonitorTagMap(Map<String, String> monitorTagMap) final Solution_Solves the planning problem and returns the best solution encountered (which might or might not be optimal, feasible or even initialized).voidsolvingEnded(SolverScope<Solution_> solverScope) voidsolvingStarted(SolverScope<Solution_> solverScope) booleanNotifies the solver that it should stop at its earliest convenience.Methods inherited from class org.optaplanner.core.impl.solver.AbstractSolveraddEventListener, addPhaseLifecycleListener, getBestSolutionRecaller, getPhaseList, phaseEnded, phaseStarted, removeEventListener, removePhaseLifecycleListener, runPhases, solvingError, stepEnded, stepStarted
- 
Field Details- 
environmentMode
- 
randomFactory
- 
basicPlumbingTermination
- 
solving
- 
solverScope
 
- 
- 
Constructor Details- 
DefaultSolverpublic DefaultSolver(EnvironmentMode environmentMode, RandomFactory randomFactory, BestSolutionRecaller<Solution_> bestSolutionRecaller, BasicPlumbingTermination<Solution_> basicPlumbingTermination, Termination<Solution_> termination, List<Phase<Solution_>> phaseList, SolverScope<Solution_> solverScope, String moveThreadCountDescription) 
 
- 
- 
Method Details- 
getEnvironmentMode
- 
getRandomFactory
- 
getScoreDirectorFactory
- 
getSolverScope
- 
getTimeMillisSpentpublic long getTimeMillisSpent()
- 
isSolvingpublic boolean isSolving()Description copied from interface:SolverThis method is thread-safe.- Returns:
- true if the Solver.solve(Solution_)method is still running.
 
- 
terminateEarlypublic boolean terminateEarly()Description copied from interface:SolverNotifies the solver that it should stop at its earliest convenience. This method returns immediately, but it takes an undetermined time for theSolver.solve(Solution_)to actually return.If the solver is running in daemon mode, this is the only way to terminate it normally. This method is thread-safe. It can only be called from a different thread because the original thread is still calling Solver.solve(Object).- Returns:
- true if successful, false if was already terminating or terminated
- See Also:
 
- 
isTerminateEarlypublic boolean isTerminateEarly()Description copied from interface:SolverThis method is thread-safe.- Returns:
- true if terminateEarly has been called since the Solverstarted.
- See Also:
 
- 
addProblemFactChangeDescription copied from interface:SolverThis method is deprecated. Schedules aProblemFactChangeto be processed.As a side-effect, this restarts the Solver, effectively resetting all terminations, but notSolver.terminateEarly().This method is thread-safe. Follows specifications of BlockingQueue.add(Object)with by default a capacity ofInteger.MAX_VALUE.- Parameters:
- problemFactChange- never null
- Returns:
- true (as specified by Collection.add(E))
- See Also:
 
- 
addProblemFactChangesDescription copied from interface:SolverThis method is deprecated. Schedules multipleProblemFactChanges to be processed.As a side-effect, this restarts the Solver, effectively resetting all terminations, but notSolver.terminateEarly().This method is thread-safe. Follows specifications of Collection.addAll(Collection)with by default a capacity ofInteger.MAX_VALUE.- Parameters:
- problemFactChangeList- never null
- Returns:
- true (as specified by Collection.add(E))
- See Also:
 
- 
addProblemChangeDescription copied from interface:SolverSchedules aProblemChangeto be processed.As a side effect, this restarts the Solver, effectively resetting allTerminations, but notSolver.terminateEarly().This method is thread-safe. Follows specifications of BlockingQueue.add(Object)with by default a capacity ofInteger.MAX_VALUE.To learn more about problem change semantics, please refer to the ProblemChangeJavadoc.- Parameters:
- problemChange- never null
- See Also:
 
- 
addProblemChangesDescription copied from interface:SolverSchedules multipleProblemChanges to be processed.As a side effect, this restarts the Solver, effectively resetting allTerminations, but notSolver.terminateEarly().This method is thread-safe. Follows specifications of BlockingQueue.add(Object)with by default a capacity ofInteger.MAX_VALUE.To learn more about problem change semantics, please refer to the ProblemChangeJavadoc.- Parameters:
- problemChangeList- never null
- See Also:
 
- 
isEveryProblemChangeProcessedpublic boolean isEveryProblemChangeProcessed()Description copied from interface:SolverChecks if all scheduledProblemChanges have been processed.This method is thread-safe. - Returns:
- true if there are no ProblemChanges left to do
 
- 
isEveryProblemFactChangeProcessedpublic boolean isEveryProblemFactChangeProcessed()Description copied from interface:SolverThis method is deprecated. Checks if all scheduledProblemFactChanges have been processed.This method is thread-safe. - Returns:
- true if there are no ProblemFactChanges left to do
 
- 
setMonitorTagMap
- 
solveDescription copied from interface:SolverSolves the planning problem and returns the best solution encountered (which might or might not be optimal, feasible or even initialized).It can take seconds, minutes, even hours or days before this method returns, depending on the termination configuration. To terminate a Solverearly, callSolver.terminateEarly().- Parameters:
- problem- never null, a- PlanningSolution, usually its planning variables are uninitialized
- Returns:
- never null, but it can return the original, uninitialized PlanningSolutionwith a nullScore.
- See Also:
 
- 
outerSolvingStarted
- 
solvingStarted- Overrides:
- solvingStartedin class- AbstractSolver<Solution_>
 
- 
solvingEnded- Overrides:
- solvingEndedin class- AbstractSolver<Solution_>
 
- 
outerSolvingEnded
 
-