Interface ConstraintWeightOverrides<Score_ extends Score<Score_>>
- Type Parameters:
Score_-
- All Known Implementing Classes:
DefaultConstraintWeightOverrides
UniConstraintStream.penalize(Score).
To use,
place a member (typically a field) of type ConstraintWeightOverrides
in your PlanningSolution-annotated class.
Users should use of(Map) to provide the actual constraint weights.
Alternatively, a JSON serializers and deserializer may be defined to interact with a solution file.
Once the constraint weights are set, they must remain constant throughout the solving process,
or a ProblemChange needs to be triggered.
Zero-weight will be excluded from processing,
and the solver will behave as if it did not exist in the ConstraintProvider.
There is no support for user-defined packages, which is a deprecated feature in itself.
The constraint is assumed to be in the same package as the top-most class implementing this interface.
It is therefore required that the constraints be built using ConstraintBuilder.asConstraint(String),
leaving the constraint package to its default value.
-
Method Summary
Modifier and TypeMethodDescription@Nullable Score_getConstraintWeight(@NonNull String constraintName) Return a constraint weight for a particular constraint.Returns all known constraints.static <Score_ extends Score<Score_>>
ConstraintWeightOverrides<Score_>none()static <Score_ extends Score<Score_>>
ConstraintWeightOverrides<Score_>
-
Method Details
-
none
-
of
static <Score_ extends Score<Score_>> ConstraintWeightOverrides<Score_> of(Map<String, Score_> constraintWeightMap) -
getConstraintWeight
Return a constraint weight for a particular constraint.- Returns:
- null if the constraint name is not known
-
getKnownConstraintNames
Returns all known constraints.- Returns:
- All constraint names for which
getConstraintWeight(String)returns a non-null value.
-