org.optaplanner.core.impl.heuristic.move

## Class AbstractMove<Solution_>

- java.lang.Object
- - org.optaplanner.core.impl.heuristic.move.AbstractMove<Solution_>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation
  All Implemented Interfaces:
    Move<Solution_>
  Direct Known Subclasses:
    ChangeMove, KOptMove, NoChangeMove, PartitionChangeMove, PillarChangeMove, PillarSwapMove, SubChainChangeMove, SubChainReversingChangeMove, SubChainReversingSwapMove, SubChainSwapMove, SwapMove, TailChainSwapMove

      public abstract class AbstractMove<Solution_>
      extends Object
      implements Move<Solution_>

  Abstract superclass for `Move`.
  See Also:
    `Move`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractMove()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract AbstractMove<Solution_>` | `createUndoMove(ScoreDirector<Solution_> scoreDirector)` Called before the move is done, so the move can be evaluated and then be undone without resulting into a permanent change in the solution.
    `AbstractMove<Solution_>` | `doMove(ScoreDirector<Solution_> scoreDirector)` Does the move (which indirectly affects the `ScoreDirector.getWorkingSolution()`).
    `protected abstract void` | `doMoveOnGenuineVariables(ScoreDirector<Solution_> scoreDirector)` Like `doMove(ScoreDirector)` but without the `ScoreDirector.triggerVariableListeners()` call (because `doMove(ScoreDirector)` already does that).
    `protected static Object[]` | `rebaseArray(Object[] externalObjects, ScoreDirector<?> destinationScoreDirector)`
    `protected static <E> List<E>` | `rebaseList(List<E> externalObjectList, ScoreDirector<?> destinationScoreDirector)`

    - ### 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.heuristic.move.Move

      `getPlanningEntities, getPlanningValues, getSimpleMoveTypeDescription, isMoveDoable, rebase`

- - ### Constructor Detail

    - #### AbstractMove

          public AbstractMove()

  - ### Method Detail

    - #### doMove

          public final AbstractMove<Solution_> doMove(ScoreDirector<Solution_> scoreDirector)

      Description copied from interface: `Move`
      Does the move (which indirectly affects the `ScoreDirector.getWorkingSolution()`). When the `working solution` is modified, the `ScoreDirector` must be correctly notified (through `ScoreDirector.beforeVariableChanged(Object, String)` and `ScoreDirector.afterVariableChanged(Object, String)`), otherwise later calculated `Score`s will be corrupted.

      This method must end with calling `ScoreDirector.triggerVariableListeners()` to ensure all shadow variables are updated.

      This method must return an undo move, so the move can be evaluated and then be undone without resulting into a permanent change in the solution.

      Specified by:
        `doMove` in interface `Move<Solution_>`
      Parameters:
        `scoreDirector` - never null, the `ScoreDirector` that needs to get notified of the changes
      Returns:
        an undoMove which does the exact opposite of this move

    - #### createUndoMove

          protected abstract AbstractMove<Solution_> createUndoMove(ScoreDirector<Solution_> scoreDirector)

      Called before the move is done, so the move can be evaluated and then be undone without resulting into a permanent change in the solution.
      Parameters:
        `scoreDirector` - the `ScoreDirector` not yet modified by the move.
      Returns:
        an undoMove which does the exact opposite of this move.

    - #### doMoveOnGenuineVariables

          protected abstract void doMoveOnGenuineVariables(ScoreDirector<Solution_> scoreDirector)

      Like `doMove(ScoreDirector)` but without the `ScoreDirector.triggerVariableListeners()` call (because `doMove(ScoreDirector)` already does that).
      Parameters:
        `scoreDirector` - never null

    - #### rebaseList

          protected static <E> List<E> rebaseList(List<E> externalObjectList,
                                                  ScoreDirector<?> destinationScoreDirector)

    - #### rebaseArray

          protected static Object[] rebaseArray(Object[] externalObjects,
                                                ScoreDirector<?> destinationScoreDirector)

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