Class BooleanVar

  • All Implemented Interfaces:
    Backtrackable

    public class BooleanVar
    extends IntVar
    Defines a variable and related operations on it.
    Version:
    4.7
    • Constructor Detail

      • BooleanVar

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

        public BooleanVar​(Store store)
        This constructor creates a variable with empty domain (standard FD domain), automatically generated name, and empty attached constraint list.
        Parameters:
        store - It specifies the store in which boolean variable should be created.
      • BooleanVar

        public BooleanVar​(Store store,
                          java.lang.String name)
        Boolean variable constructor.
        Parameters:
        store - It specifies the store in which boolean variable should be created.
        name - It specifies the id of the variable.
      • BooleanVar

        public BooleanVar​(Store store,
                          java.lang.String name,
                          int min,
                          int max)
        Boolean variable constructor.
        Parameters:
        store - It specifies the store in which boolean variable should be created.
        name - It specifies the id of the variable.
        min - it specifies the minimum value, which must be greater or equal 0.
        max - it specifies the maximum value, which must be smaller or equal 1.
      • BooleanVar

        public BooleanVar​(Store store,
                          int min,
                          int max)
        Boolean variable constructor.
        Parameters:
        store - It specifies the store in which boolean variable should be created.
        min - it specifies the minimum value, which must be greater or equal 0.
        max - it specifies the maximum value, which must be smaller or equal 1.
      • BooleanVar

        public BooleanVar​(Store store,
                          BoundDomain dom)
        It creates a Boolean variable.
        Parameters:
        store - It specifies the store in which boolean variable should be created.
        dom - It specifies the domain of the boolean variable.
      • BooleanVar

        public BooleanVar​(Store store,
                          java.lang.String name,
                          BoundDomain dom)
        It creates a Boolean variable.
        Parameters:
        store - the store in which the variable is being created.
        name - the name of the created variable.
        dom - the domain specifying the domain of the variable.
    • Method Detail

      • putModelConstraint

        public void putModelConstraint​(Constraint constraint,
                                       int pruningEvent)
        It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated. Pruning event is ignored as all are evaluated with GROUND event, since any change to Boolean Variable makes it ground.
        Overrides:
        putModelConstraint in class IntVar
        Parameters:
        constraint - - constraint being attached to a variable.
        pruningEvent - - Only NONE and GROUND events are considered. By default GROUND event is used.
      • putSearchConstraint

        public void putSearchConstraint​(Constraint constraint)
        It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
        Overrides:
        putSearchConstraint in class IntVar
        Parameters:
        constraint - It specifies the constraint which is being added.
      • removeConstraint

        public void removeConstraint​(Constraint constraint)
        It unregisters constraint with current variable, so change in variable will not cause constraint reevaluation.
        Overrides:
        removeConstraint in class IntVar
        Parameters:
        constraint - it specifies the constraint which is no longer attached to a variable.
      • sizeConstraints

        public int sizeConstraints()
        It returns current number of constraints which are associated with variable and are not yet satisfied.
        Overrides:
        sizeConstraints in class IntVar
        Returns:
        the number of constraints currently attached to this variable.
      • sizeConstraintsOriginal

        public int sizeConstraintsOriginal()
        It returns all constraints which are associated with variable, even the ones which are already satisfied.
        Overrides:
        sizeConstraintsOriginal in class IntVar
        Returns:
        the number of constraints originally attached to this variable.
      • sizeSearchConstraints

        public int sizeSearchConstraints()
        It returns current number of constraints which are associated with a boolean variable and are not yet satisfied.
        Overrides:
        sizeSearchConstraints in class IntVar
        Returns:
        the number of constraints.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class IntVar
        Returns:
        it returns the string description of the boolean variable.
      • toStringFull

        public java.lang.String toStringFull()
        Description copied from class: IntVar
        It returns the string representation of the variable using the full representation of the domain.
        Overrides:
        toStringFull in class IntVar
        Returns:
        It returns elaborate string description of the boolean variable and all the components of its domain.
      • addDom

        public void addDom​(Domain 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 BoundDomain dom()
        This function returns current domain of the variable.
        Overrides:
        dom in class IntVar
        Returns:
        the domain of the variable.
      • eq

        public boolean eq​(BooleanVar 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.
        Overrides:
        getSize in class IntVar
        Returns:
        the size of the variables domain.
      • isEmpty

        public boolean isEmpty()
        It checks if the domain is empty.
        Overrides:
        isEmpty in class IntVar
        Returns:
        true if variable domain is empty.
      • recentDomainPruning

        public BoundDomain 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.
        Overrides:
        recentDomainPruning in class IntVar
        Returns:
        difference between the current level and the one before it.
      • singleton

        public boolean singleton()
        It checks if the domain contains only one value.
        Overrides:
        singleton in class IntVar
        Returns:
        true if the variable domain is a singleton, false otherwise.
      • 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
        Overrides:
        level in class IntVar
        Returns:
        level for which the most recent changes have been applied to.
      • 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.
        Specified by:
        remove in interface Backtrackable
        Overrides:
        remove in class IntVar
        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.
        Overrides:
        domainHasChanged in class IntVar
        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.
        Overrides:
        putConstraint in class IntVar
        Parameters:
        c - the constraint being attached to this variable.