Enum SolutionUpdatePolicy
- java.lang.Object
-
- java.lang.Enum<SolutionUpdatePolicy>
-
- ai.timefold.solver.core.api.solver.SolutionUpdatePolicy
-
- All Implemented Interfaces:
Serializable,Comparable<SolutionUpdatePolicy>
public enum SolutionUpdatePolicy extends Enum<SolutionUpdatePolicy>
To fully de-normalize a planning solution freshly loaded from persistent storage, two operations need to happen:- Variable listeners need to run, reading the state of all entities and computing values for their shadow variables.
- Score needs to be calculated and stored on the planning solution.
Each of these operations has its own performance cost, and for certain use cases, only one of them may be actually necessary. Advanced users therefore get a choice of which to perform.
If unsure, pick
UPDATE_ALL.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description NO_UPDATEDoes not run anything.UPDATE_ALLCombines the effects ofUPDATE_SCORE_ONLYandUPDATE_SHADOW_VARIABLES_ONLY, in effect fully updating the solution.UPDATE_SCORE_ONLYCalculates the score based on the entities in the solution, and writes it back to the solution.UPDATE_SHADOW_VARIABLES_ONLYRuns variable listeners on all planning entities and problem facts, updates shadow variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisScoreUpdateEnabled()booleanisShadowVariableUpdateEnabled()If this is true, variable listeners will ignore certain fail-fasts.static SolutionUpdatePolicyvalueOf(String name)Returns the enum constant of this type with the specified name.static SolutionUpdatePolicy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UPDATE_ALL
public static final SolutionUpdatePolicy UPDATE_ALL
Combines the effects ofUPDATE_SCORE_ONLYandUPDATE_SHADOW_VARIABLES_ONLY, in effect fully updating the solution.
-
UPDATE_SCORE_ONLY
public static final SolutionUpdatePolicy UPDATE_SCORE_ONLY
Calculates the score based on the entities in the solution, and writes it back to the solution. Does not trigger shadow variables; if score calculation requires shadow variable values,NullPointerExceptionis likely to be thrown. To avoid this, useUPDATE_ALLinstead.
-
UPDATE_SHADOW_VARIABLES_ONLY
public static final SolutionUpdatePolicy UPDATE_SHADOW_VARIABLES_ONLY
Runs variable listeners on all planning entities and problem facts, updates shadow variables. Does not update score; the solution will keep the current score, even if it is stale or null. To avoid this, useUPDATE_ALLinstead.
-
NO_UPDATE
public static final SolutionUpdatePolicy NO_UPDATE
Does not run anything. Improves performance duringSolutionManager.explain(Object, SolutionUpdatePolicy), where the user can guarantee that the solution is already up to date. Otherwise serves no purpose.
-
-
Method Detail
-
values
public static SolutionUpdatePolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SolutionUpdatePolicy c : SolutionUpdatePolicy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SolutionUpdatePolicy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
isScoreUpdateEnabled
public boolean isScoreUpdateEnabled()
-
isShadowVariableUpdateEnabled
public boolean isShadowVariableUpdateEnabled()
If this is true, variable listeners will ignore certain fail-fasts. SeeInnerScoreDirector.expectShadowVariablesInCorrectState().- Returns:
- true if shadow variables should be updated
-
-