org.optaplanner.core.impl.phase.custom

## Interface CustomPhaseCommand<Solution_>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation
  All Known Implementing Classes:
    AbstractCustomPhaseCommand, NoChangeCustomPhaseCommand
  Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

      @FunctionalInterface
      public interface CustomPhaseCommand<Solution_>

  Runs a custom algorithm as a `Phase` of the `Solver` that changes the planning variables. Do not abuse to change the problems facts, instead use `Solver.addProblemFactChange(ProblemFactChange)` for that.

  An implementation must extend `AbstractCustomPhaseCommand` to ensure backwards compatibility in future versions.

  To add custom properties, configure custom properties and add public setters for them.

  See Also:
    `AbstractCustomPhaseCommand`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `changeWorkingSolution(ScoreDirector<Solution_> scoreDirector)` Changes `working solution` of `ScoreDirector.getWorkingSolution()`.

- - ### Method Detail

    - #### changeWorkingSolution

          void changeWorkingSolution(ScoreDirector<Solution_> scoreDirector)

      Changes `working solution` of `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 calculated `Score`s will be corrupted.

      Don't forget to call `ScoreDirector.triggerVariableListeners()` after each set of changes (especially before every `ScoreDirector.calculateScore()` call) to ensure all shadow variables are updated.

      Parameters:
        `scoreDirector` - never null, the `ScoreDirector` that needs to get notified of the changes.

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