Package org.optaplanner.core.impl.heuristic.selector.move.factory

## Interface MoveIteratorFactory<Solution_,​Move_ extends Move<Solution_>>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation

      public interface MoveIteratorFactory<Solution_,​Move_ extends Move<Solution_>>

  An interface to generate an `Iterator` of custom `Move`s.

  For a more simple version, see `MoveListFactory`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Iterator<Move_>` | `createOriginalMoveIterator​(ScoreDirector<Solution_> scoreDirector)` | When it is called depends on the configured `SelectionCacheType`.
    `Iterator<Move_>` | `createRandomMoveIterator​(ScoreDirector<Solution_> scoreDirector, Random workingRandom)` | When it is called depends on the configured `SelectionCacheType`.
    `long` | `getSize​(ScoreDirector<Solution_> scoreDirector)` |
    `default void` | `phaseEnded​(ScoreDirector<Solution_> scoreDirector)` | Called when the phase (for example Local Search) ends, to clean up anything cached since `phaseStarted(ScoreDirector)`.
    `default void` | `phaseStarted​(ScoreDirector<Solution_> scoreDirector)` | Called when the phase (for example Local Search) starts.

- - ### Method Detail

    - #### phaseStarted

          default void phaseStarted​(ScoreDirector<Solution_> scoreDirector)

      Called when the phase (for example Local Search) starts.
      Parameters:
        `scoreDirector` - never null

    - #### phaseEnded

          default void phaseEnded​(ScoreDirector<Solution_> scoreDirector)

      Called when the phase (for example Local Search) ends, to clean up anything cached since `phaseStarted(ScoreDirector)`.
      Parameters:
        `scoreDirector` - never null

    - #### getSize

          long getSize​(ScoreDirector<Solution_> scoreDirector)

      Parameters:
        `scoreDirector` - never null, the `ScoreDirector` which has the `ScoreDirector.getWorkingSolution()` of which the `Move`s need to be generated
      Returns:
        the approximate number of elements generated by `createOriginalMoveIterator(ScoreDirector)`
      Throws:
        `UnsupportedOperationException` - if not supported

    - #### createOriginalMoveIterator

          Iterator<Move_> createOriginalMoveIterator​(ScoreDirector<Solution_> scoreDirector)

      When it is called depends on the configured `SelectionCacheType`.
      Parameters:
        `scoreDirector` - never null, the `ScoreDirector` which has the `ScoreDirector.getWorkingSolution()` of which the `Move`s need to be generated
      Returns:
        never null, an `Iterator` that will end sooner or later
      Throws:
        `UnsupportedOperationException` - if only `createRandomMoveIterator(ScoreDirector, Random)` is supported

    - #### createRandomMoveIterator

          Iterator<Move_> createRandomMoveIterator​(ScoreDirector<Solution_> scoreDirector,
                                                   Random workingRandom)

      When it is called depends on the configured `SelectionCacheType`.
      Parameters:
        `scoreDirector` - never null, the `ScoreDirector` which has the `ScoreDirector.getWorkingSolution()` of which the `Move`s need to be generated
        `workingRandom` - never null, the `Random` to use when any random number is needed, so `EnvironmentMode.REPRODUCIBLE` works correctly
      Returns:
        never null, an `Iterator` that is allowed (or even presumed) to be never ending
      Throws:
        `UnsupportedOperationException` - if only `createOriginalMoveIterator(ScoreDirector)` is supported