Class Var

  • All Implemented Interfaces:
    Backtrackable
    Direct Known Subclasses:
    FloatVar, IntVar, SetVar

    public abstract class Var
    extends java.lang.Object
    implements Backtrackable
    Defines a variable and related operations on it.
    Version:
    4.8
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String id
      Id string of the variable.
      static java.util.concurrent.atomic.AtomicInteger idNumber
      It is a counter to indicate number of created variables.
      int index
      It specifies the index at which it is stored in Store.
      (package private) float pruningActivity
      Pruning activity of this variable.
      Store store
      Each variable is created in a store.
      int weight
      It specifies the current weight of the variable.
    • Constructor Summary

      Constructors 
      Constructor Description
      Var()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      float activity()  
      static <T extends Var>
      void
      addPositionMapping​(java.util.Map<T,​java.lang.Integer> position, T[] list, boolean skipSingletons, java.lang.Class clazz)  
      static <T extends Var,​R>
      void
      addPositionMapping​(java.util.Map<T,​R> position, T[] list, java.util.function.Function<T,​R> function, boolean skipSingletons, java.lang.Class clazz)  
      float afcValue()  
      void applyDecay()  
      static <T extends Var,​R>
      java.util.Map<T,​R>
      createEmptyPositioning()  
      abstract Domain dom()
      This function returns current domain of the variable.
      abstract void domainHasChanged​(int event)
      It informs the variable that its variable has changed according to the specified event.
      abstract int getSize()
      It returns the size of the current domain.
      abstract double getSizeFloat()
      It returns the size of the current domain.
      Store getStore()
      This function returns store used by this variable.
      java.lang.String id()
      This function returns variable id.
      int index()
      This function returns the index of variable in store array.
      abstract boolean isEmpty()
      It checks if the domain is empty.
      abstract int level()
      This function returns stamp of the current domain of variable.
      static <T extends Var>
      java.util.Map<T,​java.lang.Integer>
      positionMapping​(T[] list, boolean skipSingletons, java.lang.Class clazz)  
      static <T extends Var,​R>
      java.util.Map<T,​R>
      positionMapping​(T[] list, java.util.function.Function<T,​R> function, boolean skipSingletons, java.lang.Class clazz)  
      abstract void putConstraint​(Constraint c)
      It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
      abstract void putModelConstraint​(Constraint c, int pruningEvent)
      It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
      abstract void putSearchConstraint​(Constraint c)
      It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.
      abstract void removeConstraint​(Constraint c)
      It detaches constraint from the current variable, so change in variable will not cause constraint reevaluation.
      abstract boolean singleton()
      It checks if the domain contains only one value.
      abstract int sizeConstraints()
      It returns current number of constraints which are associated with variable and are not yet satisfied.
      abstract int sizeConstraintsOriginal()
      It returns all constraints which are associated with variable, even the ones which are already satisfied.
      abstract int sizeSearchConstraints()
      It returns current number of constraints which are associated with variable and are not yet satisfied.
      abstract java.lang.String toStringFull()
      It returns the string representation of the variable using the full representation of the domain.
      void updateActivity()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • idNumber

        public static final java.util.concurrent.atomic.AtomicInteger idNumber
        It is a counter to indicate number of created variables.
      • id

        public java.lang.String id
        Id string of the variable.
      • index

        public int index
        It specifies the index at which it is stored in Store.
      • weight

        public int weight
        It specifies the current weight of the variable.
      • store

        public Store store
        Each variable is created in a store. This attribute represents the store in which this variable was created.
      • pruningActivity

        float pruningActivity
        Pruning activity of this variable.
    • Constructor Detail

      • Var

        public Var()
    • Method Detail

      • dom

        public abstract Domain dom()
        This function returns current domain of the variable.
        Returns:
        the domain of the variable.
      • getSize

        public abstract int getSize()
        It returns the size of the current domain.
        Returns:
        the size of the variables domain.
      • getSizeFloat

        public abstract double getSizeFloat()
        It returns the size of the current domain.
        Returns:
        the size of the variables domain.
      • isEmpty

        public abstract boolean isEmpty()
        It checks if the domain is empty.
        Returns:
        true if variable domain is empty.
      • putModelConstraint

        public abstract 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.
        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 abstract void putSearchConstraint​(Constraint c)
        It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.
        Parameters:
        c - the constraint which is added as a search constraint.
      • removeConstraint

        public abstract 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.
        Parameters:
        c - the constraint being detached from the variable.
      • singleton

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

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

        public abstract int sizeConstraintsOriginal()
        It returns all constraints which are associated with variable, even the ones which are already satisfied.
        Returns:
        number of constraints attached at the earliest level of the variable.
      • sizeSearchConstraints

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

        public abstract 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 not been changed for a longer time.
        Specified by:
        level in interface Backtrackable
        Returns:
        level for which the most recent changes have been applied to.
      • toStringFull

        public abstract java.lang.String toStringFull()
        It returns the string representation of the variable using the full representation of the domain.
        Returns:
        string representation.
      • domainHasChanged

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

        public abstract void putConstraint​(Constraint c)
        It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.
        Parameters:
        c - the constraint being attached to this variable.
      • getStore

        public Store getStore()
        This function returns store used by this variable.
        Returns:
        the store of the variable.
      • id

        public java.lang.String id()
        This function returns variable id.
        Returns:
        the id of the variable.
      • index

        public int index()
        This function returns the index of variable in store array.
        Specified by:
        index in interface Backtrackable
        Returns:
        the index of the variable.
      • afcValue

        public float afcValue()
      • updateActivity

        public void updateActivity()
      • activity

        public float activity()
      • applyDecay

        public void applyDecay()
      • createEmptyPositioning

        public static <T extends Var,​R> java.util.Map<T,​R> createEmptyPositioning()
      • positionMapping

        public static <T extends Var> java.util.Map<T,​java.lang.Integer> positionMapping​(T[] list,
                                                                                               boolean skipSingletons,
                                                                                               java.lang.Class clazz)
      • addPositionMapping

        public static <T extends Var> void addPositionMapping​(java.util.Map<T,​java.lang.Integer> position,
                                                              T[] list,
                                                              boolean skipSingletons,
                                                              java.lang.Class clazz)
      • positionMapping

        public static <T extends Var,​R> java.util.Map<T,​R> positionMapping​(T[] list,
                                                                                       java.util.function.Function<T,​R> function,
                                                                                       boolean skipSingletons,
                                                                                       java.lang.Class clazz)
      • addPositionMapping

        public static <T extends Var,​R> void addPositionMapping​(java.util.Map<T,​R> position,
                                                                      T[] list,
                                                                      java.util.function.Function<T,​R> function,
                                                                      boolean skipSingletons,
                                                                      java.lang.Class clazz)