Module org.maxicp

Interface CPSetVar

All Superinterfaces:
ConcreteVar, CPVar, Var
All Known Implementing Classes:
CPFixedSetVar, CPSetVarImpl

public interface CPSetVar extends CPVar, ConcreteVar
A set variable is a variable that represents a set of integers from an original universe set. Its domain is conceptually represented by: - a set of included integers I - a set of possible integers P - a set of excluded integers S I,P and S are disjoint sets and their union is the universe of the set variable. In addition, a cardinality variable represents the cardinality of the set The variable is considered fixed when the set of possible integers is empty. At this point, the cardinality variable is equal to the size of the set of included integers.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a variable that represents the cardinality of the set.
    void
    exclude(int v)
    Excludes a value from the set.
    void
    Excludes all the possible values from the set.
    int
    fillExcluded(int[] dest)
    Copies the values (in an arbitrary order) of the set of excluded elements into an array.
    int
    fillIncluded(int[] dest)
    Copies the values (in an arbitrary order) of the set of included elements into an array.
    int
    fillPossible(int[] dest)
    Copies the values (in an arbitrary order) of the set of possible elements into an array.
     
    Returns the solver of the set variable.
    void
    include(int v)
    Includes a value in the set.
    void
    Includes all the possible values in the set.
    boolean
    isExcluded(int v)
    Returns if a value is excluded from the set.
    boolean
    Returns if the set variable is fixed.
    boolean
    isIncluded(int v)
    Returns if a value is included in the set.
    boolean
    isPossible(int v)
    Returns if a value is possible in the set.
    int
    Returns the size of the set of excluded elements
    int
    Returns the size of the set of included elements
    int
    Returns the size of the set of possible elements
    void
    Ask that the CPConstraint.propagate() method of the constraint c is called when the domain of the set variable changes (I,P or E).
    int
     
  • Method Details

    • card

      CPIntVar card()
      Returns a variable that represents the cardinality of the set.
      Returns:
      the cardinality variable
    • isFixed

      boolean isFixed()
      Returns if the set variable is fixed.
      Specified by:
      isFixed in interface CPVar
      Returns:
      true if the set variable is fixed, false otherwise
    • nIncluded

      int nIncluded()
      Returns the size of the set of included elements
      Returns:
      the size of the set of included elements
    • nPossible

      int nPossible()
      Returns the size of the set of possible elements
      Returns:
      the size of the set of possible elements
    • nExcluded

      int nExcluded()
      Returns the size of the set of excluded elements
      Returns:
      the size of the set of excluded elements
    • isIncluded

      boolean isIncluded(int v)
      Returns if a value is included in the set.
      Parameters:
      v - the value to check
      Returns:
      true if the value is included, false otherwise
    • isPossible

      boolean isPossible(int v)
      Returns if a value is possible in the set.
      Parameters:
      v - the value to check
      Returns:
      true if the value is possible, false otherwise
    • isExcluded

      boolean isExcluded(int v)
      Returns if a value is excluded from the set.
      Parameters:
      v - the value to check
      Returns:
      true if the value is excluded, false otherwise
    • include

      void include(int v)
      Includes a value in the set.
      Parameters:
      v - the value to include, it must be a possible value from the universe otherwise an exception is thrown. The method has no effect if the value is already included.
    • exclude

      void exclude(int v)
      Excludes a value from the set.
      Parameters:
      v - the value to exclude, it must be a possible value from the universe otherwise an exception is thrown The method has no effect if the value is already excluded.
    • includeAll

      void includeAll()
      Includes all the possible values in the set.
    • excludeAll

      void excludeAll()
      Excludes all the possible values from the set.
    • fillIncluded

      int fillIncluded(int[] dest)
      Copies the values (in an arbitrary order) of the set of included elements into an array.
      Parameters:
      dest - an array large enough dest.length >= nIncluded()
      Returns:
      the size of the set of included elements
    • fillPossible

      int fillPossible(int[] dest)
      Copies the values (in an arbitrary order) of the set of possible elements into an array.
      Parameters:
      dest - an array large enough dest.length >= nPossible()
      Returns:
      the size of the set of possible elements
    • fillExcluded

      int fillExcluded(int[] dest)
      Copies the values (in an arbitrary order) of the set of excluded elements into an array.
      Parameters:
      dest - an array large enough dest.length >= nExcluded()
      Returns:
      the size of the set of excluded elements
    • size

      int size()
    • propagateOnDomainChange

      void propagateOnDomainChange(CPConstraint c)
      Ask that the CPConstraint.propagate() method of the constraint c is called when the domain of the set variable changes (I,P or E). If intererested also in the change of the cardinality variable, call CPIntVar.propagateOnBoundChange(CPConstraint) on the cardinality variable.
      Parameters:
      c - the constraint to notify
    • getSolver

      CPSolver getSolver()
      Returns the solver of the set variable.
      Returns:
      the solver of the set variable
    • getModelProxy

      ModelProxy getModelProxy()
      Specified by:
      getModelProxy in interface Var