Class MoveDirector<Solution_,Score_ extends Score<Score_>>
java.lang.Object
ai.timefold.solver.core.impl.move.director.MoveDirector<Solution_,Score_>
- All Implemented Interfaces:
InnerMutableSolutionView<Solution_>,MutableSolutionView<Solution_>,Rebaser,SolutionView<Solution_>
@NullMarked
public sealed class MoveDirector<Solution_,Score_ extends Score<Score_>>
extends Object
implements InnerMutableSolutionView<Solution_>, Rebaser
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <Entity_,Value_>
voidassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ planningValue, Entity_ destinationEntity, int destinationIndex) Puts a given value at a particular index in a given entity'splanning list variable.final <Entity_,Value_>
voidchangeVariable(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, @Nullable Value_ newValue) Reads the value of a @basic planning variableof a given entity.final voidfinal voidExecute a given move and make sure shadow variables are up to date after that.final <Result_> Result_executeTemporary(Move<Solution_> move, MoveDirector.TemporaryMovePostprocessor<Solution_, Score_, Result_> postprocessor) final InnerScore<Score_>executeTemporary(Move<Solution_> move) <Result_> Result_executeTemporary(Move<Solution_> move, MoveDirector.TemporaryMovePostprocessor<Solution_, Score_, Result_> postprocessor) protected static <Solution_,Entity_, Value_>
ElementPositiongetPositionOf(InnerScoreDirector<Solution_, ?> scoreDirector, PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) <Entity_,Value_>
ElementPositiongetPositionOf(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) Locates a given value in any @list planning variable.final <Entity_,Value_>
Value_getValue(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity) Reads the value of a @basic planning variableof a given entity.final <Entity_,Value_>
Value_getValueAtIndex(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int index) Reads the value of a @list planning variableof a given entity at a specific index.final <Entity_,Value_>
@Nullable Value_moveValueBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, Entity_ destinationEntity, int destinationIndex) Moves a value from one entity'splanning list variableto another.final <Entity_,Value_>
@Nullable Value_moveValueInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int sourceIndex, int destinationIndex) Moves a value within one entity'splanning list variable.final <T> @Nullable Trebase(@Nullable T problemFactOrPlanningEntity) Translates an entity or fact instance (often from anotherThread) to anotherScoreDirector's internal working instance.final <Entity_,Value_>
voidunassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ movedValue, Entity_ sourceEntity, int sourceIndex) Removes a given value from a given entity'splanning list variableat a given index.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.timefold.solver.core.preview.api.move.MutableSolutionView
unassignValue, unassignValue
-
Field Details
-
externalScoreDirector
-
-
Constructor Details
-
MoveDirector
-
-
Method Details
-
assignValue
public final <Entity_,Value_> void assignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ planningValue, Entity_ destinationEntity, int destinationIndex) Description copied from interface:MutableSolutionViewPuts a given value at a particular index in a given entity'splanning list variable. Moves all values at or after the index to the right.- Specified by:
assignValuein interfaceMutableSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable to be changed.planningValue- The value to be assigned to a list variable.destinationEntity- The entity whose list variable is to be changed.destinationIndex- The index at which the value is to be assigned.
-
unassignValue
public final <Entity_,Value_> void unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ movedValue, Entity_ sourceEntity, int sourceIndex) Description copied from interface:MutableSolutionViewRemoves a given value from a given entity'splanning list variableat a given index. Shifts any later values to the left.- Specified by:
unassignValuein interfaceMutableSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable to be changed.movedValue- The value to be unassigned from a list variable.sourceEntity- The entity whose value is to be unassigned from a list variable.sourceIndex- >= 0
-
changeVariable
public final <Entity_,Value_> void changeVariable(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, @Nullable Value_ newValue) Description copied from interface:MutableSolutionViewReads the value of a @basic planning variableof a given entity.- Specified by:
changeVariablein interfaceMutableSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable to be changed.entity- The entity whose variable value is to be changed.newValue- maybe null, if unassigning the variable
-
moveValueBetweenLists
public final <Entity_,Value_> @Nullable Value_ moveValueBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, Entity_ destinationEntity, int destinationIndex) Description copied from interface:MutableSolutionViewMoves a value from one entity'splanning list variableto another.- Specified by:
moveValueBetweenListsin interfaceMutableSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable to be changed.sourceEntity- The first entity whose variable value is to be changed.sourceIndex- >= 0destinationEntity- The second entity whose variable value is to be changed.destinationIndex- >= 0- Returns:
- the value that was moved; null if nothing was moved
-
moveValueInList
public final <Entity_,Value_> @Nullable Value_ moveValueInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int sourceIndex, int destinationIndex) Description copied from interface:MutableSolutionViewMoves a value within one entity'splanning list variable.- Specified by:
moveValueInListin interfaceMutableSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable to be changed.entity- The entity whose variable value is to be changed.sourceIndex- >= 0destinationIndex- >= 0- Returns:
- the value that was moved; null if nothing was moved
-
execute
Execute a given move and make sure shadow variables are up to date after that. -
execute
-
executeTemporary
-
executeTemporary
public <Result_> Result_ executeTemporary(Move<Solution_> move, MoveDirector.TemporaryMovePostprocessor<Solution_, Score_, Result_> postprocessor) -
executeTemporary
public final <Result_> Result_ executeTemporary(Move<Solution_> move, MoveDirector.TemporaryMovePostprocessor<Solution_, Score_, Result_> postprocessor) -
getValue
public final <Entity_,Value_> Value_ getValue(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity) Description copied from interface:SolutionViewReads the value of a @basic planning variableof a given entity.- Specified by:
getValuein interfaceSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable whose value is to be read.entity- The entity whose variable is to be read.- Returns:
- The value of the variable on the entity.
-
getValueAtIndex
public final <Entity_,Value_> Value_ getValueAtIndex(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int index) Description copied from interface:SolutionViewReads the value of a @list planning variableof a given entity at a specific index.- Specified by:
getValueAtIndexin interfaceSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable whose value is to be read.entity- The entity whose variable is to be read.index- >= 0- Returns:
- The value at the given index in the list variable.
-
getPositionOf
public <Entity_,Value_> ElementPosition getPositionOf(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) Description copied from interface:SolutionViewLocates a given value in any @list planning variable.- Specified by:
getPositionOfin interfaceSolutionView<Solution_>- Parameters:
variableMetaModel- Describes the variable whose value is to be read.value- The value to locate.- Returns:
- the location of the value in the variable
-
getPositionOf
protected static <Solution_,Entity_, ElementPosition getPositionOfValue_> (InnerScoreDirector<Solution_, ?> scoreDirector, PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) -
rebase
public final <T> @Nullable T rebase(@Nullable T problemFactOrPlanningEntity) Description copied from interface:RebaserTranslates an entity or fact instance (often from anotherThread) to anotherScoreDirector's internal working instance. Useful for move rebasing and in aProblemChangeand for multi-threaded solving.Matching is determined by the
LookUpStrategyTypeonPlanningSolution. Matching uses aPlanningIdby default. -
getScoreDirector
- Specified by:
getScoreDirectorin interfaceInnerMutableSolutionView<Solution_>
-