Interface MutableSolutionView<Solution_>

Type Parameters:
Solution_ -
All Superinterfaces:
SolutionView<Solution_>
All Known Subinterfaces:
InnerMutableSolutionView<Solution_>
All Known Implementing Classes:
MoveDirector

@NullMarked public interface MutableSolutionView<Solution_> extends SolutionView<Solution_>
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 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 by assignValueAndAdd(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's planning list variable. Moves all values at or after the index to the right, much like List.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)
    • 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's planning list variable, much like List.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)
    • unassignValue

      <Entity_, Value_> void unassignValue(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, Value_ value)
      Removes a given value from the planning list variable that 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's planning list variable at 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 by unassignValue(PlanningListVariableMetaModel, Object, int), but using PositionInList to specify the position.
    • changeVariable

      <Entity_, Value_> void changeVariable(PlanningVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, Entity_ entity, @Nullable Value_ newValue)
      Changes the value of a basic planning variable of 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's planning list variable to another. To move values within the same entity, use shiftValue(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 bounds
      IllegalArgumentException - if sourceEntity == destinationEntity
    • moveValueBetweenLists

      default <Entity_, Value_> Value_ moveValueBetweenLists(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, PositionInList source, PositionInList destination)
      As defined by moveValueBetweenLists(PlanningListVariableMetaModel, Object, int, Object, int), but using PositionInList to 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's planning 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 bounds
      IllegalArgumentException - 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's planning 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 bounds
      IllegalArgumentException - if sourceIndex == destinationIndex
      See Also:
    • shiftValue

      default <Entity_, Value_> Value_ shiftValue(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, PositionInList positionInList, int offset)
      As defined by shiftValue(PlanningListVariableMetaModel, Object, int, int), but using PositionInList to 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 bounds
      IllegalArgumentException - 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's planning 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 bounds
      IllegalArgumentException - if leftIndex == rightIndex