Class SetDomain

java.lang.Object
org.jacop.core.Domain
org.jacop.set.core.SetDomain
Direct Known Subclasses:
BoundSetDomain

public abstract class SetDomain extends Domain
Defines a set interval determined by a least upper bound(lub) and a greatest lower bound(glb). The domain consist of zero, one or several sets.
Version:
4.10
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Any event.
    static final int
    Bound event.
    static final int
    It specifies event that has changed the cardinality of the set.
    static final SetDomain
    It predefines empty domain so there is no need to constantly create it when needed.
    (package private) static final int[][]
    It specifies for each event what other events are subsumed by this event.
    static final int
    It specifies event that GLB has grown.
    static final int
    It specifies event that Set variable became singleton.
    static final int
    It specifies event that LUB has shrank.
    static final int
    It specifies the maximum element in the set domain.
    static final int
    It specifies the minimum element in the set domain.
    It specifies the previous domain which was used by this domain.
    static final int
    It specifies an unique ID for the domain.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    addDom(int min, int max)
    Adds an interval [min..max] to the domain.
    abstract void
    Adds a set of values to the set of possible values used within this set domain.
    abstract void
    Adds an interval to the lub.
    abstract void
    addDom(SetDomain domain)
    Adds a set domain to this set domain.
    abstract IntDomain
    Returns the cardinality of the setDomain as [glb.card(), lub.card()]
    abstract String
    It checks if the domain has correct state.
    abstract void
    Sets the domain to an empty SetDomain.
    abstract SetDomain
    It clones the domain object.
    abstract SetDomain
    It clones the domain object, only data responsible for encoding domain values is cloned.
    abstract boolean
    contains(int value)
    It checks if value belongs to the domain of the set.
    abstract boolean
    It checks if the supplied set or setDomain is still potentially a subset of this domain.
    abstract boolean
    It checks if the supplied set domain is a subset of this domain.
    abstract int
    It returns an unique identifier of the domain.
    abstract boolean
    eq(SetDomain domain)
    It checks if the domain is equal to the supplied domain.
    int[]
    getEventsInclusion(int pruningEvent)
    It helps to specify what events should be executed if a given event occurs.
    abstract IntDomain
    glb()
    It returns the least upper bound of the domain.
    void
    in(int level, Var var, Domain domain)
    It enforces that this domain is included within the specified domain.
    abstract void
    in(int storeLevel, SetVar var, IntDomain glb, IntDomain lub)
    This function is equivalent to in(int storeLevel, Variable var, int min, int max).
    abstract void
    in(int storeLevel, SetVar var, SetDomain domain)
    It updates the domain to have values only within the domain.
    abstract void
    inCardinality(int level, SetVar a, int i, int j)
    It restricts the possible cardinality of the set domain.
    abstract void
    inGLB(int level, SetVar var, int element)
    It adds if necessary an element to glb.
    abstract void
    inGLB(int level, SetVar var, IntDomain domain)
    It specifies what elements must be in GLB.
    abstract void
    inLUB(int level, SetVar var, IntDomain domain)
    It specifies what elements can be in LUB.
    abstract void
    inLUBComplement(int level, SetVar var, int element)
    It specifies the element which can *NOT* be used as an element within a set assign to a set variable.
    abstract SetDomain
    It intersects current domain with the set of allowed values to be taken by the set domain.
    abstract SetDomain
    It intersects current domain with the one given as a parameter.
    abstract void
    inValue(int level, SetVar var, IntDomain set)
    It assigns a set variable to the specified value.
    abstract boolean
    It returns true if given domain is empty.
    abstract boolean
    isIntersecting(int min, int max)
    In intersects current domain with the interval min..max.
    abstract boolean
    It returns true if this domain intersects with the supplied domain.
    abstract boolean
    A set is never numeric
    abstract boolean
    A set is not sparse
    abstract IntDomain
    lub()
    It returns the least upper bound of the domain.
    int
    It returns the number of constraints
    void
    putModelConstraint(int storeLevel, Var var, Constraint C, int pruningEvent)
    It adds a constraint to a domain, it should only be called by putConstraint function of Variable object.
    void
    putSearchConstraint(int storeLevel, Var var, Constraint C)
    It adds a constraint to a domain, it should only be called by putConstraint function of Variable object.
    recentDomainPruning(int storeLevel)
    It returns the values which have been removed at current store level.
    void
    removeLevel(int level, Var var)
    It removes the specified level.
    void
    removeModelConstraint(int storeLevel, Var var, Constraint C)
    It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.
    void
    removeSearchConstraint(int storeLevel, Var var, int position, Constraint C)
    It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.
    abstract void
    setDomain(int min, int max)
    It sets the domain to contain any values in between min and max.
    abstract void
    It sets the domain to the specified domain.
    abstract boolean
    It returns true if given domain has only one set-element.
    abstract boolean
    It check whether the set domain is singleton and its value is equal to the specified set.
    int
    It returns all constraints which are associated with variable, even the ones which are already satisfied.
    abstract SetDomain
    subtract(int value)
    It removes the value from any set allowed to be taken by this set domain.
    abstract SetDomain
    subtract(int min, int max)
    It subtracts the set {min..max}.
    abstract SetDomain
    It subtracts domain from current domain and returns the result.
    It returns string description of the constraints attached to the domain.
    not implemented.
    abstract SetDomain
    union(int value)
    It computes union of this domain and value.
    abstract SetDomain
    union(int min, int max)
    It computes union of this domain and the interval.
    abstract SetDomain
    union(SetDomain domain)
    It computes union of the supplied domain with this domain.
    It returns value enumeration of the domain values.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • MinElement

      public static final int MinElement
      It specifies the minimum element in the set domain.
    • MaxElement

      public static final int MaxElement
      It specifies the maximum element in the set domain.
    • SetDomainID

      public static final int SetDomainID
      It specifies an unique ID for the domain.
      See Also:
    • GROUND

      public static final int GROUND
      It specifies event that Set variable became singleton.
      See Also:
    • GLB

      public static final int GLB
      It specifies event that GLB has grown.
      See Also:
    • LUB

      public static final int LUB
      It specifies event that LUB has shrank.
      See Also:
    • BOUND

      public static final int BOUND
      Bound event. Both bounds have changed.
      See Also:
    • ANY

      public static final int ANY
      Any event.
      See Also:
    • CARDINALITY

      public static final int CARDINALITY
      It specifies event that has changed the cardinality of the set.
      See Also:
    • eventsInclusion

      static final int[][] eventsInclusion
      It specifies for each event what other events are subsumed by this event. Possibly implement this by bit flags in int.
    • previousDomain

      public SetDomain previousDomain
      It specifies the previous domain which was used by this domain. The old domain is stored here and can be easily restored if necessary.
    • emptyDomain

      public static final SetDomain emptyDomain
      It predefines empty domain so there is no need to constantly create it when needed.
  • Constructor Details

    • SetDomain

      public SetDomain()
  • Method Details

    • getEventsInclusion

      public int[] getEventsInclusion(int pruningEvent)
      It helps to specify what events should be executed if a given event occurs.
      Specified by:
      getEventsInclusion in class Domain
      Parameters:
      pruningEvent - the pruning event for which we want to know what events it encompasses.
      Returns:
      an array specifying what events should be included given this event.
    • addDom

      public abstract void addDom(Interval i)
      Adds an interval to the lub.
      Parameters:
      i - The interval to be added to the lub.
    • addDom

      public abstract void addDom(IntDomain set)
      Adds a set of values to the set of possible values used within this set domain. It changes the cardinality too to avoid cardinality constraining the domain.
      Parameters:
      set - a set of values which can be taken by a set domain.
    • addDom

      public abstract void addDom(SetDomain domain)
      Adds a set domain to this set domain. This operation may add more sets than intended if for example used in the context of BoundSetDomain which can not represent arbitrary union of two sets.
      Parameters:
      domain - a set domain containing information what sets are being added.
    • addDom

      public abstract void addDom(int min, int max)
      Adds an interval [min..max] to the domain.
      Parameters:
      min - min value in the set
      max - max value in the set
    • card

      public abstract IntDomain card()
      Returns the cardinality of the setDomain as [glb.card(), lub.card()]
      Returns:
      The cardinality of the setDomain given as a boundDomain.
    • clear

      public abstract void clear()
      Sets the domain to an empty SetDomain.
      Specified by:
      clear in class Domain
    • contains

      public abstract boolean contains(IntDomain set)
      It checks if the supplied set or setDomain is still potentially a subset of this domain.
      Parameters:
      set - the set for which we check the inclusion relation.
      Returns:
      true, if this domain contains provided set, false otherwise.
    • contains

      public abstract boolean contains(SetDomain domain)
      It checks if the supplied set domain is a subset of this domain.
      Parameters:
      domain - the domain for which we check the inclusion relation.
      Returns:
      true, if this domain contains provided domain, false otherwise.
    • contains

      public abstract boolean contains(int value)
      It checks if value belongs to the domain of the set.
      Parameters:
      value - value which is checked.
      Returns:
      true if the value being checked can still be included in the set, false otherwise.
    • domainID

      public abstract int domainID()
      It returns an unique identifier of the domain.
      Specified by:
      domainID in class Domain
      Returns:
      it returns an integer id of the domain.
    • eq

      public abstract boolean eq(SetDomain domain)
      It checks if the domain is equal to the supplied domain.
      Parameters:
      domain - against which the equivalence test is performed.
      Returns:
      true if suppled domain has the same elements as this domain.
    • in

      public abstract void in(int storeLevel, SetVar var, IntDomain glb, IntDomain lub)
      This function is equivalent to in(int storeLevel, Variable var, int min, int max).
      Parameters:
      storeLevel - the level of the store at which the change occurrs.
      var - the set variable for which the domain may change.
      glb - the greatest lower bound of the domain.
      lub - the least upper bound of the domain.
    • in

      public abstract void in(int storeLevel, SetVar var, SetDomain domain)
      It updates the domain to have values only within the domain. The type of update is decided by the value of stamp. It informs the variable of a change if it occurred.
      Parameters:
      storeLevel - level of the store at which the update occurs.
      var - variable for which this domain is used.
      domain - the domain according to which the domain is updated.
    • intersect

      public abstract SetDomain intersect(SetDomain domain)
      It intersects current domain with the one given as a parameter.
      Parameters:
      domain - domain with which the intersection needs to be computed.
      Returns:
      the intersection between supplied domain and this domain.
    • intersect

      public abstract SetDomain intersect(IntDomain set)
      It intersects current domain with the set of allowed values to be taken by the set domain.
      Parameters:
      set - set of values which are allowed to be used within a set.
      Returns:
      the intersection of this domain with the set of allowed values.
    • isEmpty

      public abstract boolean isEmpty()
      It returns true if given domain is empty.
      Specified by:
      isEmpty in class Domain
      Returns:
      true if the given domain is empty.
    • isIntersecting

      public abstract boolean isIntersecting(SetDomain domain)
      It returns true if this domain intersects with the supplied domain.
      Parameters:
      domain - the domain against which the intersection is being checked.
      Returns:
      true if the given domain intersects this domain.
    • isIntersecting

      public abstract boolean isIntersecting(int min, int max)
      In intersects current domain with the interval min..max.
      Parameters:
      min - the left bound of the interval (inclusive)
      max - the right bound of the interval (inclusive)
      Returns:
      the intersection between the specified interval and this domain.
    • isNumeric

      public abstract boolean isNumeric()
      A set is never numeric
      Specified by:
      isNumeric in class Domain
      Returns:
      false
    • isSparseRepresentation

      public abstract boolean isSparseRepresentation()
      A set is not sparse
      Specified by:
      isSparseRepresentation in class Domain
      Returns:
      false
    • lub

      public abstract IntDomain lub()
      It returns the least upper bound of the domain.
      Returns:
      the least upper bound of the domain.
    • glb

      public abstract IntDomain glb()
      It returns the least upper bound of the domain.
      Returns:
      the least upper bound of the domain.
    • clone

      public abstract SetDomain clone()
      It clones the domain object.
      Specified by:
      clone in class Domain
      Returns:
      return a clone of the domain.
    • cloneLight

      public abstract SetDomain cloneLight()
      It clones the domain object, only data responsible for encoding domain values is cloned. All other fields must be set separately.
      Specified by:
      cloneLight in class Domain
      Returns:
      return a clone of the domain. It aims at getting domain of the proper class type.
    • putModelConstraint

      public void putModelConstraint(int storeLevel, Var var, Constraint C, int pruningEvent)
      It adds a constraint to a domain, it should only be called by putConstraint function of Variable object. putConstraint function from Variable must make a copy of a vector of constraints if vector was not cloned.
      Specified by:
      putModelConstraint in class Domain
      Parameters:
      storeLevel - the level at which the model constraint is to be added.
      var - variable to which the constraint is attached to.
      C - the constraint which is being attached to a variable.
      pruningEvent - the type of the prunning event required to check the consistency of the attached constraint.
    • putSearchConstraint

      public void putSearchConstraint(int storeLevel, Var var, Constraint C)
      It adds a constraint to a domain, it should only be called by putConstraint function of Variable object. putConstraint function from Variable must make a copy of a vector of constraints if vector was not cloned.
      Specified by:
      putSearchConstraint in class Domain
      Parameters:
      storeLevel - the level at which the search constraint is to be added.
      var - variable to which the constraint is attached to.
      C - the constraint which is being attached to a variable.
    • recentDomainPruning

      public SetDomain recentDomainPruning(int storeLevel)
      It returns the values which have been removed at current store level.
      Parameters:
      storeLevel - the current store level.
      Returns:
      emptyDomain if domain did not change at current level, or the set of values which have been removed at current level.
    • removeLevel

      public void removeLevel(int level, Var var)
      It removes the specified level. This function may re-instantiate the old copy of the domain (previous value) or recover from changes done at stamp level to get the previous value at level lower at provided level.
      Specified by:
      removeLevel in class Domain
      Parameters:
      level - the level which is being removed.
      var - the variable to which this domain belonged to.
    • removeSearchConstraint

      public void removeSearchConstraint(int storeLevel, Var var, int position, Constraint C)
      It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.
      Specified by:
      removeSearchConstraint in class Domain
      Parameters:
      storeLevel - specifies the current level of the store, from which it should be removed.
      var - specifies variable for which the constraint is being removed.
      position - specifies the position of the removed constraint.
      C - the constraint which is being removed.
    • removeModelConstraint

      public void removeModelConstraint(int storeLevel, Var var, Constraint C)
      It removes a constraint from a domain, it should only be called by removeConstraint function of Variable object.
      Specified by:
      removeModelConstraint in class Domain
      Parameters:
      storeLevel - specifies the current level of the store, from which it should be removed.
      var - specifies variable for which the constraint is being removed.
      C - the constraint which is being removed.
    • setDomain

      public abstract void setDomain(SetDomain domain)
      It sets the domain to the specified domain.
      Parameters:
      domain - the domain from which this domain takes all elements.
    • setDomain

      public abstract void setDomain(int min, int max)
      It sets the domain to contain any values in between min and max.
      Parameters:
      min - the minimum value allowed to be taken within the set.
      max - the maximal value allowed to be taken within the set.
    • singleton

      public abstract boolean singleton()
      It returns true if given domain has only one set-element.
      Specified by:
      singleton in class Domain
      Returns:
      true if the domain contains only one set-element.
    • singleton

      public abstract boolean singleton(IntDomain set)
      It check whether the set domain is singleton and its value is equal to the specified set.
      Parameters:
      set - the set for which we check if it is equal to a value taken by this set domain.
      Returns:
      true, if this set domain is equal to supplied set, false otherwise.
    • sizeConstraintsOriginal

      public int sizeConstraintsOriginal()
      It returns all constraints which are associated with variable, even the ones which are already satisfied.
      Specified by:
      sizeConstraintsOriginal in class Domain
      Returns:
      the number of constraints attached to the original domain of the variable associated with this domain.
    • subtract

      public abstract SetDomain subtract(SetDomain domain)
      It subtracts domain from current domain and returns the result.
      Parameters:
      domain - the domain which is subtracted from this domain.
      Returns:
      the result of the subtraction.
    • subtract

      public abstract SetDomain subtract(int min, int max)
      It subtracts the set {min..max}.
      Parameters:
      min - the left bound of the set.
      max - the right bound of the set.
      Returns:
      the result of the subtraction.
    • subtract

      public abstract SetDomain subtract(int value)
      It removes the value from any set allowed to be taken by this set domain.
      Parameters:
      value - value which can not be used within any set value assigned to this set domain.
      Returns:
      the domain which does not allow specified value to be used.
    • toStringConstraints

      public String toStringConstraints()
      It returns string description of the constraints attached to the domain.
      Specified by:
      toStringConstraints in class Domain
      Returns:
      the string description.
    • toStringFull

      public String toStringFull()
      not implemented.
      Specified by:
      toStringFull in class Domain
      Returns:
      complete description of the domain.
    • union

      public abstract SetDomain union(SetDomain domain)
      It computes union of the supplied domain with this domain.
      Parameters:
      domain - the domain for which the union is computed.
      Returns:
      the union of this domain with the supplied one.
    • union

      public abstract SetDomain union(int min, int max)
      It computes union of this domain and the interval.
      Parameters:
      min - the left bound of the interval (inclusive).
      max - the right bound of the interval (inclusive).
      Returns:
      the union of this domain and the interval.
    • union

      public abstract SetDomain union(int value)
      It computes union of this domain and value.
      Parameters:
      value - it specifies the value which is being added.
      Returns:
      domain which is a union of this one and the value.
    • valueEnumeration

      public abstract ValueEnumeration valueEnumeration()
      It returns value enumeration of the domain values.
      Specified by:
      valueEnumeration in class Domain
      Returns:
      valueEnumeration which can be used to enumerate the sets of this domain one by one.
    • checkInvariants

      public abstract String checkInvariants()
      Description copied from class: Domain
      It checks if the domain has correct state.
      Specified by:
      checkInvariants in class Domain
      Returns:
      It returns the information about the first invariant which does not hold or null otherwise.
    • in

      public void in(int level, Var var, Domain domain)
      Description copied from class: Domain
      It enforces that this domain is included within the specified domain.
      Specified by:
      in in class Domain
      Parameters:
      level - store level at which this inclusion is enforced.
      var - variable which is informed of the change if any occurs.
      domain - the domain which restricts this domain.
    • inLUB

      public abstract void inLUB(int level, SetVar var, IntDomain domain)
      It specifies what elements can be in LUB. It will not add any new elements only removed the elements currently in LUB but not permitted by the argument domain.
      Parameters:
      level - level of the store at which this restriction takes place.
      var - variable which domain is being restricted.
      domain - the domain specifying the allowed values the domain of the set variable.
    • inLUBComplement

      public abstract void inLUBComplement(int level, SetVar var, int element)
      It specifies the element which can *NOT* be used as an element within a set assign to a set variable.
      Parameters:
      level - level of the store at which this restriction takes place.
      var - variable which domain is being restricted.
      element - the value being removed from the domain of the set variable.
    • inGLB

      public abstract void inGLB(int level, SetVar var, IntDomain domain)
      It specifies what elements must be in GLB. It will add new elements if they are not already in GLB.
      Parameters:
      level - level of the store at which this addition takes place.
      var - variable which domain is being restricted.
      domain - the domain specifying the required values of the set variable.
    • inGLB

      public abstract void inGLB(int level, SetVar var, int element)
      It adds if necessary an element to glb.
      Parameters:
      level - level at which the change is recorded.
      var - set variable to which the change applies to.
      element - the element which must be in glb.
    • inValue

      public abstract void inValue(int level, SetVar var, IntDomain set)
      It assigns a set variable to the specified value.
      Parameters:
      level - level at which the change is recorded.
      var - set variable to which the change applies to.
      set - the value assigned to a set variable.
    • noConstraints

      public int noConstraints()
      It returns the number of constraints
      Specified by:
      noConstraints in class Domain
      Returns:
      the number of constraints attached to this domain.
    • inCardinality

      public abstract void inCardinality(int level, SetVar a, int i, int j)
      It restricts the possible cardinality of the set domain.
      Parameters:
      level - level of the store at which the restriction takes place.
      a - the variable which domain is being restricted.
      i - the minimal allowed cardinality
      j - the maximal allowed cardinality