agg.util.csp
Class BinaryConstraint

java.lang.Object
  extended by agg.util.csp.BinaryConstraint
Direct Known Subclasses:
Constraint_Attribute, Constraint_InheritAttribute, Constraint_InheritSource, Constraint_InheritTarget, Constraint_InheritType, Constraint_Source, Constraint_Target, Constraint_Type

public abstract class BinaryConstraint
extends java.lang.Object

An abstract class for binary constraints.


Field Summary
protected  Variable itsVar1
           
protected  Variable itsVar2
           
protected  int itsWeight
           
 
Constructor Summary
BinaryConstraint(Variable v, int weight)
          Construct myself to be a "unary" constraint on v.
BinaryConstraint(Variable v1, Variable v2, int weight)
          Construct myself to be a binary constraint between variables v1 and v2, with the specified weight.
 
Method Summary
 void activate()
          Activate this constraint.
abstract  void clear()
           
 void deactivate()
          Deactivate this constraint.
abstract  boolean execute()
          Check if the constraint is satisfied.
 Variable getCause(Variable rvar)
          When execute() failed, this returns the variable that is supposed to have caused the failure.
 Variable getVar1()
          Return my first variable.
 Variable getVar2()
          Return my second variable.
 int getWeight()
          Return my weight.
 boolean isApplicable()
          Return true iff all variables involved are instantiated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itsVar1

protected Variable itsVar1

itsVar2

protected Variable itsVar2

itsWeight

protected int itsWeight
Constructor Detail

BinaryConstraint

public BinaryConstraint(Variable v1,
                        Variable v2,
                        int weight)
Construct myself to be a binary constraint between variables v1 and v2, with the specified weight.


BinaryConstraint

public BinaryConstraint(Variable v,
                        int weight)
Construct myself to be a "unary" constraint on v. Actually, this is a BinaryConstraint with both its variables being v.

Method Detail

clear

public abstract void clear()

activate

public void activate()
Activate this constraint.


deactivate

public void deactivate()
Deactivate this constraint.


isApplicable

public boolean isApplicable()
Return true iff all variables involved are instantiated.


execute

public abstract boolean execute()
Check if the constraint is satisfied.

Pre: isApplicable().


getCause

public Variable getCause(Variable rvar)
When execute() failed, this returns the variable that is supposed to have caused the failure.

Parameters:
rvar - the variable (of the two involved) that has been instantiated most recently.

getVar1

public Variable getVar1()
Return my first variable.


getVar2

public Variable getVar2()
Return my second variable.


getWeight

public int getWeight()
Return my weight. The higher the value, the higher the significance of the constraint.