Class ValueRangeManager<Solution_>
java.lang.Object
ai.timefold.solver.core.impl.score.director.ValueRangeManager<Solution_>
Caches value ranges for the current working solution,
allowing to quickly access these cached value ranges when needed.
Outside a ProblemChange, value ranges are not allowed to change.
Call reset(Object) every time the working solution changes through a problem fact,
so that all caches can be invalidated.
Two score directors can never share the same instance of this class;
this class contains state that is specific to a particular instance of a working solution.
Even a clone of that same solution must not share the same instance of this class,
unless reset(Object) is called with the clone;
failing to follow this rule will result in score corruptions as the cached value ranges reference
objects from the original working solution pre-clone.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionValueRangeManager(SolutionDescriptor<Solution_> solutionDescriptor) It is not recommended for code other thanScoreDirectorto create instances of this class. -
Method Summary
Modifier and TypeMethodDescriptioncomputeInitializationStatistics(Solution_ solution, @Nullable Consumer<Object> finisher) <Entity_> longcountOnEntity(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Entity_ entity) longcountOnSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Solution_ solution) <Entity_,Value_>
CountableValueRange<Value_>getFromEntity(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Entity_ entity) <Entity_,Value_>
CountableValueRange<Value_>getFromEntity(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Entity_ entity, @Nullable SelectionSorter<Solution_, Value_> sorter) <Value_> CountableValueRange<Value_>getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor) AsgetFromSolution(ValueRangeDescriptor, Object), but the solution is taken from the cached working solution.<Value_> CountableValueRange<Value_>getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, @Nullable SelectionSorter<Solution_, Value_> sorter) <Value_> CountableValueRange<Value_>getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Solution_ solution) <Value_> CountableValueRange<Value_>getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Solution_ solution, @Nullable SelectionSorter<Solution_, Value_> sorter) getInitializationStatistics(@Nullable Consumer<Object> finisher) <Entity_,Value_>
ReachableValues<Entity_,Value_> getReachableValues(GenuineVariableDescriptor<Solution_> variableDescriptor) <Entity_,Value_>
ReachableValues<Entity_,Value_> getReachableValues(GenuineVariableDescriptor<Solution_> variableDescriptor, @Nullable SelectionSorter<Solution_, Value_> sorter) static <Solution_>
ValueRangeManager<Solution_>of(SolutionDescriptor<Solution_> solutionDescriptor, Solution_ solution) void
-
Constructor Details
-
ValueRangeManager
It is not recommended for code other thanScoreDirectorto create instances of this class. See class-level documentation for more details. For safety, prefer usingof(SolutionDescriptor, Object)to create an instance of this class with a solution already set.
-
-
Method Details
-
of
public static <Solution_> ValueRangeManager<Solution_> of(SolutionDescriptor<Solution_> solutionDescriptor, Solution_ solution) -
getInitializationStatistics
-
getInitializationStatistics
public SolutionInitializationStatistics getInitializationStatistics(@Nullable Consumer<Object> finisher) -
computeInitializationStatistics
public SolutionInitializationStatistics computeInitializationStatistics(Solution_ solution, @Nullable Consumer<Object> finisher) -
getProblemSizeStatistics
-
getFromSolution
public <Value_> CountableValueRange<Value_> getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor) AsgetFromSolution(ValueRangeDescriptor, Object), but the solution is taken from the cached working solution. This requiresreset(Object)to be called before the first call to this method, and therefore this method will throw an exception if called before the score director is instantiated.- Throws:
IllegalStateException- if called beforereset(Object)is called
-
getFromSolution
public <Value_> CountableValueRange<Value_> getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, @Nullable SelectionSorter<Solution_, Value_> sorter) -
getFromSolution
public <Value_> CountableValueRange<Value_> getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Solution_ solution) -
getFromSolution
public <Value_> CountableValueRange<Value_> getFromSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Solution_ solution, @Nullable SelectionSorter<Solution_, Value_> sorter) -
getFromEntity
public <Entity_,Value_> CountableValueRange<Value_> getFromEntity(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Entity_ entity) - Throws:
IllegalStateException- if called beforereset(Object)is called
-
getFromEntity
public <Entity_,Value_> CountableValueRange<Value_> getFromEntity(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Entity_ entity, @Nullable SelectionSorter<Solution_, Value_> sorter) - Throws:
IllegalStateException- if called beforereset(Object)is called
-
countOnSolution
public long countOnSolution(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Solution_ solution) -
countOnEntity
public <Entity_> long countOnEntity(ValueRangeDescriptor<Solution_> valueRangeDescriptor, Entity_ entity) -
getReachableValues
public <Entity_,Value_> ReachableValues<Entity_,Value_> getReachableValues(GenuineVariableDescriptor<Solution_> variableDescriptor) -
getReachableValues
public <Entity_,Value_> ReachableValues<Entity_,Value_> getReachableValues(GenuineVariableDescriptor<Solution_> variableDescriptor, @Nullable SelectionSorter<Solution_, Value_> sorter) -
reset
-