Interface ConstraintWeightOverrides<Score_ extends Score<Score_>>

Type Parameters:
Score_ -
All Known Implementing Classes:
DefaultConstraintWeightOverrides

public interface ConstraintWeightOverrides<Score_ extends Score<Score_>>
Used to override constraint weights defined in Constraint Streams, e.g., in 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 Details

    • none

      static <Score_ extends Score<Score_>> ConstraintWeightOverrides<Score_> none()
    • of

      static <Score_ extends Score<Score_>> ConstraintWeightOverrides<Score_> of(Map<String,Score_> constraintWeightMap)
    • getConstraintWeight

      @Nullable Score_ getConstraintWeight(@NonNull String constraintName)
      Return a constraint weight for a particular constraint.
      Returns:
      null if the constraint name is not known
    • getKnownConstraintNames

      @NonNull Set<String> getKnownConstraintNames()
      Returns all known constraints.
      Returns:
      All constraint names for which getConstraintWeight(String) returns a non-null value.