Class FloatVar

java.lang.Object
org.jacop.core.Var
org.jacop.floats.core.FloatVar
All Implemented Interfaces:
Backtrackable

public class FloatVar extends Var
Defines a Float Domain Variable and related operations on it.
Version:
4.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    It stores pointer to a current domain, which has stamp equal to store stamp.

    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.
    FloatVar(Store store)
    This constructor creates a variable with empty domain (standard FloatIntervalDomain domain), automatically generated name, and empty attached constraint list.
    FloatVar(Store store, double min, double max)
    This constructor creates a variable with a domain between min..max, automatically generated name, and empty attached constraint list.
    FloatVar(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.
    FloatVar(Store store, String name, double min, double max)
    This constructor creates a variable in a given store, with the domain specified by min..max and with the given name.
    FloatVar(Store store, String name, FloatDomain dom)
    It creates a variable in a given store, with a given name and a given domain.
    FloatVar(Store store, FloatDomain 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(double min, double max)
    It is possible to add the domain of variable.
    void
    It is possible to add the domain of variable.
    private void
     
    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(FloatVar 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.
    double
    max()
    This function returns current maximal value in the domain of the variable.
    double
    min()
    This function returns current minimal value in the domain of the 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(double min, double 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.
    boolean
    singleton(double val)
    It checks if the domain contains only one value equal to c.
    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.
    double
    This function returns current value in the domain of the variable.

    Methods inherited from class java.lang.Object

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

    • domain

      public FloatDomain domain
      It stores pointer to a current domain, which has stamp equal to store stamp.
  • Constructor Details

    • FloatVar

      public FloatVar(Store store, String name, FloatDomain 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.
    • FloatVar

      public FloatVar(Store store, FloatDomain 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.
    • FloatVar

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

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

      public FloatVar(Store store, double min, double max)
      This constructor creates a variable with a domain between 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.
    • FloatVar

      public FloatVar(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.
    • FloatVar

      public FloatVar(Store store, String name, double min, double 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

    • commonInitialization

      private void commonInitialization(Store store, String name, FloatDomain dom)
    • addDom

      public void addDom(double min, double 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(double min, double 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.
    • value

      public double value()
      This function returns current value in the domain of the variable. If current domain of variable is not singleton then warning is printed and minimal value is returned.
      Returns:
      the value to which the variable has been grounded to.
    • singleton

      public boolean singleton(double val)
      It checks if the domain contains only one value equal to c.
      Parameters:
      val - value to which we compare the singleton of the variable.
      Returns:
      true if a variable domain is singleton and it is equal to the specified value.
    • max

      public double max()
      This function returns current maximal value in the domain of the variable.
      Returns:
      the maximum value belonging to the domain.
    • min

      public double min()
      This function returns current minimal value in the domain of the variable.
      Returns:
      the minimum value beloning to the domain.
    • setDomain

      public void setDomain(FloatDomain 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(FloatDomain 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 FloatDomain 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(FloatVar 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()
      Description copied from class: Var
      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 FloatDomain 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.