|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectCSPGen.BinaryConstraint
This class is used to store the data structure of a single binary constraint.
Only on instance of this class need be created for each edge in the constraint
graph. When an instance of this class is created it will notified both
Variables that it constraints of itself. Thus all the variables of a problem
should be created before any BinaryCosntraints are created.
There can be only ONE instance of this class per edge in the graph. Additional
instances will be rejected.
An instance of this class is immutable once created.
Variable,
Problem| Field Summary | |
protected boolean[][] |
truthTable
Stores the truth table of this constraint. |
Variable |
V1
The first variable involved in this constraint. |
Variable |
V2
The second variable involved in this constraint. |
| Constructor Summary | |
protected |
BinaryConstraint()
Deprecated. DO NOT USE. |
protected |
BinaryConstraint(Variable v1,
Variable v2,
boolean[][] truthTable)
Constructs a new binary constraint. |
| Method Summary | |
boolean |
equals(java.lang.Object o)
Determines if this constraint is equal to the given instance. |
boolean |
isSatisfied()
Checks if this constraint is satisfied given the current state of the problem. |
boolean |
isViolated()
Checks if this constraint is violated given the current state of the problem. |
java.lang.String |
toString()
Returns a string representation of this BinaryConstraint. |
boolean |
truthTable(int x1,
int x2)
The truth table of this constraint. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public final Variable V1
Variablepublic final Variable V2
Variableprotected boolean[][] truthTable
truthTable(int x1, int x2)| Constructor Detail |
protected BinaryConstraint()
protected BinaryConstraint(Variable v1,
Variable v2,
boolean[][] truthTable)
v1 - the first variable of the constraintv2 - the second variable of the constrainttruthTable - a complete truth table for this constraint of
size d1 by d2. The array is NOT cloned.
java.lang.IllegalArgumentException - if the truth table is too smalltruthTable| Method Detail |
public boolean truthTable(int x1,
int x2)
x1 - the value of the first variablex2 - the value of the second variableisSatisfied()public boolean isSatisfied()
true iff both variables are assigned and consistant under
this constraintfalse under any other conditionstruthTable(int x1, int x2)public boolean isViolated()
true if and only if both variables are instantiated and are
inconsistant with each other.false in all other cases.truthTable(int x1, int x2)public boolean equals(java.lang.Object o)
Requirements are that the two variables of the constraint must be the
same (determined using ==) and that the two constraints have the exact
same truth table.
Under normal circumstances (bc1==bc2)
should yield the same results as (bc.equals(bc)).
o - the object to which the comparison is madepublic java.lang.String toString()
The truth table is using nested for loops with the first
dimension on the outside and the second on the inside.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||