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 Summary
Modifier and TypeMethodDescription<Entity_,Value_>
intcountValues(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity) Reads the value of alist planning variableand returns its length.<Entity_,Value_>
ElementPositiongetPositionOf(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) Locates a given value in anylist planning variable.<Entity_,Value_>
@Nullable Value_getValue(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity) Reads the value of abasic planning variableof a given entity.<Entity_,Value_>
Value_getValueAtIndex(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity, int index) Reads the value of alist planning variableof a given entity at a specific index.<Entity_,Value_>
booleanisPinned(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, @Nullable Value_ value) Checking if aPlanningListVariable's value is pinned requires checking: the entity'sPlanningPinfield, the entity'sPlanningPinToIndexfield, and the value's position in the list variable. As this is complex, this method is provided as a convenience.<Entity_,Value_>
booleanisPinned(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, @Nullable Entity_ entity) Checks if aPlanningEntitywith a basicPlanningVariableis pinned.<Entity_,Value_>
booleanisValueInRange(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.default <Entity_,Value_>
booleanisValueInRange(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 onPlanningSolution.
-
Method Details
-
getValue
<Entity_,Value_> @Nullable Value_ getValue(PlanningVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ entity) Reads the value of abasic planning variableof 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 alist planning variableand 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 nullIndexOutOfBoundsException- 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 alist planning variableof 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 nullIndexOutOfBoundsException- if the index is out of bounds
-
getPositionOf
<Entity_,Value_> ElementPosition getPositionOf(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Value_ value) Locates a given value in anylist 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 aPlanningEntitywith a basicPlanningVariableis 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 aPlanningListVariable's value is pinned requires checking:- the entity's
PlanningPinfield, - the entity's
PlanningPinToIndexfield, - and the value's position in the list variable.
- 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
- the entity's
-
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 onPlanningSolution.- Type Parameters:
Entity_- generic type of the entity that the variable is defined onValue_- generic type of the value that the variable can take- Parameters:
variableMetaModel- variable in questionvalue- 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; useisValueInRange(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 onentity, theentityargument must not be null.- Type Parameters:
Entity_- generic type of the entity that the variable is defined onValue_- generic type of the value that the variable can take- Parameters:
variableMetaModel- variable in questionentity- entity that the value would be applied to; must be of a type that the variable is defined onvalue- 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
-