Class Domain

java.lang.Object
org.jacop.core.Domain
Direct Known Subclasses:
FloatDomain, IntDomain, SetDomain

public abstract class Domain extends Object
Defines a Domain and related operations on it.
Version:
4.9
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final FailException
    An exception used if failure encountered in functions in();
    It specifies constraints which are attached to current domain, each array has different pruning event.
    int[]
    It specifies the first position of a constraint which is satisfied.
    static final int
    It specifies the constant responsible of conveying a message that no information is provided by the domain when describing the change which has occurred within the domain.
    static final int
    It specifies the constant for NONE event, if event is NONE then the constraint is not attached to a variable.
    It specifies constraints which are attached to current domain.
    boolean
    It specifies if the vector of constraints were cloned (if it was not cloned then the same vector is reused across domains with different stamps.
    int
    It specifies the position of the last constraint which is still not yet satisfied.
    int
    It specifies the level of this domain, which specifies at which store level it was created and used.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    It checks if the domain has correct state.
    abstract void
    It removes all elements.
    abstract Domain
    It clones the domain object.
    abstract Domain
    It clones the domain object, only data responsible for encoding domain values is cloned.
    It returns all the constraints attached currently to the domain.
    abstract int
    It returns an unique identifier of the domain.
    abstract int[]
    getEventsInclusion(int pruningEvent)
    It specifies what events should be executed if a given event occurs.
    abstract int
    It returns the size of the domain.
    abstract void
    in(int level, Var var, Domain domain)
    It enforces that this domain is included within the specified domain.
    abstract boolean
    It returns true if given domain is empty.
    abstract boolean
    It specifies if domain is a finite domain of numeric values (integers).
    abstract boolean
    It specifies if the domain type is more suited to representing sparse domain.
    abstract int
    It returns the number of constraints
    int
    It returns number of search constraints.
    abstract 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.
    abstract 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.
    abstract void
    removeLevel(int level, Var var)
    It removes the specified level.
    abstract 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.
    abstract 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.
     
    void
    setStamp(int stamp)
    It sets the stamp of the domain.
    abstract boolean
    It returns true if given domain has only one element.
    abstract boolean
    It returns true if given domain has only one element.
    int
    It returns all constraints which are associated with variable, even the ones which are already satisfied.
    abstract int
    It returns all constraints which are associated with variable, even the ones which are already satisfied.
    int
    It returns the stamp of the domain.
    abstract String
    It returns string description of the domain (only values in the domain).
    abstract String
    It returns string description of the constraints attached to the domain.
    abstract String
    It returns complete string description containing all relevant information about the 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

    • NOINFO

      public static final int NOINFO
      It specifies the constant responsible of conveying a message that no information is provided by the domain when describing the change which has occurred within the domain.
      See Also:
    • NONE

      public static final int NONE
      It specifies the constant for NONE event, if event is NONE then the constraint is not attached to a variable. Useful for constraints which are always satisfied or not satisfied after the first consistency function execution.
      See Also:
    • failException

      public static final FailException failException
      An exception used if failure encountered in functions in();
    • modelConstraints

      public Constraint[][] modelConstraints
      It specifies constraints which are attached to current domain, each array has different pruning event.
    • modelConstraintsToEvaluate

      public int[] modelConstraintsToEvaluate
      It specifies the first position of a constraint which is satisfied. All constraints at earlier positions are not satisfied yet.
    • searchConstraints

      public List<Constraint> searchConstraints
      It specifies constraints which are attached to current domain.
    • searchConstraintsCloned

      public boolean searchConstraintsCloned
      It specifies if the vector of constraints were cloned (if it was not cloned then the same vector is reused across domains with different stamps. Only reading actions are allowed on not cloned vector of constraints.
    • searchConstraintsToEvaluate

      public int searchConstraintsToEvaluate
      It specifies the position of the last constraint which is still not yet satisfied.
    • stamp

      public int stamp
      It specifies the level of this domain, which specifies at which store level it was created and used. The domain is only valid (used) at a store level equal domain stamp.
  • Constructor Details

    • Domain

      public Domain()
  • Method Details

    • clear

      public abstract void clear()
      It removes all elements.
    • cloneLight

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

      public abstract Domain clone()
      It clones the domain object.
      Overrides:
      clone in class Object
    • valueEnumeration

      public abstract ValueEnumeration valueEnumeration()
      It returns value enumeration of the domain values.
      Returns:
      valueEnumeration which can be used to enumerate one by one value from this domain.
    • getSize

      public abstract int getSize()
      It returns the size of the domain.
      Returns:
      number of elements in this domain.
    • isEmpty

      public abstract boolean isEmpty()
      It returns true if given domain is empty.
      Returns:
      true if the given domain is empty.
    • removeModelConstraint

      public abstract 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. It is called for example in a situation when a constraint is satisfied.
      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.
    • removeSearchConstraint

      public abstract 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.
      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.
    • searchConstraints

      public List<Constraint> searchConstraints()
      Returns:
      it returns the array containing search constraints (the ones imposed after setting up the model).
    • setStamp

      public void setStamp(int stamp)
      It sets the stamp of the domain.
      Parameters:
      stamp - defines the time stamp of the domain.
    • singleton

      public abstract boolean singleton()
      It returns true if given domain has only one element.
      Returns:
      true if the domain contains only one element.
    • singleton

      public abstract boolean singleton(Domain value)
      It returns true if given domain has only one element.
      Parameters:
      value - value represented as domain object to which the domain must be equal to.
      Returns:
      true if the domain contains only one element.
    • noConstraints

      public abstract int noConstraints()
      It returns the number of constraints
      Returns:
      the number of constraints attached to this domain.
    • noSearchConstraints

      public int noSearchConstraints()
      It returns number of search constraints.
      Returns:
      the number of search constraints.
    • stamp

      public int stamp()
      It returns the stamp of the domain.
      Returns:
      the level of the domain.
    • toString

      public abstract String toString()
      It returns string description of the domain (only values in the domain).
      Overrides:
      toString in class Object
    • toStringConstraints

      public abstract String toStringConstraints()
      It returns string description of the constraints attached to the domain.
      Returns:
      the string description.
    • toStringFull

      public abstract String toStringFull()
      It returns complete string description containing all relevant information about the domain.
      Returns:
      complete description of the domain.
    • removeLevel

      public abstract 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.
      Parameters:
      level - the level which is being removed.
      var - the variable to which this domain belonged to.
    • domainID

      public abstract int domainID()
      It returns an unique identifier of the domain.
      Returns:
      it returns an integer id of the domain.
    • isSparseRepresentation

      public abstract boolean isSparseRepresentation()
      It specifies if the domain type is more suited to representing sparse domain.
      Returns:
      true if sparse, false otherwise.
    • isNumeric

      public abstract boolean isNumeric()
      It specifies if domain is a finite domain of numeric values (integers).
      Returns:
      true if domains contains numeric values.
    • putModelConstraint

      public abstract 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 list of model constraints if vector was not cloned.
      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 abstract 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 list of search constraints if vector was not cloned.
      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.
    • sizeConstraints

      public int sizeConstraints()
      It returns all constraints which are associated with variable, even the ones which are already satisfied.
      Returns:
      the number of constraint attached to this domain.
    • sizeConstraintsOriginal

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

      public List<Constraint> constraints()
      It returns all the constraints attached currently to the domain. It should not be used extensively.
      Returns:
      an array of constraints currently attached to the domain.
    • in

      public abstract void in(int level, Var var, Domain domain)
      It enforces that this domain is included within the specified 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.
    • checkInvariants

      public abstract String checkInvariants()
      It checks if the domain has correct state.
      Returns:
      null if everything is ok, otherwise a string describing the problem.
    • getEventsInclusion

      public abstract int[] getEventsInclusion(int pruningEvent)
      It specifies what events should be executed if a given event occurs.
      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.