JaCoP.core
Class BooleanVar

java.lang.Object
  extended by JaCoP.core.Var
      extended by JaCoP.core.IntVar
          extended by JaCoP.core.BooleanVar
All Implemented Interfaces:
Backtrackable

public class BooleanVar
extends IntVar

Defines a variable and related operations on it.

Version:
3.1
Author:
Radoslaw Szymanek and Krzysztof Kuchcinski

Field Summary
static java.lang.String[] xmlAttributes
          It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format.
 
Fields inherited from class JaCoP.core.IntVar
domain
 
Fields inherited from class JaCoP.core.Var
id, idNumber, index, store, weight
 
Constructor Summary
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, BoundDomain dom)
          It creates a Boolean variable.
BooleanVar(Store store, java.lang.String name)
          Boolean variable constructor.
BooleanVar(Store store, java.lang.String name, BoundDomain dom)
          It creates a Boolean variable.
BooleanVar(Store store, java.lang.String name, int min, int max)
          Boolean variable constructor.
 
Method Summary
 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 JaCoP.core.IntVar
addDom, addDom, eq, max, min, setDomain, setDomain, singleton, value
 
Methods inherited from class JaCoP.core.Var
id, index
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xmlAttributes

public static java.lang.String[] xmlAttributes
It specifies the arguments required to be saved by an XML format as well as the constructor being called to recreate an object from an XML format.

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,
                  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 class IntVar
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 class IntVar
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 class IntVar
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 class IntVar
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 class IntVar
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 class IntVar
Returns:
the number of constraints.

toString

public java.lang.String toString()
Overrides:
toString in class IntVar
Returns:
it returns the string description of the boolean variable.

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 class IntVar
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.

Overrides:
dom in class IntVar
Returns:
the 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.

Overrides:
getSize in class IntVar
Returns:
the size of the variables domain.

isEmpty

public boolean isEmpty()
It checks if the domain is empty.

Overrides:
isEmpty in class IntVar
Returns:
true if variable 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 class IntVar
Returns:
difference between the current level and the one before it.

singleton

public boolean singleton()
It checks if the domain contains only one value.

Overrides:
singleton in class IntVar
Returns:
true if the variable domain is a singleton, false otherwise.

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
Overrides:
level in class IntVar
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 interface Backtrackable
Overrides:
remove in class IntVar

domainHasChanged

public void domainHasChanged(int event)
It informs the variable that its variable has changed according to the specified event.

Overrides:
domainHasChanged in class IntVar
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 class IntVar
Parameters:
c - the constraint being attached to this variable.