Class SetVar

java.lang.Object
org.jacop.core.Var
org.jacop.set.core.SetVar
All Implemented Interfaces:
Backtrackable

public class SetVar extends Var
Defines a Finite Domain Variable (FDV) and related operations on it.
Version:
4.9
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    It specifies the current domain associated with this set variable.

    Fields inherited from class org.jacop.core.Var

    id, idNumber, index, store, weight
  • Constructor Summary

    Constructors
    Constructor
    Description
    No parameter, explicit, empty constructor for subclasses.
    SetVar(Store store)
    This constructor creates a variable with empty domain (standard IntervalDomain domain), automatically generated name, and empty attached constraint list.
    SetVar(Store store, int min, int max)
    This constructor creates a set variable with domain a set min..max automatically generated name, and empty attached constraint list.
    SetVar(Store store, String name)
    This constructor creates a variable with an empty domain (standard IntervalDomain domain), the specified name, and an empty attached constraint list.
    SetVar(Store store, String name, int min, int max)
    This constructor creates a variable in a given store, with the domain specified by min..max and with the given name.
    SetVar(Store store, String name, SetDomain dom)
    It creates a variable in a given store, with a given name and a given domain.
    SetVar(Store store, SetDomain dom)
    It creates a variable in a given store, with a given name and a given domain.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDom(int min, int max)
    It is possible to add the domain of variable.
    void
    It is possible to add the domain of variable.
    dom()
    This function returns current domain of the variable.
    void
    domainHasChanged(int event)
    It informs the variable that its variable has changed according to the specified event.
    boolean
    eq(SetVar var)
    It checks if the domains of variables are equal.
    int
    It returns the size of the current domain.
    double
    It returns the size of the current domain.
    boolean
    It checks if the domain is empty.
    int
    This function returns stamp of the current domain of variable.
    void
    It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
    void
    putModelConstraint(Constraint c, int pruningEvent)
    It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
    void
    It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.
    It returns the values which have been removed at current store level.
    void
    remove(int removedLevel)
    It specifies the function being called by the manager upon backtracking.
    void
    It detaches constraint from the current variable, so change in variable will not cause constraint reevaluation.
    void
    setDomain(int min, int max)
    It is possible to set the domain of variable.
    void
    It is possible to set the domain of variable.
    boolean
    It checks if the domain contains only one value.
    int
    It returns current number of constraints which are associated with variable and are not yet satisfied.
    int
    It returns all constraints which are associated with variable, even the ones which are already satisfied.
    int
    It returns current number of constraints which are associated with variable and are not yet satisfied.
     
    It returns the string representation of the variable using the full representation of the domain.

    Methods inherited from class java.lang.Object

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

    • domain

      public SetDomain domain
      It specifies the current domain associated with this set variable.
  • Constructor Details

    • SetVar

      public SetVar(Store store, String name, SetDomain dom)
      It creates a variable in a given store, with a given name and a given domain.
      Parameters:
      store - store in which the variable is created.
      name - the name for the variable being created.
      dom - the domain of the variable being created.
    • SetVar

      public SetVar(Store store, SetDomain dom)
      It creates a variable in a given store, with a given name and a given domain.
      Parameters:
      store - store in which the variable is created.
      dom - the domain of the variable being created.
    • SetVar

      public SetVar()
      No parameter, explicit, empty constructor for subclasses.
    • SetVar

      public SetVar(Store store)
      This constructor creates a variable with empty domain (standard IntervalDomain domain), automatically generated name, and empty attached constraint list.
      Parameters:
      store - store in which the variable is created.
    • SetVar

      public SetVar(Store store, int min, int max)
      This constructor creates a set variable with domain a set min..max automatically generated name, and empty attached constraint list.
      Parameters:
      store - store in which the variable is created.
      min - the minimum value of the domain.
      max - the maximum value of the domain.
    • SetVar

      public SetVar(Store store, String name)
      This constructor creates a variable with an empty domain (standard IntervalDomain domain), the specified name, and an empty attached constraint list.
      Parameters:
      store - store in which the variable is created.
      name - the name for the variable being created.
    • SetVar

      public SetVar(Store store, String name, int min, int max)
      This constructor creates a variable in a given store, with the domain specified by min..max and with the given name.
      Parameters:
      store - the store in which the variable is created.
      name - the name of the variable being created.
      min - the minimum value of the variables domain.
      max - the maximum value of the variables domain.
  • Method Details

    • addDom

      public void addDom(int min, int max)
      It is possible to add the domain of variable. It should be used with care, only right after variable was created and before it is used in constraints or search. Current implementation requires domains being added in the increasing order (e.g. 1..5 before 9..10).
      Parameters:
      min - the left bound of the interval being added.
      max - the right bound of the interval being added.
    • setDomain

      public void setDomain(int min, int max)
      It is possible to set the domain of variable. It should be used with care, only right after variable was created and before it is used in constraints or search.
      Parameters:
      min - the left bound of the interval used to set this variable domain to.
      max - the right bound of the interval used to set this variable domain to.
    • setDomain

      public void setDomain(SetDomain dom)
      It is possible to set the domain of variable. It should be used with care, only right after variable was created and before it is used in constraints or search.
      Parameters:
      dom - domain to which the current variable domain is set to.
    • addDom

      public void addDom(SetDomain dom)
      It is possible to add the domain of variable. It should be used with care, only right after variable was created and before it is used in constraints or search.
      Parameters:
      dom - the added domain.
    • dom

      public SetDomain dom()
      This function returns current domain of the variable.
      Specified by:
      dom in class Var
      Returns:
      the domain of the variable.
    • eq

      public boolean eq(SetVar var)
      It checks if the domains of variables are equal.
      Parameters:
      var - the variable to which current variable is compared to.
      Returns:
      true if both variables have the same domain.
    • getSize

      public int getSize()
      It returns the size of the current domain.
      Specified by:
      getSize in class Var
      Returns:
      the size of the variables domain.
    • getSizeFloat

      public double getSizeFloat()
      It returns the size of the current domain.
      Specified by:
      getSizeFloat in class Var
      Returns:
      the size of the variables domain.
    • isEmpty

      public boolean isEmpty()
      It checks if the domain is empty.
      Specified by:
      isEmpty in class Var
      Returns:
      true if variable domain is empty.
    • putModelConstraint

      public void putModelConstraint(Constraint c, int pruningEvent)
      It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated. Pruning events constants from 0 to n, where n is the strongest pruning event.
      Specified by:
      putModelConstraint in class Var
      Parameters:
      c - the constraint which is being attached to the variable.
      pruningEvent - type of the event which must occur to trigger the execution of the consistency function.
    • putSearchConstraint

      public void putSearchConstraint(Constraint c)
      It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.
      Specified by:
      putSearchConstraint in class Var
      Parameters:
      c - the constraint which is added as a search constraint.
    • recentDomainPruning

      public SetDomain recentDomainPruning()
      It returns the values which have been removed at current store level. It does _not_ return the recent pruning in between the calls to that function.
      Returns:
      difference between the current level and the one before it.
    • removeConstraint

      public void removeConstraint(Constraint c)
      It detaches constraint from the current variable, so change in variable will not cause constraint reevaluation. It is only removed from the current level onwards. Removing current level at later stage will automatically re-attached the constraint to the variable.
      Specified by:
      removeConstraint in class Var
      Parameters:
      c - the constraint being detached from the variable.
    • singleton

      public boolean singleton()
      It checks if the domain contains only one value.
      Specified by:
      singleton in class Var
      Returns:
      true if the variable domain is a singleton, false otherwise.
    • sizeConstraints

      public int sizeConstraints()
      It returns current number of constraints which are associated with variable and are not yet satisfied.
      Specified by:
      sizeConstraints in class Var
      Returns:
      number of constraints attached to the variable.
    • 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 Var
      Returns:
      number of constraints attached at the earliest level of the variable.
    • sizeSearchConstraints

      public int sizeSearchConstraints()
      It returns current number of constraints which are associated with variable and are not yet satisfied.
      Specified by:
      sizeSearchConstraints in class Var
      Returns:
      number of attached search constraints.
    • level

      public int level()
      This function returns stamp of the current domain of variable. It is equal or smaller to the stamp of store. Larger difference indicates that variable has been changed for a longer time.
      Specified by:
      level in interface Backtrackable
      Specified by:
      level in class Var
      Returns:
      level for which the most recent changes have been applied to.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringFull

      public String toStringFull()
      It returns the string representation of the variable using the full representation of the domain.
      Specified by:
      toStringFull in class Var
      Returns:
      string representation.
    • remove

      public void remove(int removedLevel)
      Description copied from interface: Backtrackable
      It specifies the function being called by the manager upon backtracking. The manager may call this function for the objects which have not changed but it must call this function for all objects that have changed.
      Parameters:
      removedLevel - level that is being removed.
    • domainHasChanged

      public void domainHasChanged(int event)
      It informs the variable that its variable has changed according to the specified event.
      Specified by:
      domainHasChanged in class Var
      Parameters:
      event - the type of the change (GROUND, BOUND, ANY).
    • putConstraint

      public void putConstraint(Constraint c)
      Description copied from class: Var
      It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
      Specified by:
      putConstraint in class Var
      Parameters:
      c - the constraint being attached to this variable.