org.optaplanner.core.impl.solver
Class DefaultSolver
java.lang.Object
   org.optaplanner.core.impl.solver.DefaultSolver
org.optaplanner.core.impl.solver.DefaultSolver
- All Implemented Interfaces: 
- Solver
- public class DefaultSolver 
- extends Object- implements Solver
Default implementation for Solver.
- See Also:
- Solver
 
 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
logger
protected final transient org.slf4j.Logger logger
solverEventSupport
protected SolverEventSupport solverEventSupport
scoreDirectorFactory
protected InnerScoreDirectorFactory scoreDirectorFactory
randomFactory
protected RandomFactory randomFactory
basicPlumbingTermination
protected BasicPlumbingTermination basicPlumbingTermination
termination
protected Termination termination
bestSolutionRecaller
protected BestSolutionRecaller bestSolutionRecaller
phaseList
protected List<Phase> phaseList
solving
protected AtomicBoolean solving
solverScope
protected DefaultSolverScope solverScope
DefaultSolver
public DefaultSolver()
getRandomFactory
public RandomFactory getRandomFactory()
- 
 
- 
 
setRandomFactory
public void setRandomFactory(RandomFactory randomFactory)
- 
 
- 
 
getScoreDirectorFactory
public InnerScoreDirectorFactory getScoreDirectorFactory()
- 
- Specified by:
- getScoreDirectorFactoryin interface- Solver
 
- 
- Returns:
- never null
 
setScoreDirectorFactory
public void setScoreDirectorFactory(InnerScoreDirectorFactory scoreDirectorFactory)
- 
 
- 
 
setBasicPlumbingTermination
public void setBasicPlumbingTermination(BasicPlumbingTermination basicPlumbingTermination)
- 
 
- 
 
setTermination
public void setTermination(Termination termination)
- 
 
- 
 
getBestSolutionRecaller
public BestSolutionRecaller getBestSolutionRecaller()
- 
 
- 
 
setBestSolutionRecaller
public void setBestSolutionRecaller(BestSolutionRecaller bestSolutionRecaller)
- 
 
- 
 
getPhaseList
public List<Phase> getPhaseList()
- 
 
- 
 
setPhaseList
public void setPhaseList(List<Phase> phaseList)
- 
 
- 
 
getSolverScope
public DefaultSolverScope getSolverScope()
- 
 
- 
 
getBestSolution
public Solution getBestSolution()
- 
- Specified by:
- getBestSolutionin interface- Solver
 
- 
- Returns:
- never null, but it can return the original, uninitialized Solutionwith aScorenull.
 
getTimeMillisSpent
public long getTimeMillisSpent()
- 
- Specified by:
- getTimeMillisSpentin interface- Solver
 
- 
- Returns:
- the amount of millis spent between when this solver started and ended
 
isSolving
public boolean isSolving()
- Description copied from interface: Solver
- This method is thread-safe.
 
- 
- Specified by:
- isSolvingin interface- Solver
 
- 
- Returns:
- true if the Solver.solve(Solution)method is still running.
 
terminateEarly
public boolean terminateEarly()
- Description copied from interface: Solver
- Notifies the solver that it should stop at its earliest convenience.
 This method returns immediately, but it takes an undetermined time
 for the Solver.solve(Solution)to actually return.
 
 This method is thread-safe.
 
- 
- Specified by:
- terminateEarlyin interface- Solver
 
- 
- Returns:
- true if successful
- See Also:
- Solver.isTerminateEarly(),- Future.cancel(boolean)
 
isTerminateEarly
public boolean isTerminateEarly()
- Description copied from interface: Solver
- This method is thread-safe.
 
- 
- Specified by:
- isTerminateEarlyin interface- Solver
 
- 
- Returns:
- true if terminateEarly has been called since the  started.
- See Also:
- Future.isCancelled()
 
addProblemFactChange
public boolean addProblemFactChange(ProblemFactChange problemFactChange)
- Description copied from interface: Solver
- Schedules a ProblemFactChangeto be processed.
 
 As a side-effect, this restarts theSolver, effectively resetting allTerminations,
 but notSolver.terminateEarly().
 
 This method is thread-safe.
 Follows specifications ofBlockingQueue.add(Object)with by default
 a capacity ofInteger.MAX_VALUE.
 
- 
- Specified by:
- addProblemFactChangein interface- Solver
 
- 
- Parameters:
- problemFactChange- never null
- Returns:
- true (as specified by Collection.add(E))
 
isEveryProblemFactChangeProcessed
public boolean isEveryProblemFactChangeProcessed()
- Description copied from interface: Solver
- Checks if all scheduled ProblemFactChanges have been processed.
 
 This method is thread-safe.
 
- 
- Specified by:
- isEveryProblemFactChangeProcessedin interface- Solver
 
- 
- Returns:
- true if there are no ProblemFactChanges left to do
 
solve
public final void solve(Solution planningProblem)
- Description copied from interface: Solver
- Solves the planning problem.
 It can take minutes, even hours or days before this method returns,
 depending on the termination configuration.
 To terminate a Solverearly, callSolver.terminateEarly().
 
- 
- Specified by:
- solvein interface- Solver
 
- 
- Parameters:
- planningProblem- never null, usually its planning variables are uninitialized
- See Also:
- Solver.terminateEarly()
 
outerSolvingStarted
public void outerSolvingStarted(DefaultSolverScope solverScope)
- 
 
- 
 
solvingStarted
public void solvingStarted(DefaultSolverScope solverScope)
- 
 
- 
 
runPhases
protected void runPhases()
- 
 
- 
 
solvingEnded
public void solvingEnded(DefaultSolverScope solverScope)
- 
 
- 
 
outerSolvingEnded
public void outerSolvingEnded(DefaultSolverScope solverScope)
- 
 
- 
 
addEventListener
public void addEventListener(SolverEventListener eventListener)
- 
- Specified by:
- addEventListenerin interface- Solver
 
- 
- Parameters:
- eventListener- never null
 
removeEventListener
public void removeEventListener(SolverEventListener eventListener)
- 
- Specified by:
- removeEventListenerin interface- Solver
 
- 
- Parameters:
- eventListener- never null
 
addPhaseLifecycleListener
public void addPhaseLifecycleListener(PhaseLifecycleListener phaseLifecycleListener)
- 
 
- 
 
removePhaseLifecycleListener
public void removePhaseLifecycleListener(PhaseLifecycleListener phaseLifecycleListener)
- 
 
- 
 
Copyright © 2006-2014 JBoss by Red Hat. All Rights Reserved.