Class Constraint

java.lang.Object
com.google.ortools.sat.Constraint
Direct Known Subclasses:
AutomatonConstraint, CircuitConstraint, CumulativeConstraint, MultipleCircuitConstraint, NoOverlap2dConstraint, ReservoirConstraint, TableConstraint

public class Constraint extends Object
Wrapper around a ConstraintProto.

Constraints created by the CpModel class are automatically added to the model. One needs this class to add an enforcement literal to a constraint.

  • Constructor Details

  • Method Details

    • onlyEnforceIf

      public void onlyEnforceIf(Literal lit)
      Adds a literal to the constraint.
    • onlyEnforceIf

      public void onlyEnforceIf(Literal[] lits)
      Adds a list of literals to the constraint.
    • getIndex

      public int getIndex()
      Returns the index of the constraint in the model.
    • getBuilder

      public ConstraintProto.Builder getBuilder()
      Returns the constraint builder.