public interface Solver<Solution_ extends Solution>
solve(Solution)
and then getBestSolution()
.
These methods are not thread-safe and should be called from the same thread,
except for the methods that are explicitly marked as thread-safe.
Note that despite that solve(Solution)
is not thread-safe for clients of this class,
that method is free to do multi-threading inside itself.
Build by a SolverFactory
.
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(SolverEventListener<Solution_> eventListener) |
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.
|
ScoreDirectorFactory |
getScoreDirectorFactory()
|
long |
getTimeMillisSpent() |
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 |
removeEventListener(SolverEventListener<Solution_> eventListener) |
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).
|
boolean |
terminateEarly()
Notifies the solver that it should stop at its earliest convenience.
|
Solution_ getBestSolution()
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.
long getTimeMillisSpent()
Solution_ solve(Solution_ planningProblem)
It can take seconds, minutes, even hours or days before this method returns,
depending on the Termination
configuration.
To terminate a Solver
early, call terminateEarly()
.
planningProblem
- never null, usually its planning variables are uninitializedSolution
with a Score
null.terminateEarly()
boolean isSolving()
solve(Solution)
method is still running.boolean terminateEarly()
solve(Solution)
to actually return.
This method is thread-safe.
isTerminateEarly()
,
Future.cancel(boolean)
boolean isTerminateEarly()
Solver
started.Future.isCancelled()
boolean addProblemFactChange(ProblemFactChange problemFactChange)
ProblemFactChange
to be processed.
As a side-effect, this restarts the Solver
, effectively resetting all Termination
s,
but not terminateEarly()
.
This method is thread-safe.
Follows specifications of BlockingQueue.add(Object)
with by default
a capacity of Integer.MAX_VALUE
.
problemFactChange
- never nullCollection.add(E)
)boolean isEveryProblemFactChangeProcessed()
ProblemFactChange
s have been processed.
This method is thread-safe.
ProblemFactChange
s left to dovoid addEventListener(SolverEventListener<Solution_> eventListener)
eventListener
- never nullvoid removeEventListener(SolverEventListener<Solution_> eventListener)
eventListener
- never nullScoreDirectorFactory getScoreDirectorFactory()
Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.