Package org.jacop.set.core
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.8
-
-
Constructor Summary
Constructors Constructor Description SetVar()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, java.lang.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, java.lang.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, java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDom(int min, int max)It is possible to add the domain of variable.voidaddDom(SetDomain dom)It is possible to add the domain of variable.SetDomaindom()This function returns current domain of the variable.voiddomainHasChanged(int event)It informs the variable that its variable has changed according to the specified event.booleaneq(SetVar var)It checks if the domains of variables are equal.intgetSize()It returns the size of the current domain.doublegetSizeFloat()It returns the size of the current domain.booleanisEmpty()It checks if the domain is empty.intlevel()This function returns stamp of the current domain of variable.voidputConstraint(Constraint c)It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.voidputModelConstraint(Constraint c, int pruningEvent)It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.voidputSearchConstraint(Constraint c)It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.SetDomainrecentDomainPruning()It returns the values which have been removed at current store level.voidremove(int removedLevel)It specifies the function being called by the manager upon backtracking.voidremoveConstraint(Constraint c)It detaches constraint from the current variable, so change in variable will not cause constraint reevaluation.voidsetDomain(int min, int max)It is possible to set the domain of variable.voidsetDomain(SetDomain dom)It is possible to set the domain of variable.booleansingleton()It checks if the domain contains only one value.intsizeConstraints()It returns current number of constraints which are associated with variable and are not yet satisfied.intsizeConstraintsOriginal()It returns all constraints which are associated with variable, even the ones which are already satisfied.intsizeSearchConstraints()It returns current number of constraints which are associated with variable and are not yet satisfied.java.lang.StringtoString()java.lang.StringtoStringFull()It returns the string representation of the variable using the full representation of the domain.-
Methods inherited from class org.jacop.core.Var
activity, addPositionMapping, addPositionMapping, afcValue, applyDecay, createEmptyPositioning, getStore, id, index, positionMapping, positionMapping, updateActivity
-
-
-
-
Field Detail
-
domain
public SetDomain domain
It specifies the current domain associated with this set variable.
-
-
Constructor Detail
-
SetVar
public SetVar(Store store, java.lang.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, java.lang.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, java.lang.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 Detail
-
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.
-
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.
-
getSizeFloat
public double getSizeFloat()
It returns the size of the current domain.- Specified by:
getSizeFloatin classVar- Returns:
- the size of the variables domain.
-
isEmpty
public boolean isEmpty()
It checks if the 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:
putModelConstraintin 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
public void putSearchConstraint(Constraint c)
It registers constraint with current variable, so always when this variable is changed the constraint is reevaluated.- Specified by:
putSearchConstraintin classVar- 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:
removeConstraintin 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:
sizeConstraintsin 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:
sizeConstraintsOriginalin 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:
sizeSearchConstraintsin 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:
levelin interfaceBacktrackable- Specified by:
levelin classVar- Returns:
- level for which the most recent changes have been applied to.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringFull
public java.lang.String toStringFull()
It returns the string representation of the variable using the full representation of the domain.- Specified by:
toStringFullin classVar- Returns:
- string representation.
-
remove
public void remove(int removedLevel)
Description copied from interface:BacktrackableIt 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:
domainHasChangedin classVar- Parameters:
event- the type of the change (GROUND, BOUND, ANY).
-
putConstraint
public void putConstraint(Constraint c)
Description copied from class:VarIt registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.- Specified by:
putConstraintin classVar- Parameters:
c- the constraint being attached to this variable.
-
-