Interface SolutionView<Solution_>

Type Parameters:
Solution_ -
All Known Subinterfaces:
InnerMutableSolutionView<Solution_>, MutableSolutionView<Solution_>
All Known Implementing Classes:
MoveDirector

@NullMarked public interface SolutionView<Solution_>
Allows read-only access to the state of the solution that is being operated on by the Move.

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

    • getValue

      <Entity_, Value_> @Nullable Value_ getValue(PlanningVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, Entity_ entity)
      Reads the value of a basic planning variable of a given entity.
      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.
    • countValues

      <Entity_, Value_> int countValues(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, Entity_ entity)
      Reads the value of a list planning variable and returns its length.
      Parameters:
      variableMetaModel - Describes the variable whose value is to be read.
      entity - The entity whose variable is to be read.
      Returns:
      The number of values in the list variable.
      Throws:
      NullPointerException - if the value of the list variable is null
      IndexOutOfBoundsException - if the index is out of bounds
    • getValueAtIndex

      <Entity_, Value_> Value_ getValueAtIndex(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, Entity_ entity, int index)
      Reads the value of a list planning variable of a given entity at a specific index.
      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.
      Throws:
      NullPointerException - if the value of the list variable is null
      IndexOutOfBoundsException - if the index is out of bounds
    • getPositionOf

      <Entity_, Value_> ElementPosition getPositionOf(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, Value_ value)
      Locates a given value in any list planning variable.
      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
    • isPinned

      <Entity_, Value_> boolean isPinned(PlanningVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, @Nullable Entity_ entity)
      Checks if a PlanningEntity with a basic PlanningVariable is pinned.
      Parameters:
      variableMetaModel - Describes the variable whose value is to be read.
      entity - The entity to check if it is pinned.
      Returns:
      boolean indicating if the value is pinned in the variable
    • isPinned

      <Entity_, Value_> boolean isPinned(PlanningListVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, @Nullable Value_ value)
      Checking if a PlanningListVariable's value is pinned requires checking: As this is complex, this method is provided as a convenience.
      Parameters:
      variableMetaModel - Describes the variable whose value is to be read.
      value - The value to check if it is pinned; may be null, in which case the method returns false.
      Returns:
      boolean indicating if the value is pinned in the variable
    • isValueInRange

      default <Entity_, Value_> boolean isValueInRange(GenuineVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, @Nullable Value_ value)
      Checks if a given value is present in the value range of a genuine planning variable, when the value range is defined on PlanningSolution.
      Type Parameters:
      Entity_ - generic type of the entity that the variable is defined on
      Value_ - generic type of the value that the variable can take
      Parameters:
      variableMetaModel - variable in question
      value - value to check
      Returns:
      true if the value is acceptable for the variable
      Throws:
      IllegalArgumentException - if the value range is on an entity as opposed to a solution; use isValueInRange(GenuineVariableMetaModel, Object, Object) to provide the entity instance.
    • isValueInRange

      <Entity_, Value_> boolean isValueInRange(GenuineVariableMetaModel<Solution_,Entity_,Value_> variableMetaModel, @Nullable Entity_ entity, @Nullable Value_ value)
      Checks if a given value is present in the value range of a genuine planning variable. If the value range is defined on entity, the entity argument must not be null.
      Type Parameters:
      Entity_ - generic type of the entity that the variable is defined on
      Value_ - generic type of the value that the variable can take
      Parameters:
      variableMetaModel - variable in question
      entity - entity that the value would be applied to; must be of a type that the variable is defined on
      value - value to check
      Returns:
      true if the value is acceptable for the variable
      Throws:
      IllegalArgumentException - if the value range is on an entity as opposed to a solution, and the entity is null