Class Constraint

java.lang.Object
com.google.ortools.sat.Constraint

public class Constraint
extends java.lang.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 Summary

    Constructors
    Constructor Description
    Constraint​(CpModelProto.Builder builder)  
  • Method Summary

    Modifier and Type Method Description
    ConstraintProto.Builder getBuilder()
    Returns the constraint builder.
    int getIndex()
    Returns the index of the constraint in the model.
    void onlyEnforceIf​(Literal lit)
    Adds a literal to the constraint.
    void onlyEnforceIf​(Literal[] lits)
    Adds a list of literals to the constraint.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.