Solution_
- the solution type, the class with the PlanningSolution
annotationpublic class PartitionSolver<Solution_> extends AbstractSolver<Solution_>
Modifier and Type | Field and Description |
---|---|
protected DefaultSolverScope<Solution_> |
solverScope |
bestSolutionRecaller, phaseLifecycleSupport, phaseList, solverEventSupport, termination
Constructor and Description |
---|
PartitionSolver(Termination termination,
BestSolutionRecaller<Solution_> bestSolutionRecaller,
List<Phase<Solution_>> phaseList,
DefaultSolverScope<Solution_> solverScope) |
Modifier and Type | Method and Description |
---|---|
boolean |
addProblemFactChange(ProblemFactChange<Solution_> problemFactChange)
Schedules a
ProblemFactChange to be processed. |
Score |
getBestScore()
Returns the
Score of the Solver.getBestSolution() . |
Solution_ |
getBestSolution()
The best solution is the
best solution found during solving:
it might or might not be optimal, feasible or even initialized. |
InnerScoreDirectorFactory<Solution_> |
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.
|
Solution_ |
solve(Solution_ part)
Solves the planning problem and returns the best solution encountered
(which might or might not be optimal, feasible or even initialized).
|
void |
solvingEnded(DefaultSolverScope<Solution_> solverScope) |
void |
solvingStarted(DefaultSolverScope<Solution_> solverScope) |
boolean |
terminateEarly()
Notifies the solver that it should stop at its earliest convenience.
|
addEventListener, addPhaseLifecycleListener, removeEventListener, removePhaseLifecycleListener, runPhases
protected final DefaultSolverScope<Solution_> solverScope
public PartitionSolver(Termination termination, BestSolutionRecaller<Solution_> bestSolutionRecaller, List<Phase<Solution_>> phaseList, DefaultSolverScope<Solution_> solverScope)
public InnerScoreDirectorFactory<Solution_> getScoreDirectorFactory()
Solver
public Solution_ getBestSolution()
Solver
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.
PlanningSolution
with a Score
null.public Score getBestScore()
Solver
Score
of the Solver.getBestSolution()
.
This is useful for generic code, which doesn't know the type of the PlanningSolution
to retrieve the Score
from the Solver.getBestSolution()
easily.
PlanningSolution
is still uninitializedpublic long getTimeMillisSpent()
public boolean isSolving()
Solver
#solve(Solution_)
method is still running.public boolean terminateEarly()
Solver
#solve(Solution_)
to actually return.
This method is thread-safe.
Solver.isTerminateEarly()
,
Future.cancel(boolean)
public boolean isTerminateEarly()
Solver
Solver
started.Future.isCancelled()
public boolean addProblemFactChange(ProblemFactChange<Solution_> 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
.
problemFactChange
- never nullCollection.add(E)
)public boolean isEveryProblemFactChangeProcessed()
Solver
ProblemFactChange
s have been processed.
This method is thread-safe.
ProblemFactChange
s left to dopublic Solution_ solve(Solution_ part)
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()
.
part
- never null, usually its planning variables are uninitializedPlanningSolution
with a Score
null.Solver.terminateEarly()
public void solvingStarted(DefaultSolverScope<Solution_> solverScope)
solvingStarted
in class AbstractSolver<Solution_>
public void solvingEnded(DefaultSolverScope<Solution_> solverScope)
solvingEnded
in class AbstractSolver<Solution_>
Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.