Interface MutableSolutionView<Solution_>
- Type Parameters:
Solution_-
- All Superinterfaces:
SolutionView<Solution_>
- All Known Subinterfaces:
InnerMutableSolutionView<Solution_>
- All Known Implementing Classes:
MoveDirector
Contains all reading and mutating methods available to a
Move
in order to change the state of a planning solution.
This package and all of its contents are part of the Neighborhoods API, which is under development and is only offered as a preview feature. There are no guarantees for backward compatibility; any class, method, or field may change or be removed without prior notice, although we will strive to avoid this as much as possible.
We encourage you to try the API and give us feedback on your experience with it, before we finalize the API. Please direct your feedback to Timefold Solver GitHub or to Timefold Discord.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <Entity_,Value_>
voidassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, Entity_ destinationEntity, int destinationIndex) Deprecated, for removal: This API element is subject to removal in a future version.default <Entity_,Value_>
voidassignValueAndAdd(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, PositionInList destination) As defined byassignValueAndAdd(PlanningListVariableMetaModel, Object, Object, int), but usingPositionInListto specify the position.<Entity_,Value_>
voidassignValueAndAdd(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, Entity_ destinationEntity, int destinationIndex) Puts a given value at a particular index in a given entity'splanning list variable.default <Entity_,Value_>
voidassignValueAndSet(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, PositionInList destination) As defined byassignValueAndSet(PlanningListVariableMetaModel, Object, Object, int), but usingPositionInListto specify the position.<Entity_,Value_>
voidassignValueAndSet(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, Entity_ destinationEntity, int destinationIndex) Puts a given value at a particular index in a given entity'splanning list variable, much likeList.set(int, Object).<Entity_,Value_>
voidchangeVariable(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, @Nullable Value_ newValue) Changes the value of abasic planning variableof a given entity.default <Entity_,Value_>
Value_moveValueBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, PositionInList source, PositionInList destination) As defined bymoveValueBetweenLists(PlanningListVariableMetaModel, Object, int, Object, int), but usingPositionInListto specify the source and destination positions.<Entity_,Value_>
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.<Entity_,Value_>
Value_moveValueInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, int destinationIndex) Moves a value within one entity'splanning list variable.default <Entity_,Value_>
Value_shiftValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, PositionInList positionInList, int offset) As defined byshiftValue(PlanningListVariableMetaModel, Object, int, int), but usingPositionInListto specify the source position.<Entity_,Value_>
Value_shiftValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, int offset) Moves a value within one entity'splanning list variable, by the given offset.<Entity_,Value_>
voidswapValuesBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ leftEntity, int leftIndex, Entity_ rightEntity, int rightIndex) Swaps two values between two entities'planning list variable.<Entity_,Value_>
voidswapValuesInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int leftIndex, int rightIndex) Swaps two values within one entity'splanning list variable.default <Entity_,Value_>
Value_unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, PositionInList destination) As defined byunassignValue(PlanningListVariableMetaModel, Object, int), but usingPositionInListto specify the position.<Entity_,Value_>
Value_unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int index) Removes a value from a given entity'splanning list variableat a given index.<Entity_,Value_>
voidunassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) Removes a given value from theplanning list variablethat it's part of.Methods inherited from interface ai.timefold.solver.core.preview.api.move.SolutionView
countValues, getPositionOf, getValue, getValueAtIndex, isPinned, isPinned, isValueInRange, isValueInRange
-
Method Details
-
assignValue
@Deprecated(forRemoval=true) default <Entity_,Value_> void assignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, Entity_ destinationEntity, int destinationIndex) Deprecated, for removal: This API element is subject to removal in a future version.As defined byassignValueAndAdd(PlanningListVariableMetaModel, Object, Object, int). Will be removed right before this API is moved out of preview. -
assignValueAndAdd
<Entity_,Value_> void assignValueAndAdd(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, Entity_ destinationEntity, int destinationIndex) Puts 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, much likeList.add(int, Object).- Parameters:
variableMetaModel- Describes the variable to be changed.value- The value to be assigned to a list variable.destinationEntity- The entity whose list variable is to be changed.destinationIndex- The index in the list variable at which the value is to be assigned, moving the pre-existing value at that index and all subsequent values to the right.- Throws:
IllegalStateException- if the value is already assigned to a list variable
-
assignValueAndAdd
default <Entity_,Value_> void assignValueAndAdd(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, PositionInList destination) As defined byassignValueAndAdd(PlanningListVariableMetaModel, Object, Object, int), but usingPositionInListto specify the position. -
assignValueAndSet
<Entity_,Value_> void assignValueAndSet(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, Entity_ destinationEntity, int destinationIndex) Puts a given value at a particular index in a given entity'splanning list variable, much likeList.set(int, Object). The original value at that index becomes unassigned. If the destination index is equal to the list size, the value is appended to the end of the list without unassigning any value.- Parameters:
variableMetaModel- Describes the variable to be changed.value- The value to be assigned to a list variable.destinationEntity- The entity whose list variable is to be changed.destinationIndex- The index in the list variable at which the value is to be assigned, unassigning the pre-existing value at that index.- Throws:
IllegalStateException- if the value is already assigned to a list variable
-
assignValueAndSet
default <Entity_,Value_> void assignValueAndSet(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value, PositionInList destination) As defined byassignValueAndSet(PlanningListVariableMetaModel, Object, Object, int), but usingPositionInListto specify the position. -
unassignValue
<Entity_,Value_> void unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) Removes a given value from theplanning list variablethat it's part of. Shifts any subsequent values to the left.- Parameters:
variableMetaModel- Describes the variable to be changed.value- The value to be removed from a list variable.- Throws:
IllegalStateException- if the value is not assigned to a list variable
-
unassignValue
<Entity_,Value_> Value_ unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int index) Removes a value from a given entity'splanning list variableat a given index. Shifts any subsequent values to the left.- Parameters:
variableMetaModel- Describes the variable to be changed.entity- The entity whose element is to be removed from a list variable.index- The index in entity's list variable which contains the value to be removed; Acceptable values range from zero to one less than list size. All values after the index are shifted to the left.- Returns:
- the removed value
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
unassignValue
default <Entity_,Value_> Value_ unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, PositionInList destination) As defined byunassignValue(PlanningListVariableMetaModel, Object, int), but usingPositionInListto specify the position. -
changeVariable
<Entity_,Value_> void changeVariable(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, @Nullable Value_ newValue) Changes the value of abasic planning variableof a given entity.- 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
<Entity_,Value_> 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. To move values within the same entity, useshiftValue(PlanningListVariableMetaModel, Object, int, int)instead.- Parameters:
variableMetaModel- Describes the variable to be changed.sourceEntity- The entity from which the value will be removed.sourceIndex- The index in the source entity's list variable which contains the value to be moved; Acceptable values range from zero to one less than list size. All values after the index are shifted to the left.destinationEntity- The entity to which the value will be added.destinationIndex- The index in the destination entity's list variable to which the value will be moved; Acceptable values range from zero to equal to list size. All values at or after the index are shifted to the right. To append to the end of the list, use the list size as index.- Returns:
- the value that was moved
- Throws:
IndexOutOfBoundsException- if either index is out of boundsIllegalArgumentException- if sourceEntity == destinationEntity
-
moveValueBetweenLists
default <Entity_,Value_> Value_ moveValueBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, PositionInList source, PositionInList destination) As defined bymoveValueBetweenLists(PlanningListVariableMetaModel, Object, int, Object, int), but usingPositionInListto specify the source and destination positions. -
moveValueInList
<Entity_,Value_> Value_ moveValueInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, int destinationIndex) Moves a value within one entity'splanning list variable. Behaves as if the value is first removed from the source index, shifting all later values to the left, and then inserted at the destination index. This means that, to move the item to the end of the list, the destination index must equal the list size minus one.- Parameters:
variableMetaModel- Describes the variable to be changed.sourceEntity- The entity whose variable value is to be changed.sourceIndex- The index in the source entity's list variable which contains the value to be moved; Acceptable values range from zero to one less than list size. All values after the index are shifted to the left.destinationIndex- The index in the source entity's list variable to which the value will be moved; Acceptable values range from zero to one less than list size. All values at or after the index are shifted to the right.- Returns:
- the value that was moved
- Throws:
IndexOutOfBoundsException- if either index is out of boundsIllegalArgumentException- if sourceIndex == destinationIndex- See Also:
-
shiftValue
<Entity_,Value_> Value_ shiftValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, int offset) Moves a value within one entity'splanning list variable, by the given offset.- Parameters:
variableMetaModel- Describes the variable to be changed.sourceEntity- The entity whose variable value is to be changed.sourceIndex- The index in the source entity's list variable which contains the value to be moved; Acceptable values range from zero to one less than list size.offset- By how much to move the value; positive values move to the right, negative values to the left. The offset must not be zero. The offset must not move the value out of bounds.- Returns:
- the value that was moved
- Throws:
IndexOutOfBoundsException- if either index is out of boundsIllegalArgumentException- if sourceIndex == destinationIndex- See Also:
-
shiftValue
default <Entity_,Value_> Value_ shiftValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, PositionInList positionInList, int offset) As defined byshiftValue(PlanningListVariableMetaModel, Object, int, int), but usingPositionInListto specify the source position. -
swapValuesBetweenLists
<Entity_,Value_> void swapValuesBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ leftEntity, int leftIndex, Entity_ rightEntity, int rightIndex) Swaps two values between two entities'planning list variable.- Parameters:
variableMetaModel- Describes the variable to be changed.leftEntity- The first entity whose variable value is to be swapped.leftIndex- The index in the left entity's list variable which contains the value to be swapped; Acceptable values range from zero to one less than list size.rightEntity- The second entity whose variable value is to be swapped.rightIndex- The index in the right entity's list variable which contains the other value to be swapped; Acceptable values range from zero to one less than list size.- Throws:
IndexOutOfBoundsException- if either index is out of boundsIllegalArgumentException- if leftEntity == rightEntity while leftIndex == rightIndex
-
swapValuesInList
<Entity_,Value_> void swapValuesInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int leftIndex, int rightIndex) Swaps two values within one entity'splanning list variable.- Parameters:
variableMetaModel- Describes the variable to be changed.entity- The entity whose variable values are to be swapped.leftIndex- The index in the entity's list variable which contains the value to be swapped; Acceptable values range from zero to one less than list size.rightIndex- The index in the entity's list variable which contains the other value to be swapped; Acceptable values range from zero to one less than list size.- Throws:
IndexOutOfBoundsException- if either index is out of boundsIllegalArgumentException- if leftIndex == rightIndex
-
assignValueAndAdd(PlanningListVariableMetaModel, Object, Object, int)instead.