CIDER Toolkit
Version 0.1.0-beta

au.edu.monash.csse.tonyj.cider.constraints
Interface Constraint

All Superinterfaces:
java.io.Serializable

public interface Constraint
extends java.io.Serializable

A constraint essentially defines a mathematical relationship, such as x < y + 3 (where each side of the < sign can be thought of as a ConstraintExpression). This interface defines how a constraint is manipulated. Classes that implement this interface should also define a no-argument constructor and must be Serializable.


Method Summary
 java.util.Set getConstraintVariables()
          Returns a set containing all the constraint variables used by this constraint.
 double getWeight()
          Returns the weight of this constraint.
 void initialize(java.lang.String constraint, ConstraintVariable[] variables)
          Initializes the constraint from a string.
 void initializeConstant(ConstraintVariable variable, double constant)
          Initializes a constraint of the form: variable == constant
 void initializeWithEqualsRelationship(ConstraintVariable variable, ConstraintExpression expression)
          Initializes a constraint of the form: variable == expression
 boolean isSatisfied(double tolerance)
          Returns true if and only if the solved values of the constraint variables satisfy this constraint within the specified tolerance amount.
 void setWeight(double weight)
          Sets the weight of this constraint.
 

Method Detail

initialize

public void initialize(java.lang.String constraint,
                       ConstraintVariable[] variables)
                throws CannotProcessConstraintException,
                       java.lang.ArrayIndexOutOfBoundsException,
                       java.lang.NumberFormatException
Initializes the constraint from a string.

Parameters:
constraint - A string that defines the constraint (this string needs to be parsed).
variables - An array of constraint variables that the constraint string refers to.
Throws:
CannotProcessConstraintException - If string cannot be parsed.
java.lang.ArrayIndexOutOfBoundsException - If an illegal access of the constraint variable array is attempted.
java.lang.NumberFormatException - If an illegal number format is found in the string being parsed.

initializeWithEqualsRelationship

public void initializeWithEqualsRelationship(ConstraintVariable variable,
                                             ConstraintExpression expression)
Initializes a constraint of the form: variable == expression

Parameters:
variable - The variable to be used in defining the equals relationship.
expression - The expression to be used in defining the equals relationship.

initializeConstant

public void initializeConstant(ConstraintVariable variable,
                               double constant)
Initializes a constraint of the form: variable == constant

Parameters:
variable - The variable to be used in defining the equals relationship.
constant - The constant value.

isSatisfied

public boolean isSatisfied(double tolerance)
Returns true if and only if the solved values of the constraint variables satisfy this constraint within the specified tolerance amount. This method must work regardless of whether the constraint has been added to a ConstraintSolver or not. If the constraint has not been initialized, behaviour is undefined.

Parameters:
tolerance - Tolerance amount for checking constraint satisfaction.

getConstraintVariables

public java.util.Set getConstraintVariables()
Returns a set containing all the constraint variables used by this constraint.


setWeight

public void setWeight(double weight)
Sets the weight of this constraint.

Parameters:
weight - Weight value.

getWeight

public double getWeight()
Returns the weight of this constraint.


CIDER Toolkit
Version 0.1.0-beta