Package org.optaplanner.core.impl.solver
Class AbstractSolver<Solution_>
java.lang.Object
org.optaplanner.core.impl.solver.AbstractSolver<Solution_>
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation
- All Implemented Interfaces:
Solver<Solution_>
- Direct Known Subclasses:
DefaultSolver
,PartitionSolver
Common code between
DefaultSolver
and child solvers (such as PartitionSolver
).
Do not create a new child Solver
to implement a new heuristic or metaheuristic,
just use a new Phase
for that.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final BestSolutionRecaller<Solution_>
protected final org.slf4j.Logger
protected final Termination<Solution_>
-
Constructor Summary
ConstructorDescriptionAbstractSolver
(BestSolutionRecaller<Solution_> bestSolutionRecaller, Termination<Solution_> solverTermination, List<Phase<Solution_>> phaseList) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(SolverEventListener<Solution_> eventListener) void
addPhaseLifecycleListener
(PhaseLifecycleListener<Solution_> phaseLifecycleListener) Add aPhaseLifecycleListener
that is notified ofsolving
events and also of thephase
and thestep
starting/ending events of all phases.void
phaseEnded
(AbstractPhaseScope<Solution_> phaseScope) void
phaseStarted
(AbstractPhaseScope<Solution_> phaseScope) void
removeEventListener
(SolverEventListener<Solution_> eventListener) void
removePhaseLifecycleListener
(PhaseLifecycleListener<Solution_> phaseLifecycleListener) protected void
runPhases
(SolverScope<Solution_> solverScope) void
solvingEnded
(SolverScope<Solution_> solverScope) void
solvingError
(SolverScope<Solution_> solverScope, Exception exception) void
solvingStarted
(SolverScope<Solution_> solverScope) void
stepEnded
(AbstractStepScope<Solution_> stepScope) void
stepStarted
(AbstractStepScope<Solution_> stepScope) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.optaplanner.core.api.solver.Solver
addProblemChange, addProblemChanges, addProblemFactChange, addProblemFactChanges, isEveryProblemChangeProcessed, isEveryProblemFactChangeProcessed, isSolving, isTerminateEarly, solve, terminateEarly
-
Field Details
-
logger
protected final transient org.slf4j.Logger logger -
bestSolutionRecaller
-
solverTermination
-
phaseList
-
-
Constructor Details
-
AbstractSolver
public AbstractSolver(BestSolutionRecaller<Solution_> bestSolutionRecaller, Termination<Solution_> solverTermination, List<Phase<Solution_>> phaseList)
-
-
Method Details
-
solvingStarted
-
runPhases
-
solvingEnded
-
solvingError
-
phaseStarted
-
phaseEnded
-
stepStarted
-
stepEnded
-
addEventListener
- Specified by:
addEventListener
in interfaceSolver<Solution_>
- Parameters:
eventListener
- never null
-
removeEventListener
- Specified by:
removeEventListener
in interfaceSolver<Solution_>
- Parameters:
eventListener
- never null
-
addPhaseLifecycleListener
Add aPhaseLifecycleListener
that is notified ofsolving
events and also of thephase
and thestep
starting/ending events of all phases.To get notified for only 1 phase, use
Phase.addPhaseLifecycleListener(PhaseLifecycleListener)
instead.- Parameters:
phaseLifecycleListener
- never null
-
removePhaseLifecycleListener
- Parameters:
phaseLifecycleListener
- never null- See Also:
-
getBestSolutionRecaller
-
getPhaseList
-