Module org.maxicp

Class CPFixedSetVar

java.lang.Object
org.maxicp.cp.engine.core.CPFixedSetVar
All Implemented Interfaces:
CPSetVar, CPVar, ConcreteVar, Var

public class CPFixedSetVar extends Object implements CPSetVar
A fixed set variable that contains a specific set of values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CPFixedSetVar(CPSolver cp, int[] values)
    Creates a fixed set variable with the given values.
  • 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
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CPFixedSetVar

      public CPFixedSetVar(CPSolver cp, int[] values)
      Creates a fixed set variable with the given values.
      Parameters:
      cp - the solver in which the variable is created
      values - the values of the set
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface CPSetVar
    • card

      public CPIntVar card()
      Description copied from interface: CPSetVar
      Returns a variable that represents the cardinality of the set.
      Specified by:
      card in interface CPSetVar
      Returns:
      the cardinality variable
    • fillPossible

      public int fillPossible(int[] dest)
      Description copied from interface: CPSetVar
      Copies the values (in an arbitrary order) of the set of possible elements into an array.
      Specified by:
      fillPossible in interface CPSetVar
      Parameters:
      dest - an array large enough dest.length >= nPossible()
      Returns:
      the size of the set of possible elements
    • fillIncluded

      public int fillIncluded(int[] dest)
      Description copied from interface: CPSetVar
      Copies the values (in an arbitrary order) of the set of included elements into an array.
      Specified by:
      fillIncluded in interface CPSetVar
      Parameters:
      dest - an array large enough dest.length >= nIncluded()
      Returns:
      the size of the set of included elements
    • fillExcluded

      public int fillExcluded(int[] dest)
      Description copied from interface: CPSetVar
      Copies the values (in an arbitrary order) of the set of excluded elements into an array.
      Specified by:
      fillExcluded in interface CPSetVar
      Parameters:
      dest - an array large enough dest.length >= nExcluded()
      Returns:
      the size of the set of excluded elements
    • isPossible

      public boolean isPossible(int v)
      Description copied from interface: CPSetVar
      Returns if a value is possible in the set.
      Specified by:
      isPossible in interface CPSetVar
      Parameters:
      v - the value to check
      Returns:
      true if the value is possible, false otherwise
    • isIncluded

      public boolean isIncluded(int v)
      Description copied from interface: CPSetVar
      Returns if a value is included in the set.
      Specified by:
      isIncluded in interface CPSetVar
      Parameters:
      v - the value to check
      Returns:
      true if the value is included, false otherwise
    • isExcluded

      public boolean isExcluded(int v)
      Description copied from interface: CPSetVar
      Returns if a value is excluded from the set.
      Specified by:
      isExcluded in interface CPSetVar
      Parameters:
      v - the value to check
      Returns:
      true if the value is excluded, false otherwise
    • isFixed

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

      public int nIncluded()
      Description copied from interface: CPSetVar
      Returns the size of the set of included elements
      Specified by:
      nIncluded in interface CPSetVar
      Returns:
      the size of the set of included elements
    • nPossible

      public int nPossible()
      Description copied from interface: CPSetVar
      Returns the size of the set of possible elements
      Specified by:
      nPossible in interface CPSetVar
      Returns:
      the size of the set of possible elements
    • nExcluded

      public int nExcluded()
      Description copied from interface: CPSetVar
      Returns the size of the set of excluded elements
      Specified by:
      nExcluded in interface CPSetVar
      Returns:
      the size of the set of excluded elements
    • getSolver

      public CPSolver getSolver()
      Description copied from interface: CPSetVar
      Returns the solver of the set variable.
      Specified by:
      getSolver in interface CPSetVar
      Returns:
      the solver of the set variable
    • getModelProxy

      public ModelProxy getModelProxy()
      Specified by:
      getModelProxy in interface CPSetVar
      Specified by:
      getModelProxy in interface Var
    • exclude

      public void exclude(int v)
      Description copied from interface: CPSetVar
      Excludes a value from the set.
      Specified by:
      exclude in interface CPSetVar
      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.
    • include

      public void include(int v)
      Description copied from interface: CPSetVar
      Includes a value in the set.
      Specified by:
      include in interface CPSetVar
      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.
    • propagateOnDomainChange

      public void propagateOnDomainChange(CPConstraint c)
      Description copied from interface: CPSetVar
      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.
      Specified by:
      propagateOnDomainChange in interface CPSetVar
      Parameters:
      c - the constraint to notify
    • includeAll

      public void includeAll()
      Description copied from interface: CPSetVar
      Includes all the possible values in the set.
      Specified by:
      includeAll in interface CPSetVar
    • excludeAll

      public void excludeAll()
      Description copied from interface: CPSetVar
      Excludes all the possible values from the set.
      Specified by:
      excludeAll in interface CPSetVar