Package org.jacop.floats.core
Class FloatVar
java.lang.Object
org.jacop.core.Var
org.jacop.floats.core.FloatVar
- All Implemented Interfaces:
Backtrackable
Defines a Float Domain Variable and related operations on it.
- Version:
- 4.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionIt stores pointer to a current domain, which has stamp equal to store stamp. -
Constructor Summary
ConstructorsConstructorDescriptionFloatVar()
No parameter, explicit, empty constructor for subclasses.This constructor creates a variable with empty domain (standard FloatIntervalDomain domain), automatically generated name, and empty attached constraint list.This constructor creates a variable with a domain between min..max, automatically generated name, and empty attached constraint list.This constructor creates a variable with an empty domain (standard IntervalDomain domain), the specified name, and an empty attached constraint list.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 TypeMethodDescriptionvoid
addDom
(double min, double max) It is possible to add the domain of variable.void
addDom
(FloatDomain dom) It is possible to add the domain of variable.private void
commonInitialization
(Store store, String name, FloatDomain dom) 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
It checks if the domains of variables are equal.int
getSize()
It returns the size of the current domain.double
It returns the size of the current domain.boolean
isEmpty()
It checks if the domain is empty.int
level()
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
setDomain
(FloatDomain dom) 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.toString()
It returns the string representation of the variable using the full representation of the domain.double
value()
This function returns current value in the domain of the variable.Methods inherited from class org.jacop.core.Var
activity, addPositionMapping, addPositionMapping, afcValue, applyDecay, createEmptyPositioning, getStore, id, index, positionMapping, positionMapping, updateActivity
-
Field Details
-
domain
It stores pointer to a current domain, which has stamp equal to store stamp.
-
-
Constructor Details
-
FloatVar
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
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
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
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
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
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
-
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
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
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
This function returns current domain of the variable. -
eq
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. -
getSizeFloat
public double getSizeFloat()Description copied from class:Var
It returns the size of the current domain.- Specified by:
getSizeFloat
in classVar
- Returns:
- the size of the variables domain.
-
isEmpty
public boolean isEmpty()It checks if the domain is empty. -
putModelConstraint
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 classVar
- 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
It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.- Specified by:
putSearchConstraint
in classVar
- Parameters:
c
- the constraint which is added as a search constraint.
-
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
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 classVar
- Parameters:
c
- the constraint being detached from the variable.
-
singleton
public boolean singleton()It checks if the domain contains only one value. -
sizeConstraints
public int sizeConstraints()It returns current number of constraints which are associated with variable and are not yet satisfied.- Specified by:
sizeConstraints
in classVar
- 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 classVar
- 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 classVar
- 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 interfaceBacktrackable
- Specified by:
level
in classVar
- Returns:
- level for which the most recent changes have been applied to.
-
toString
-
toStringFull
It returns the string representation of the variable using the full representation of the domain.- Specified by:
toStringFull
in classVar
- 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 classVar
- Parameters:
event
- the type of the change (GROUND, BOUND, ANY).
-
putConstraint
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 classVar
- Parameters:
c
- the constraint being attached to this variable.
-