Solution_ - the solution type, the class with the PlanningSolution annotationpublic interface Solver<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 multithreading inside itself.
Build by a SolverFactory.
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(SolverEventListener<Solution_> eventListener) |
boolean |
addProblemFactChange(ProblemFactChange<Solution_> problemFactChange)
Schedules a
ProblemFactChange to be processed. |
boolean |
addProblemFactChanges(List<ProblemFactChange<Solution_>> problemFactChangeList)
Schedules multiple
ProblemFactChanges to be processed. |
String |
explainBestScore()
Returns a diagnostic text that explains the
getBestSolution() through the ConstraintMatch API
to identify which constraints or planning entities cause that getBestScore() quality. |
Score |
getBestScore()
Returns the
Score of the getBestSolution(). |
Solution_ |
getBestSolution()
The best solution is the
best solution found during solving:
it might or might not be optimal, feasible or even initialized. |
ScoreDirectorFactory<Solution_> |
getScoreDirectorFactory()
|
long |
getTimeMillisSpent()
Returns the amount of milliseconds spent solving since the last start.
|
boolean |
isEveryProblemFactChangeProcessed()
Checks if all scheduled
ProblemFactChanges 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_ problem)
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()
best solution found during solving:
it might or might not be optimal, feasible or even initialized.
The 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.
solve(Object) hasn't been called yet),
but it can return the uninitialized PlanningSolution with a Score null.Score getBestScore()
Score of the getBestSolution().
This is useful for generic code, which doesn't know the type of the PlanningSolution
to retrieve the Score from the getBestSolution() easily.
This method is thread-safe.
PlanningSolution is still uninitializedString explainBestScore()
getBestSolution() through the ConstraintMatch API
to identify which constraints or planning entities cause that getBestScore() quality.
In case of an infeasible solution,
this can help diagnose the cause of that.
Do not parse this string.
Instead, to provide this information in a UI or a service, use getScoreDirectorFactory()
to retrieve ScoreDirector.getConstraintMatchTotalMap() and ScoreDirector.getIndictmentMap()
and convert those into a domain specific API.
This method is thread-safe.
getBestScore() returns nullScoreDirector.explainScore()long getTimeMillisSpent()
A addProblemFactChange(ProblemFactChange) triggers a restart which resets this time.
This method is thread-safe.
Solution_ solve(Solution_ problem)
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().
problem - never null, usually its planning variables are uninitializedPlanningSolution 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<Solution_> problemFactChange)
ProblemFactChange to be processed.
As a side-effect, this restarts the Solver, effectively resetting all Terminations,
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))addProblemFactChanges(List)boolean addProblemFactChanges(List<ProblemFactChange<Solution_>> problemFactChangeList)
ProblemFactChanges to be processed.
As a side-effect, this restarts the Solver, effectively resetting all Terminations,
but not terminateEarly().
This method is thread-safe.
Follows specifications of Collection.addAll(Collection) with by default
a capacity of Integer.MAX_VALUE.
problemFactChangeList - never nullCollection.add(E))addProblemFactChange(ProblemFactChange)boolean isEveryProblemFactChangeProcessed()
ProblemFactChanges have been processed.
This method is thread-safe.
ProblemFactChanges left to dovoid addEventListener(SolverEventListener<Solution_> eventListener)
eventListener - never nullvoid removeEventListener(SolverEventListener<Solution_> eventListener)
eventListener - never nullScoreDirectorFactory<Solution_> getScoreDirectorFactory()
Copyright © 2006–2019 JBoss by Red Hat. All rights reserved.