CIDER Toolkit
Version 0.1.0-beta

au.edu.monash.csse.tonyj.cider.constraints
Class ConstraintSolver

java.lang.Object
  |
  +--ConstraintSolver

public abstract class ConstraintSolver
extends java.lang.Object

This abstract base class allows a multi-way constraint solver to be implemented in the CIDER toolkit. Classes that extend this base class should also define a no-argument constructor.


Constructor Summary
ConstraintSolver()
           
 
Method Summary
abstract  boolean addConstraint(Constraint c)
          Adds a constraint to the solver.
 void addConstraintVariableListener(ConstraintVariableListener cvl)
          Adds an listener to listen for solver events (which are launched whenever a constraint variable is modified by the solver).
abstract  void addEditVariable(ConstraintVariable v)
          Informs the solver that a new desired value is going to be suggested for a particular variable.
abstract  void addVariable(ConstraintVariable v)
          Adds a constraint variable to the solver.
abstract  java.util.Set getConstraints()
          Returns a set containing all constraints in the solver.
abstract  java.util.Set getConstraintVariables()
          Returns a set containing all constraint variables in the solver (including, of course, all variables used by constraints in the solver).
 void launchVariableModifiedEvent(ConstraintVariable cv, java.lang.Double oldValue)
          Launches an event which indicates that a constraint variable has been modified.
abstract  boolean removeConstraint(Constraint c)
          Removes a constraint from the solver if possible.
 void removeConstraintVariableListener(ConstraintVariableListener cvl)
          Removes a listener that listens for solver events (which are launched whenever a constraint variable is modified by the solver).
abstract  boolean removeVariable(ConstraintVariable v)
          Removes a constraint variable from the solver if possible.
abstract  void resolve()
          Calls the solver to re-solve the constraints.
abstract  void solve()
          Calls the solver to solve all constraints.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintSolver

public ConstraintSolver()
Method Detail

addVariable

public abstract void addVariable(ConstraintVariable v)
Adds a constraint variable to the solver. If the variable is already in the solver, this method does nothing.

Parameters:
v - The variable to be added.

removeVariable

public abstract boolean removeVariable(ConstraintVariable v)
Removes a constraint variable from the solver if possible. If the variable is currently being used by a constraint in the solver, it may not be possible to remove the variable.

Parameters:
v - The variable to be removed.
Returns:
true if the variable successfully removed, false otherwise.

addConstraint

public abstract boolean addConstraint(Constraint c)
Adds a constraint to the solver.

Parameters:
c - The constraint to be added.
Returns:
true if successful, false if the constraint could not be added because it conflicts with the existing constraints in the solver.

removeConstraint

public abstract boolean removeConstraint(Constraint c)
Removes a constraint from the solver if possible.

Parameters:
c - The constraint to be removed.
Returns:
true if the constraint successfully removed, false otherwise.

addEditVariable

public abstract void addEditVariable(ConstraintVariable v)
Informs the solver that a new desired value is going to be suggested for a particular variable. Allows the solver to tag that variable as one that can be edited.

Parameters:
v - The variable to be edited.

getConstraints

public abstract java.util.Set getConstraints()
Returns a set containing all constraints in the solver.


getConstraintVariables

public abstract java.util.Set getConstraintVariables()
Returns a set containing all constraint variables in the solver (including, of course, all variables used by constraints in the solver).


solve

public abstract void solve()
Calls the solver to solve all constraints. This method should be called if constraints have been added to or removed from the solver.

This method must call the launchVariableModifiedEvent(au.edu.monash.csse.tonyj.cider.constraints.ConstraintVariable, java.lang.Double) method for each constraint variable whose value has been modified by this call.


resolve

public abstract void resolve()
Calls the solver to re-solve the constraints. This method should be called if the suggested values of constraint variables have been modified.

This method must call the launchVariableModifiedEvent(au.edu.monash.csse.tonyj.cider.constraints.ConstraintVariable, java.lang.Double) method for each constraint variable whose value has been modified by this call.


addConstraintVariableListener

public void addConstraintVariableListener(ConstraintVariableListener cvl)
Adds an listener to listen for solver events (which are launched whenever a constraint variable is modified by the solver).

Parameters:
cvl - The listener to be added.

removeConstraintVariableListener

public void removeConstraintVariableListener(ConstraintVariableListener cvl)
Removes a listener that listens for solver events (which are launched whenever a constraint variable is modified by the solver).

Parameters:
cvl - The listener to be removed.

launchVariableModifiedEvent

public void launchVariableModifiedEvent(ConstraintVariable cv,
                                        java.lang.Double oldValue)
Launches an event which indicates that a constraint variable has been modified. All constraint variable listeners that have been added to the solver are informed of this event.

Parameters:
cv - The constraint variable that was modified.
oldValue - The old solved value of the constraint variable before the modificaton.

CIDER Toolkit
Version 0.1.0-beta