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 the `PlanningSolution` 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 and Description
    --- | ---
    `protected boolean` | `assertExpectedStepScore`
    `protected boolean` | `assertShadowVariablesAreNotStaleAfterStep`
    `protected boolean` | `assertStepScoreFromScratch`
    `protected BestSolutionRecaller<Solution_>` | `bestSolutionRecaller`
    `protected org.slf4j.Logger` | `logger`
    `protected String` | `logIndentation`
    `protected int` | `phaseIndex`
    `protected PhaseLifecycleSupport<Solution_>` | `phaseLifecycleSupport` Used for `addPhaseLifecycleListener(PhaseLifecycleListener)`.
    `protected PhaseLifecycleSupport<Solution_>` | `solverPhaseLifecycleSupport` Used for `AbstractSolver.addPhaseLifecycleListener(PhaseLifecycleListener)`.
    `protected Termination` | `termination`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractPhase(int phaseIndex, String logIndentation, BestSolutionRecaller<Solution_> bestSolutionRecaller, Termination termination)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPhaseLifecycleListener(PhaseLifecycleListener<Solution_> phaseLifecycleListener)` Add a `PhaseLifecycleListener` that is only notified of the `phase` and the `PhaseLifecycleListener.stepStarted(AbstractStepScope)` step} starting/ending events from this phase (and the `SolverLifecycleListener.solvingStarted(DefaultSolverScope)` solving} events too of course).
    `protected void` | `assertWorkingSolutionInitialized(AbstractPhaseScope<Solution_> phaseScope)`
    `protected void` | `calculateWorkingStepScore(AbstractStepScope<Solution_> stepScope, Object completedAction)`
    `int` | `getPhaseIndex()`
    `abstract String` | `getPhaseTypeString()`
    `Termination` | `getTermination()`
    `boolean` | `isAssertExpectedStepScore()`
    `boolean` | `isAssertShadowVariablesAreNotStaleAfterStep()`
    `boolean` | `isAssertStepScoreFromScratch()`
    `void` | `phaseEnded(AbstractPhaseScope<Solution_> phaseScope)`
    `void` | `phaseStarted(AbstractPhaseScope<Solution_> phaseScope)`
    `protected void` | `predictWorkingStepScore(AbstractStepScope<Solution_> stepScope, Object completedAction)`
    `void` | `removePhaseLifecycleListener(PhaseLifecycleListener<Solution_> phaseLifecycleListener)`
    `void` | `setAssertExpectedStepScore(boolean assertExpectedStepScore)`
    `void` | `setAssertShadowVariablesAreNotStaleAfterStep(boolean assertShadowVariablesAreNotStaleAfterStep)`
    `void` | `setAssertStepScoreFromScratch(boolean assertStepScoreFromScratch)`
    `void` | `setSolverPhaseLifecycleSupport(PhaseLifecycleSupport<Solution_> solverPhaseLifecycleSupport)` Used to make `AbstractSolver.addPhaseLifecycleListener(PhaseLifecycleListener)` work.
    `void` | `solvingEnded(DefaultSolverScope<Solution_> solverScope)`
    `void` | `solvingStarted(DefaultSolverScope<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.impl.phase.Phase

      `solve`

- - ### Field Detail

    - #### logger

          protected final transient org.slf4j.Logger logger

    - #### phaseIndex

          protected final int phaseIndex

    - #### logIndentation

          protected final String logIndentation

    - #### bestSolutionRecaller

          protected final BestSolutionRecaller<Solution_> bestSolutionRecaller

    - #### termination

          protected final Termination termination

    - #### solverPhaseLifecycleSupport

          protected PhaseLifecycleSupport<Solution_> solverPhaseLifecycleSupport

      Used for `AbstractSolver.addPhaseLifecycleListener(PhaseLifecycleListener)`.

    - #### phaseLifecycleSupport

          protected PhaseLifecycleSupport<Solution_> phaseLifecycleSupport

      Used for `addPhaseLifecycleListener(PhaseLifecycleListener)`.

    - #### assertStepScoreFromScratch

          protected boolean assertStepScoreFromScratch

    - #### assertExpectedStepScore

          protected boolean assertExpectedStepScore

    - #### assertShadowVariablesAreNotStaleAfterStep

          protected boolean assertShadowVariablesAreNotStaleAfterStep

  - ### Constructor Detail

    - #### AbstractPhase

          public AbstractPhase(int phaseIndex,
                               String logIndentation,
                               BestSolutionRecaller<Solution_> bestSolutionRecaller,
                               Termination termination)

  - ### Method Detail

    - #### getPhaseIndex

          public int getPhaseIndex()

    - #### getTermination

          public Termination getTermination()

    - #### setSolverPhaseLifecycleSupport

          public void setSolverPhaseLifecycleSupport(PhaseLifecycleSupport<Solution_> solverPhaseLifecycleSupport)

      Description copied from interface: `Phase`
      Used to make `AbstractSolver.addPhaseLifecycleListener(PhaseLifecycleListener)` work.
      Specified by:
        `setSolverPhaseLifecycleSupport` in interface `Phase<Solution_>`
      Parameters:
        `solverPhaseLifecycleSupport` - never null

    - #### 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(DefaultSolverScope<Solution_> solverScope)

      Specified by:
        `solvingStarted` in interface `SolverLifecycleListener<Solution_>`

    - #### solvingEnded

          public void solvingEnded(DefaultSolverScope<Solution_> solverScope)

      Specified by:
        `solvingEnded` in interface `SolverLifecycleListener<Solution_>`

    - #### phaseStarted

          public void phaseStarted(AbstractPhaseScope<Solution_> phaseScope)

      Specified by:
        `phaseStarted` in interface `PhaseLifecycleListener<Solution_>`

    - #### stepStarted

          public void stepStarted(AbstractStepScope<Solution_> stepScope)

      Specified by:
        `stepStarted` in interface `PhaseLifecycleListener<Solution_>`

    - #### calculateWorkingStepScore

          protected void calculateWorkingStepScore(AbstractStepScope<Solution_> stepScope,
                                                   Object completedAction)

    - #### predictWorkingStepScore

          protected void predictWorkingStepScore(AbstractStepScope<Solution_> stepScope,
                                                 Object completedAction)

    - #### stepEnded

          public void stepEnded(AbstractStepScope<Solution_> stepScope)

      Specified by:
        `stepEnded` in interface `PhaseLifecycleListener<Solution_>`

    - #### phaseEnded

          public void phaseEnded(AbstractPhaseScope<Solution_> phaseScope)

      Specified by:
        `phaseEnded` in interface `PhaseLifecycleListener<Solution_>`

    - #### addPhaseLifecycleListener

          public void addPhaseLifecycleListener(PhaseLifecycleListener<Solution_> phaseLifecycleListener)

      Description copied from interface: `Phase`
      Add a `PhaseLifecycleListener` that is only notified of the `phase` and the `PhaseLifecycleListener.stepStarted(AbstractStepScope)` step} starting/ending events from this phase (and the `SolverLifecycleListener.solvingStarted(DefaultSolverScope)` solving} events too of course).

      To get notified for all phases, use `AbstractSolver.addPhaseLifecycleListener(PhaseLifecycleListener)` instead.

      Specified by:
        `addPhaseLifecycleListener` in interface `Phase<Solution_>`
      Parameters:
        `phaseLifecycleListener` - never null

    - #### removePhaseLifecycleListener

          public void removePhaseLifecycleListener(PhaseLifecycleListener<Solution_> phaseLifecycleListener)

      Specified by:
        `removePhaseLifecycleListener` in interface `Phase<Solution_>`
      Parameters:
        `phaseLifecycleListener` - never null
      See Also:
        `Phase.addPhaseLifecycleListener(PhaseLifecycleListener)`

    - #### assertWorkingSolutionInitialized

          protected void assertWorkingSolutionInitialized(AbstractPhaseScope<Solution_> phaseScope)

Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.