Interface PhaseCommand<Solution_>
- Type Parameters:
Solution_- the solution type, the class with thePlanningSolutionannotation
- All Known Subinterfaces:
CustomPhaseCommand<Solution_>
@NullMarked
public interface PhaseCommand<Solution_>
Runs a custom algorithm as a
Phase of the Solver that changes the planning variables.
To change problem facts, use Solver.addProblemChange(ProblemChange) instead.
To add custom properties, configure custom properties and add public setters for them.
-
Method Summary
Modifier and TypeMethodDescriptionvoidchangeWorkingSolution(ScoreDirector<Solution_> scoreDirector, BooleanSupplier isPhaseTerminated) Changesworking solutionofScoreDirector.getWorkingSolution().
-
Method Details
-
changeWorkingSolution
void changeWorkingSolution(ScoreDirector<Solution_> scoreDirector, BooleanSupplier isPhaseTerminated) Changesworking solutionofScoreDirector.getWorkingSolution(). When theworking solutionis modified, theScoreDirectormust be correctly notified (throughScoreDirector.beforeVariableChanged(Object, String)andScoreDirector.afterVariableChanged(Object, String)), otherwise calculatedScores will be corrupted.Don't forget to call
ScoreDirector.triggerVariableListeners()after each set of changes (especially before everyInnerScoreDirector.calculateScore()call) to ensure all shadow variables are updated.- Parameters:
scoreDirector- theScoreDirectorthat needs to get notified of the changes.isPhaseTerminated- long-running command implementations should check this periodically and terminate early if it returns true. Otherwise the terminations configured by the user will have no effect, as the solver can only terminate itself when a command has ended.
-