jopt.csp.spi.arcalgorithm.variable
Class BooleanExpr

java.lang.Object
  extended byjopt.csp.spi.arcalgorithm.variable.VariableChangeBase
      extended byjopt.csp.spi.arcalgorithm.variable.NumExprBase
          extended byjopt.csp.spi.arcalgorithm.variable.IntExpr
              extended byjopt.csp.spi.arcalgorithm.variable.BooleanExpr
All Implemented Interfaces:
BoolExpr, jopt.csp.variable.CspBooleanExpr, jopt.csp.variable.CspDoubleCast, jopt.csp.variable.CspFloatCast, jopt.csp.variable.CspIntExpr, jopt.csp.variable.CspLongCast, jopt.csp.variable.CspNumExpr, DoubleCast, FloatCast, LongCast, NumExpr, TrigExpr, VariableChangeSource
Direct Known Subclasses:
BooleanVariable, GenericBooleanExpr

public class BooleanExpr
extends IntExpr
implements jopt.csp.variable.CspBooleanExpr, BoolExpr

A class used to create boolean expressions including AND, OR, NOT operations, etc. An expression usually does not have a concrete domain that can be modified, so it must be wrapped by a variable if it's value is to be directly altered.

Author:
jboerkoel, Nick Coleman

Constructor Summary
BooleanExpr(java.lang.String name, BooleanExpr aexpr, int operation, boolean bConst)
          Constructor for building expressions based on an operation on one other variable and a constant
BooleanExpr(java.lang.String name, BooleanExpr aexpr, int operation, BooleanExpr bexpr, boolean notB)
          Constructor for building expressions based on an operation on two other variables
BooleanExpr(java.lang.String name, BooleanExpr aexpr, int operation, GenericBooleanConstant bConst)
          Constructor for building expressions based on an operation on one other variable and a constant
BooleanExpr(java.lang.String name, jopt.csp.variable.CspConstraint constraint)
          Constructor for expression that wraps a constraint and is based upon a domain computed from the constraint
BooleanExpr(java.lang.String name, int operation, BooleanExpr bexpr)
          Constructor for building an expression based on an operation on one other variable
 
Method Summary
 void addVariableChangeListener(VariableChangeListener listener)
          Adds a listener interested in variable change events
 void addVariableChangeListener(VariableChangeListener listener, boolean firstTime)
          Adds a listener interested in variable change events
 jopt.csp.variable.CspBooleanExpr and(boolean val)
          Creates a boolean expression resulting from anding a constant with this expression
 jopt.csp.variable.CspBooleanExpr and(jopt.csp.variable.CspBooleanExpr expr)
          Creates a boolean expression resulting from anding a boolean expression with this expression
 jopt.csp.variable.CspBooleanExpr and(jopt.csp.variable.CspConstraint cons)
          Creates a boolean expression resulting from anding a constraint with this expression
 jopt.csp.variable.CspBooleanExpr and(jopt.csp.variable.CspGenericBooleanConstant val)
          Creates a boolean expression resulting from anding a constant with this expression
 jopt.csp.variable.CspConstraint createBuildingBlockConstraint()
           
 jopt.csp.variable.CspConstraint createExternalConstraint()
           
 jopt.csp.variable.CspBooleanExpr eq(boolean val)
          Creates a boolean expression resulting from setting a boolean expression equal to this expression
 jopt.csp.variable.CspBooleanExpr eq(jopt.csp.variable.CspBooleanExpr expr)
          Creates a boolean expression resulting from setting a boolean expression equal to this expression
 jopt.csp.variable.CspBooleanExpr eq(jopt.csp.variable.CspConstraint cons)
          Creates a boolean expression resulting from setting a boolean expression equal to this expression
 BooleanDomain getBooleanDomain()
          Returns the domain corresponding to this expression
 Arc[] getBooleanSourceArcs()
          Returns array of arcs that will affect the boolean true / false value of this constraint upon a change
 Node getNode()
          Returns node associated with this expression
 java.util.Collection getNodeCollection()
          Returns collection of all nodes used to build this expression
 int getSize()
          Returns the size of this variable's domain
 jopt.csp.variable.CspBooleanExpr implies(boolean val)
          Creates a boolean expression resulting from this expression implying another expression
 jopt.csp.variable.CspBooleanExpr implies(jopt.csp.variable.CspBooleanExpr expr)
          Creates a boolean expression resulting from this expression implying another expression
 jopt.csp.variable.CspBooleanExpr implies(jopt.csp.variable.CspConstraint cons)
          Creates a boolean expression resulting from this expression implying a constraint
 jopt.csp.variable.CspBooleanExpr implies(jopt.csp.variable.CspGenericBooleanConstant val)
          Creates a boolean expression resulting from anding a constant with this expression
 boolean isFalse()
          Returns true if variable cannot be satisfied
 boolean isTrue()
          Returns true if variable cannot be dissatisfied
 jopt.csp.variable.CspBooleanExpr not()
          Returns a Boolean Variable equal to the Not of this one
 BoolExpr notExpr()
          Returns a BoolExpr equal to the Not of this one
 jopt.csp.variable.CspBooleanExpr or(boolean val)
          Creates a boolean expression resulting from oring a constant with this expression
 jopt.csp.variable.CspBooleanExpr or(jopt.csp.variable.CspBooleanExpr expr)
          Creates a boolean expression resulting from oring a boolean expression with this expression
 jopt.csp.variable.CspBooleanExpr or(jopt.csp.variable.CspConstraint cons)
          Creates a boolean expression resulting from oring a constraint with this expression
 jopt.csp.variable.CspBooleanExpr or(jopt.csp.variable.CspGenericBooleanConstant val)
          Creates a boolean expression resulting from oring a constant with this expression
 jopt.csp.variable.CspConstraint toConstraint()
          Returns a constraint that represents this boolean expression that can be used in the solver
 java.lang.String toString()
           
 void updateGraph(NodeArcGraph graph)
          Adds arcs representing this expression to the node arc graph
 jopt.csp.variable.CspBooleanExpr xor(boolean val)
          Creates a boolean expression resulting from xoring a constant with this expression
 jopt.csp.variable.CspBooleanExpr xor(jopt.csp.variable.CspBooleanExpr expr)
          Creates a boolean expression resulting from xoring a boolean expression with this expression
 jopt.csp.variable.CspBooleanExpr xor(jopt.csp.variable.CspConstraint cons)
          Creates a boolean expression resulting from xoring a constraint with this expression
 jopt.csp.variable.CspBooleanExpr xor(jopt.csp.variable.CspGenericBooleanConstant val)
          Creates a boolean expression resulting from xoring a constant with this expression
 
Methods inherited from class jopt.csp.spi.arcalgorithm.variable.IntExpr
add, add, add, add, add, add, add, add, between, between, divide, divide, divide, divide, divide, divide, divide, divide, eq, eq, geq, geq, getDoubleDomain, getFloatDomain, getIntDomain, getLongDomain, getMax, getMin, getNextHigher, getNextLower, getNumberType, getNumMax, getNumMin, getPrecision, gt, gt, isInDomain, leq, leq, lt, lt, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiply, neq, neq, notBetween, notBetween, setPrecision, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract
 
Methods inherited from class jopt.csp.spi.arcalgorithm.variable.NumExprBase
between, between, between, between, eq, equals, geq, getDomain, getName, gt, hashCode, isBound, leq, lt, neq, notBetween, notBetween, notBetween, notBetween, removeVariableChangeListener, setName
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jopt.csp.variable.CspIntExpr
add, add, add, add, add, add, add, add, between, between, divide, divide, divide, divide, divide, divide, divide, divide, eq, eq, geq, geq, getMax, getMin, gt, gt, leq, leq, lt, lt, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiply, neq, neq, notBetween, notBetween, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract
 
Methods inherited from interface jopt.csp.variable.CspNumExpr
between, between, between, between, eq, geq, getName, gt, isBound, leq, lt, neq, notBetween, notBetween, notBetween, notBetween, setName
 
Methods inherited from interface jopt.csp.spi.arcalgorithm.constraint.bool.BoolExpr
getName, isBound
 
Methods inherited from interface jopt.csp.spi.arcalgorithm.constraint.num.NumExpr
getName, isBound
 

Constructor Detail

BooleanExpr

public BooleanExpr(java.lang.String name,
                   jopt.csp.variable.CspConstraint constraint)
Constructor for expression that wraps a constraint and is based upon a domain computed from the constraint

Parameters:
name - Unique name assigned to expression
constraint - Constraint this boolean expression wraps

BooleanExpr

public BooleanExpr(java.lang.String name,
                   BooleanExpr aexpr,
                   int operation,
                   BooleanExpr bexpr,
                   boolean notB)
Constructor for building expressions based on an operation on two other variables

Parameters:
name - Unique name assigned to expression
aexpr - A variable of boolean expression
operation - Operation this expression represents such as AND, OR, etc.
bexpr - B variable of boolean expression
notB - True if operation is on !B instead of B

BooleanExpr

public BooleanExpr(java.lang.String name,
                   BooleanExpr aexpr,
                   int operation,
                   boolean bConst)
Constructor for building expressions based on an operation on one other variable and a constant

Parameters:
name - Unique name assigned to expression
aexpr - A variable of boolean expression
operation - Operation this expression represents such as AND, OR, etc.
bConst - Constant b value of boolean expression

BooleanExpr

public BooleanExpr(java.lang.String name,
                   BooleanExpr aexpr,
                   int operation,
                   GenericBooleanConstant bConst)
Constructor for building expressions based on an operation on one other variable and a constant

Parameters:
name - Unique name assigned to expression
aexpr - A variable of boolean expression
operation - Operation this expression represents such as AND, OR, etc.
bConst - Constant b value of boolean expression

BooleanExpr

public BooleanExpr(java.lang.String name,
                   int operation,
                   BooleanExpr bexpr)
Constructor for building an expression based on an operation on one other variable

Parameters:
name - Unique name assigned to expression
operation - Operation this expression represents such as EQ, IMPLIES or NOT
bexpr - A variable of boolean expression
Method Detail

getBooleanSourceArcs

public Arc[] getBooleanSourceArcs()
Returns array of arcs that will affect the boolean true / false value of this constraint upon a change

Specified by:
getBooleanSourceArcs in interface BoolExpr
Overrides:
getBooleanSourceArcs in class NumExprBase

getNode

public Node getNode()
Returns node associated with this expression

Specified by:
getNode in interface BoolExpr
Overrides:
getNode in class IntExpr

and

public jopt.csp.variable.CspBooleanExpr and(jopt.csp.variable.CspBooleanExpr expr)
Creates a boolean expression resulting from anding a boolean expression with this expression

Specified by:
and in interface jopt.csp.variable.CspBooleanExpr

and

public jopt.csp.variable.CspBooleanExpr and(jopt.csp.variable.CspConstraint cons)
Creates a boolean expression resulting from anding a constraint with this expression

Specified by:
and in interface jopt.csp.variable.CspBooleanExpr

and

public jopt.csp.variable.CspBooleanExpr and(boolean val)
Creates a boolean expression resulting from anding a constant with this expression

Specified by:
and in interface jopt.csp.variable.CspBooleanExpr

and

public jopt.csp.variable.CspBooleanExpr and(jopt.csp.variable.CspGenericBooleanConstant val)
Creates a boolean expression resulting from anding a constant with this expression

Specified by:
and in interface jopt.csp.variable.CspBooleanExpr

xor

public jopt.csp.variable.CspBooleanExpr xor(jopt.csp.variable.CspBooleanExpr expr)
Creates a boolean expression resulting from xoring a boolean expression with this expression

Specified by:
xor in interface jopt.csp.variable.CspBooleanExpr

xor

public jopt.csp.variable.CspBooleanExpr xor(jopt.csp.variable.CspConstraint cons)
Creates a boolean expression resulting from xoring a constraint with this expression

Specified by:
xor in interface jopt.csp.variable.CspBooleanExpr

xor

public jopt.csp.variable.CspBooleanExpr xor(boolean val)
Creates a boolean expression resulting from xoring a constant with this expression

Specified by:
xor in interface jopt.csp.variable.CspBooleanExpr

xor

public jopt.csp.variable.CspBooleanExpr xor(jopt.csp.variable.CspGenericBooleanConstant val)
Creates a boolean expression resulting from xoring a constant with this expression

Specified by:
xor in interface jopt.csp.variable.CspBooleanExpr

implies

public jopt.csp.variable.CspBooleanExpr implies(jopt.csp.variable.CspBooleanExpr expr)
Creates a boolean expression resulting from this expression implying another expression

Specified by:
implies in interface jopt.csp.variable.CspBooleanExpr

implies

public jopt.csp.variable.CspBooleanExpr implies(boolean val)
Creates a boolean expression resulting from this expression implying another expression

Specified by:
implies in interface jopt.csp.variable.CspBooleanExpr

implies

public jopt.csp.variable.CspBooleanExpr implies(jopt.csp.variable.CspGenericBooleanConstant val)
Creates a boolean expression resulting from anding a constant with this expression

Specified by:
implies in interface jopt.csp.variable.CspBooleanExpr

implies

public jopt.csp.variable.CspBooleanExpr implies(jopt.csp.variable.CspConstraint cons)
Creates a boolean expression resulting from this expression implying a constraint

Specified by:
implies in interface jopt.csp.variable.CspBooleanExpr

or

public jopt.csp.variable.CspBooleanExpr or(jopt.csp.variable.CspBooleanExpr expr)
Creates a boolean expression resulting from oring a boolean expression with this expression

Specified by:
or in interface jopt.csp.variable.CspBooleanExpr

or

public jopt.csp.variable.CspBooleanExpr or(jopt.csp.variable.CspConstraint cons)
Creates a boolean expression resulting from oring a constraint with this expression

Specified by:
or in interface jopt.csp.variable.CspBooleanExpr

or

public jopt.csp.variable.CspBooleanExpr or(boolean val)
Creates a boolean expression resulting from oring a constant with this expression

Specified by:
or in interface jopt.csp.variable.CspBooleanExpr

or

public jopt.csp.variable.CspBooleanExpr or(jopt.csp.variable.CspGenericBooleanConstant val)
Creates a boolean expression resulting from oring a constant with this expression

Specified by:
or in interface jopt.csp.variable.CspBooleanExpr

eq

public jopt.csp.variable.CspBooleanExpr eq(jopt.csp.variable.CspBooleanExpr expr)
Creates a boolean expression resulting from setting a boolean expression equal to this expression

Specified by:
eq in interface jopt.csp.variable.CspBooleanExpr

eq

public jopt.csp.variable.CspBooleanExpr eq(jopt.csp.variable.CspConstraint cons)
Creates a boolean expression resulting from setting a boolean expression equal to this expression

Specified by:
eq in interface jopt.csp.variable.CspBooleanExpr

eq

public jopt.csp.variable.CspBooleanExpr eq(boolean val)
Creates a boolean expression resulting from setting a boolean expression equal to this expression

Specified by:
eq in interface jopt.csp.variable.CspBooleanExpr

toConstraint

public jopt.csp.variable.CspConstraint toConstraint()
Description copied from interface: BoolExpr
Returns a constraint that represents this boolean expression that can be used in the solver

Specified by:
toConstraint in interface jopt.csp.variable.CspBooleanExpr

createExternalConstraint

public jopt.csp.variable.CspConstraint createExternalConstraint()

createBuildingBlockConstraint

public jopt.csp.variable.CspConstraint createBuildingBlockConstraint()

not

public jopt.csp.variable.CspBooleanExpr not()
Returns a Boolean Variable equal to the Not of this one

Specified by:
not in interface jopt.csp.variable.CspBooleanExpr

notExpr

public BoolExpr notExpr()
Returns a BoolExpr equal to the Not of this one

Specified by:
notExpr in interface BoolExpr

isFalse

public boolean isFalse()
Returns true if variable cannot be satisfied

Specified by:
isFalse in interface jopt.csp.variable.CspBooleanExpr

isTrue

public boolean isTrue()
Returns true if variable cannot be dissatisfied

Specified by:
isTrue in interface jopt.csp.variable.CspBooleanExpr

getSize

public int getSize()
Returns the size of this variable's domain


getBooleanDomain

public BooleanDomain getBooleanDomain()
Returns the domain corresponding to this expression


updateGraph

public void updateGraph(NodeArcGraph graph)
Adds arcs representing this expression to the node arc graph

Specified by:
updateGraph in interface BoolExpr
Overrides:
updateGraph in class NumExprBase

toString

public java.lang.String toString()
Overrides:
toString in class NumExprBase

getNodeCollection

public java.util.Collection getNodeCollection()
Description copied from interface: BoolExpr
Returns collection of all nodes used to build this expression

Specified by:
getNodeCollection in interface BoolExpr
Overrides:
getNodeCollection in class NumExprBase

addVariableChangeListener

public void addVariableChangeListener(VariableChangeListener listener)
Adds a listener interested in variable change events

Specified by:
addVariableChangeListener in interface VariableChangeSource
Overrides:
addVariableChangeListener in class NumExprBase

addVariableChangeListener

public void addVariableChangeListener(VariableChangeListener listener,
                                      boolean firstTime)
Adds a listener interested in variable change events