Package org.jacop.core
Class BooleanVar
java.lang.Object
org.jacop.core.Var
org.jacop.core.IntVar
org.jacop.core.BooleanVar
- All Implemented Interfaces:
Backtrackable
Defines a variable and related operations on it.
- Version:
- 4.10
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionNo parameter, explicit, empty constructor for subclasses.BooleanVar(Store store) This constructor creates a variable with empty domain (standard FD domain), automatically generated name, and empty attached constraint list.BooleanVar(Store store, int min, int max) Boolean variable constructor.BooleanVar(Store store, String name) Boolean variable constructor.BooleanVar(Store store, String name, int min, int max) Boolean variable constructor.BooleanVar(Store store, String name, BoundDomain dom) It creates a Boolean variable.BooleanVar(Store store, BoundDomain dom) It creates a Boolean variable. -
Method Summary
Modifier and TypeMethodDescriptionvoidIt is possible to add the domain of variable.dom()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(BooleanVar var) It checks if the domains of variables are equal.intgetSize()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.voidIt registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.voidputModelConstraint(Constraint constraint, int pruningEvent) It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.voidputSearchConstraint(Constraint constraint) It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.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 constraint) It unregisters constraint with current variable, so change in variable will not cause constraint reevaluation.booleanIt checks if the domain contains only one value.intIt returns current number of constraints which are associated with variable and are not yet satisfied.intIt returns all constraints which are associated with variable, even the ones which are already satisfied.intIt returns current number of constraints which are associated with a boolean variable and are not yet satisfied.toString()It returns the string representation of the variable using the full representation of the domain.Methods inherited from class org.jacop.core.IntVar
addDom, addDom, eq, getSizeFloat, max, min, setDomain, setDomain, singleton, valueMethods inherited from class org.jacop.core.Var
activity, addPositionMapping, addPositionMapping, afcValue, applyDecay, createEmptyPositioning, getStore, id, index, positionMapping, positionMapping, updateActivity
-
Constructor Details
-
BooleanVar
public BooleanVar()No parameter, explicit, empty constructor for subclasses. -
BooleanVar
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
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
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
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
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
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 Details
-
putModelConstraint
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:
putModelConstraintin classIntVar- Parameters:
constraint- - constraint being attached to a variable.pruningEvent- - Only NONE and GROUND events are considered. By default GROUND event is used.
-
putSearchConstraint
It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.- Overrides:
putSearchConstraintin classIntVar- Parameters:
constraint- It specifies the constraint which is being added.
-
removeConstraint
It unregisters constraint with current variable, so change in variable will not cause constraint reevaluation.- Overrides:
removeConstraintin classIntVar- 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:
sizeConstraintsin classIntVar- 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:
sizeConstraintsOriginalin classIntVar- 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:
sizeSearchConstraintsin classIntVar- Returns:
- the number of constraints.
-
toString
-
toStringFull
Description copied from class:IntVarIt returns the string representation of the variable using the full representation of the domain.- Overrides:
toStringFullin classIntVar- Returns:
- It returns elaborate string description of the boolean variable and all the components of its domain.
-
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. -
isEmpty
public boolean isEmpty()It checks if the domain is empty. -
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:
recentDomainPruningin classIntVar- Returns:
- difference between the current level and the one before it.
-
singleton
public boolean singleton()It checks if the domain contains only one value. -
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- Overrides:
levelin classIntVar- Returns:
- level for which the most recent changes have been applied to.
-
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.- Specified by:
removein interfaceBacktrackable- Overrides:
removein classIntVar- 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:
domainHasChangedin classIntVar- Parameters:
event- the type of the change (GROUND, BOUND, ANY).
-
putConstraint
Description copied from class:VarIt registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.- Overrides:
putConstraintin classIntVar- Parameters:
c- the constraint being attached to this variable.
-