Modifier and Type | Field and Description |
---|---|
protected BasicPlumbingTermination |
basicPlumbingTermination |
protected BestSolutionRecaller |
bestSolutionRecaller |
protected boolean |
constraintMatchEnabledPreference |
protected EnvironmentMode |
environmentMode |
protected org.slf4j.Logger |
logger |
protected List<Phase> |
phaseList |
protected RandomFactory |
randomFactory |
protected InnerScoreDirectorFactory |
scoreDirectorFactory |
protected SolverEventSupport<Solution_> |
solverEventSupport |
protected DefaultSolverScope |
solverScope |
protected AtomicBoolean |
solving |
protected Termination |
termination |
Constructor and Description |
---|
DefaultSolver() |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(SolverEventListener<Solution_> eventListener) |
void |
addPhaseLifecycleListener(PhaseLifecycleListener phaseLifecycleListener) |
boolean |
addProblemFactChange(ProblemFactChange problemFactChange)
Schedules a
ProblemFactChange to be processed. |
Solution_ |
getBestSolution()
The best solution is the best solution found during solving:
it might or might not be optimal, feasible or even initialized.
|
BestSolutionRecaller |
getBestSolutionRecaller() |
EnvironmentMode |
getEnvironmentMode() |
List<Phase> |
getPhaseList() |
RandomFactory |
getRandomFactory() |
InnerScoreDirectorFactory |
getScoreDirectorFactory()
|
DefaultSolverScope |
getSolverScope() |
long |
getTimeMillisSpent() |
boolean |
isConstraintMatchEnabledPreference() |
boolean |
isEveryProblemFactChangeProcessed()
Checks if all scheduled
ProblemFactChange s have been processed. |
boolean |
isSolving()
This method is thread-safe.
|
boolean |
isTerminateEarly()
This method is thread-safe.
|
void |
outerSolvingEnded(DefaultSolverScope solverScope) |
void |
outerSolvingStarted(DefaultSolverScope solverScope) |
void |
removeEventListener(SolverEventListener<Solution_> eventListener) |
void |
removePhaseLifecycleListener(PhaseLifecycleListener phaseLifecycleListener) |
protected void |
runPhases() |
void |
setBasicPlumbingTermination(BasicPlumbingTermination basicPlumbingTermination) |
void |
setBestSolutionRecaller(BestSolutionRecaller bestSolutionRecaller) |
void |
setConstraintMatchEnabledPreference(boolean constraintMatchEnabledPreference) |
void |
setEnvironmentMode(EnvironmentMode environmentMode) |
void |
setPhaseList(List<Phase> phaseList) |
void |
setRandomFactory(RandomFactory randomFactory) |
void |
setScoreDirectorFactory(InnerScoreDirectorFactory scoreDirectorFactory) |
void |
setTermination(Termination termination) |
Solution_ |
solve(Solution_ planningProblem)
Solves the planning problem and returns the best solution encountered
(which might or might not be optimal, feasible or even initialized).
|
void |
solvingEnded(DefaultSolverScope solverScope) |
void |
solvingStarted(DefaultSolverScope solverScope) |
boolean |
terminateEarly()
Notifies the solver that it should stop at its earliest convenience.
|
protected final transient org.slf4j.Logger logger
protected SolverEventSupport<Solution_ extends Solution> solverEventSupport
protected EnvironmentMode environmentMode
protected RandomFactory randomFactory
protected boolean constraintMatchEnabledPreference
protected InnerScoreDirectorFactory scoreDirectorFactory
protected BasicPlumbingTermination basicPlumbingTermination
protected Termination termination
protected BestSolutionRecaller bestSolutionRecaller
protected AtomicBoolean solving
protected DefaultSolverScope solverScope
public EnvironmentMode getEnvironmentMode()
public void setEnvironmentMode(EnvironmentMode environmentMode)
public RandomFactory getRandomFactory()
public void setRandomFactory(RandomFactory randomFactory)
public boolean isConstraintMatchEnabledPreference()
public void setConstraintMatchEnabledPreference(boolean constraintMatchEnabledPreference)
public InnerScoreDirectorFactory getScoreDirectorFactory()
Solver
getScoreDirectorFactory
in interface Solver<Solution_ extends Solution>
public void setScoreDirectorFactory(InnerScoreDirectorFactory scoreDirectorFactory)
public void setBasicPlumbingTermination(BasicPlumbingTermination basicPlumbingTermination)
public void setTermination(Termination termination)
public BestSolutionRecaller getBestSolutionRecaller()
public void setBestSolutionRecaller(BestSolutionRecaller bestSolutionRecaller)
public DefaultSolverScope getSolverScope()
public Solution_ getBestSolution()
Solver
Solver.solve(Solution)
method also returns the best solution,
but this method is useful in rare asynchronous situations (although
SolverEventListener.bestSolutionChanged(BestSolutionChangedEvent)
is often more appropriate).
This method is thread-safe.
public long getTimeMillisSpent()
getTimeMillisSpent
in interface Solver<Solution_ extends Solution>
public boolean isSolving()
Solver
isSolving
in interface Solver<Solution_ extends Solution>
Solver.solve(Solution)
method is still running.public boolean terminateEarly()
Solver
Solver.solve(Solution)
to actually return.
This method is thread-safe.
terminateEarly
in interface Solver<Solution_ extends Solution>
Solver.isTerminateEarly()
,
Future.cancel(boolean)
public boolean isTerminateEarly()
Solver
isTerminateEarly
in interface Solver<Solution_ extends Solution>
Solver
started.Future.isCancelled()
public boolean addProblemFactChange(ProblemFactChange problemFactChange)
Solver
ProblemFactChange
to be processed.
As a side-effect, this restarts the Solver
, effectively resetting all Termination
s,
but not Solver.terminateEarly()
.
This method is thread-safe.
Follows specifications of BlockingQueue.add(Object)
with by default
a capacity of Integer.MAX_VALUE
.
addProblemFactChange
in interface Solver<Solution_ extends Solution>
problemFactChange
- never nullCollection.add(E)
)public boolean isEveryProblemFactChangeProcessed()
Solver
ProblemFactChange
s have been processed.
This method is thread-safe.
isEveryProblemFactChangeProcessed
in interface Solver<Solution_ extends Solution>
ProblemFactChange
s left to dopublic final Solution_ solve(Solution_ planningProblem)
Solver
It can take seconds, minutes, even hours or days before this method returns,
depending on the Termination
configuration.
To terminate a Solver
early, call Solver.terminateEarly()
.
public void outerSolvingStarted(DefaultSolverScope solverScope)
public void solvingStarted(DefaultSolverScope solverScope)
protected void runPhases()
public void solvingEnded(DefaultSolverScope solverScope)
public void outerSolvingEnded(DefaultSolverScope solverScope)
public void addEventListener(SolverEventListener<Solution_> eventListener)
addEventListener
in interface Solver<Solution_ extends Solution>
eventListener
- never nullpublic void removeEventListener(SolverEventListener<Solution_> eventListener)
removeEventListener
in interface Solver<Solution_ extends Solution>
eventListener
- never nullpublic void addPhaseLifecycleListener(PhaseLifecycleListener phaseLifecycleListener)
public void removePhaseLifecycleListener(PhaseLifecycleListener phaseLifecycleListener)
Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.