Package org.optaplanner.core.impl.phase
Class AbstractPhase<Solution_>
- java.lang.Object
-
- org.optaplanner.core.impl.phase.AbstractPhase<Solution_>
-
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation
- All Implemented Interfaces:
EventListener
,PhaseLifecycleListener<Solution_>
,Phase<Solution_>
,SolverLifecycleListener<Solution_>
- Direct Known Subclasses:
DefaultConstructionHeuristicPhase
,DefaultCustomPhase
,DefaultExhaustiveSearchPhase
,DefaultLocalSearchPhase
,DefaultPartitionedSearchPhase
,NoChangePhase
public abstract class AbstractPhase<Solution_> extends Object implements Phase<Solution_>
- See Also:
DefaultLocalSearchPhase
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
assertExpectedStepScore
protected boolean
assertShadowVariablesAreNotStaleAfterStep
protected boolean
assertStepScoreFromScratch
protected org.slf4j.Logger
logger
protected String
logIndentation
protected int
phaseIndex
protected PhaseLifecycleSupport<Solution_>
phaseLifecycleSupport
protected Termination<Solution_>
phaseTermination
protected AbstractSolver<Solution_>
solver
protected Map<io.micrometer.core.instrument.Tags,List<AtomicReference<Number>>>
stepScoreMap
-
Constructor Summary
Constructors Constructor Description AbstractPhase(int phaseIndex, String logIndentation, Termination<Solution_> phaseTermination)
-
Method Summary
-
-
-
Field Detail
-
logger
protected final transient org.slf4j.Logger logger
-
phaseIndex
protected final int phaseIndex
-
logIndentation
protected final String logIndentation
-
stepScoreMap
protected final Map<io.micrometer.core.instrument.Tags,List<AtomicReference<Number>>> stepScoreMap
-
phaseTermination
protected final Termination<Solution_> phaseTermination
-
phaseLifecycleSupport
protected PhaseLifecycleSupport<Solution_> phaseLifecycleSupport
-
solver
protected AbstractSolver<Solution_> solver
-
assertStepScoreFromScratch
protected boolean assertStepScoreFromScratch
-
assertExpectedStepScore
protected boolean assertExpectedStepScore
-
assertShadowVariablesAreNotStaleAfterStep
protected boolean assertShadowVariablesAreNotStaleAfterStep
-
-
Constructor Detail
-
AbstractPhase
public AbstractPhase(int phaseIndex, String logIndentation, Termination<Solution_> phaseTermination)
-
-
Method Detail
-
getPhaseIndex
public int getPhaseIndex()
-
getPhaseTermination
public Termination<Solution_> getPhaseTermination()
-
getSolver
public AbstractSolver<Solution_> getSolver()
-
setSolver
public void setSolver(AbstractSolver<Solution_> solver)
-
isAssertStepScoreFromScratch
public boolean isAssertStepScoreFromScratch()
-
setAssertStepScoreFromScratch
public void setAssertStepScoreFromScratch(boolean assertStepScoreFromScratch)
-
isAssertExpectedStepScore
public boolean isAssertExpectedStepScore()
-
setAssertExpectedStepScore
public void setAssertExpectedStepScore(boolean assertExpectedStepScore)
-
isAssertShadowVariablesAreNotStaleAfterStep
public boolean isAssertShadowVariablesAreNotStaleAfterStep()
-
setAssertShadowVariablesAreNotStaleAfterStep
public void setAssertShadowVariablesAreNotStaleAfterStep(boolean assertShadowVariablesAreNotStaleAfterStep)
-
getPhaseTypeString
public abstract String getPhaseTypeString()
-
solvingStarted
public void solvingStarted(SolverScope<Solution_> solverScope)
- Specified by:
solvingStarted
in interfaceSolverLifecycleListener<Solution_>
-
solvingEnded
public void solvingEnded(SolverScope<Solution_> solverScope)
- Specified by:
solvingEnded
in interfaceSolverLifecycleListener<Solution_>
-
phaseStarted
public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope)
- Specified by:
phaseStarted
in interfacePhaseLifecycleListener<Solution_>
-
phaseEnded
public void phaseEnded(AbstractPhaseScope<Solution_> phaseScope)
- Specified by:
phaseEnded
in interfacePhaseLifecycleListener<Solution_>
-
stepStarted
public void stepStarted(AbstractStepScope<Solution_> stepScope)
- Specified by:
stepStarted
in interfacePhaseLifecycleListener<Solution_>
-
calculateWorkingStepScore
protected <Score_ extends Score<Score_>> void calculateWorkingStepScore(AbstractStepScope<Solution_> stepScope, Object completedAction)
-
predictWorkingStepScore
protected <Score_ extends Score<Score_>> void predictWorkingStepScore(AbstractStepScope<Solution_> stepScope, Object completedAction)
-
stepEnded
public void stepEnded(AbstractStepScope<Solution_> stepScope)
- Specified by:
stepEnded
in interfacePhaseLifecycleListener<Solution_>
-
addPhaseLifecycleListener
public void addPhaseLifecycleListener(PhaseLifecycleListener<Solution_> phaseLifecycleListener)
Description copied from interface:Phase
Add aPhaseLifecycleListener
that is only notified of thephase
and thePhaseLifecycleListener.stepStarted(AbstractStepScope)
step} starting/ending events from this phase (and theSolverLifecycleListener.solvingStarted(SolverScope)
solving} events too of course).To get notified for all phases, use
AbstractSolver.addPhaseLifecycleListener(PhaseLifecycleListener)
instead.- Specified by:
addPhaseLifecycleListener
in interfacePhase<Solution_>
- Parameters:
phaseLifecycleListener
- never null
-
removePhaseLifecycleListener
public void removePhaseLifecycleListener(PhaseLifecycleListener<Solution_> phaseLifecycleListener)
- Specified by:
removePhaseLifecycleListener
in interfacePhase<Solution_>
- Parameters:
phaseLifecycleListener
- never null- See Also:
Phase.addPhaseLifecycleListener(PhaseLifecycleListener)
-
assertWorkingSolutionInitialized
protected void assertWorkingSolutionInitialized(AbstractPhaseScope<Solution_> phaseScope)
-
-