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
public class BooleanVar extends IntVar
Defines a variable and related operations on it.- Version:
- 4.7
-
-
Constructor Summary
Constructors Constructor Description BooleanVar()
No 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, java.lang.String name)
Boolean variable constructor.BooleanVar(Store store, java.lang.String name, int min, int max)
Boolean variable constructor.BooleanVar(Store store, java.lang.String name, BoundDomain dom)
It creates a Boolean variable.BooleanVar(Store store, BoundDomain dom)
It creates a Boolean variable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDom(Domain dom)
It is possible to add the domain of variable.BoundDomain
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(BooleanVar var)
It checks if the domains of variables are equal.int
getSize()
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.void
putConstraint(Constraint c)
It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.void
putModelConstraint(Constraint constraint, int pruningEvent)
It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.void
putSearchConstraint(Constraint constraint)
It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.BoundDomain
recentDomainPruning()
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
removeConstraint(Constraint constraint)
It unregisters constraint with current variable, so change in variable will not cause constraint reevaluation.boolean
singleton()
It checks if the domain contains only one value.int
sizeConstraints()
It returns current number of constraints which are associated with variable and are not yet satisfied.int
sizeConstraintsOriginal()
It returns all constraints which are associated with variable, even the ones which are already satisfied.int
sizeSearchConstraints()
It returns current number of constraints which are associated with a boolean variable and are not yet satisfied.java.lang.String
toString()
java.lang.String
toStringFull()
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, value
-
Methods inherited from class org.jacop.core.Var
activity, addPositionMapping, addPositionMapping, afcValue, applyDecay, createEmptyPositioning, getStore, id, index, positionMapping, positionMapping, updateActivity
-
-
-
-
Constructor Detail
-
BooleanVar
public BooleanVar()
No parameter, explicit, empty constructor for subclasses.
-
BooleanVar
public BooleanVar(Store store)
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
public BooleanVar(Store store, java.lang.String name)
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
public BooleanVar(Store store, java.lang.String name, int min, int max)
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
public BooleanVar(Store store, int min, int max)
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
public BooleanVar(Store store, BoundDomain dom)
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
public BooleanVar(Store store, java.lang.String name, BoundDomain dom)
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 Detail
-
putModelConstraint
public void putModelConstraint(Constraint constraint, int pruningEvent)
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:
putModelConstraint
in classIntVar
- Parameters:
constraint
- - constraint being attached to a variable.pruningEvent
- - Only NONE and GROUND events are considered. By default GROUND event is used.
-
putSearchConstraint
public void putSearchConstraint(Constraint constraint)
It registers constraint with current variable, so anytime this variable is changed the constraint is reevaluated.- Overrides:
putSearchConstraint
in classIntVar
- Parameters:
constraint
- It specifies the constraint which is being added.
-
removeConstraint
public void removeConstraint(Constraint constraint)
It unregisters constraint with current variable, so change in variable will not cause constraint reevaluation.- Overrides:
removeConstraint
in 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:
sizeConstraints
in 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:
sizeConstraintsOriginal
in 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:
sizeSearchConstraints
in classIntVar
- Returns:
- the number of constraints.
-
toString
public java.lang.String toString()
-
toStringFull
public java.lang.String toStringFull()
Description copied from class:IntVar
It returns the string representation of the variable using the full representation of the domain.- Overrides:
toStringFull
in classIntVar
- Returns:
- It returns elaborate string description of the boolean variable and all the components of its domain.
-
addDom
public void addDom(Domain 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 BoundDomain dom()
This function returns current domain of the variable.
-
eq
public boolean eq(BooleanVar 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.
-
isEmpty
public boolean isEmpty()
It checks if the domain is empty.
-
recentDomainPruning
public BoundDomain 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:
recentDomainPruning
in 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:
level
in interfaceBacktrackable
- Overrides:
level
in classIntVar
- Returns:
- level for which the most recent changes have been applied to.
-
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.- Specified by:
remove
in interfaceBacktrackable
- Overrides:
remove
in 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:
domainHasChanged
in classIntVar
- 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.- Overrides:
putConstraint
in classIntVar
- Parameters:
c
- the constraint being attached to this variable.
-
-