agg.util.csp
Class CSP

java.lang.Object
  extended by agg.util.csp.CSP
Direct Known Subclasses:
ALR_CSP, ALR_InheritCSP

public abstract class CSP
extends java.lang.Object

An abstract class for Constraint Satisfaction Problems with only binary constraints.


Field Summary
protected  java.lang.Object itsDomain
           
protected  SolutionStrategy itsSolver
           
protected  boolean itsTouchedFlag
           
 
Constructor Summary
CSP(SolutionStrategy solver)
          Construct myself with an initial SolutionStrategy.
 
Method Summary
 java.lang.Object getDomain()
          Return the current global domain of values.
abstract  int getSize()
          Return the number of variables in the CSP.
abstract  Variable getVariable(GraphObject obj)
           
abstract  java.util.Enumeration<Variable> getVariables()
          Return an Enumeration of all my variables.
 boolean hasFoundSolution()
           
 boolean hasMoreSolutions()
           
 boolean hasQueries()
           
 boolean nextSolution()
          Compute my next solution, and instantiate my variables appropriately.
protected abstract  void preprocessDomain(java.lang.Object domain)
          Preprocess the given domain for optimization purposes (to get more accurate data for Constraint weights, or to initialize Query databases).
 void reinitialize(boolean doUpdateQueries)
           
 void reset()
           
 void setDomain(java.lang.Object domain)
          Set the global domain of values for the variables, and call preprocessDomain() with the given domain.
 void setSolutionStrategy(SolutionStrategy solver)
          Set the algorithm which is used to compute my solutions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itsDomain

protected java.lang.Object itsDomain

itsSolver

protected SolutionStrategy itsSolver

itsTouchedFlag

protected boolean itsTouchedFlag
Constructor Detail

CSP

public CSP(SolutionStrategy solver)
Construct myself with an initial SolutionStrategy.

Post: getDomain() == null.

Method Detail

getVariables

public abstract java.util.Enumeration<Variable> getVariables()
Return an Enumeration of all my variables. Enumeration elements are of type Variable.


getVariable

public abstract Variable getVariable(GraphObject obj)

getSize

public abstract int getSize()
Return the number of variables in the CSP.


setDomain

public final void setDomain(java.lang.Object domain)
Set the global domain of values for the variables, and call preprocessDomain() with the given domain.

Post: getDomain() == domain.

See Also:
preprocessDomain(java.lang.Object)

preprocessDomain

protected abstract void preprocessDomain(java.lang.Object domain)
Preprocess the given domain for optimization purposes (to get more accurate data for Constraint weights, or to initialize Query databases). This is a template method to be implemented in subclasses, and is invoked out of setDomain().

See Also:
setDomain(java.lang.Object)

getDomain

public final java.lang.Object getDomain()
Return the current global domain of values.


nextSolution

public final boolean nextSolution()
Compute my next solution, and instantiate my variables appropriately. Variables already instantiated will not be altered, so this method can be used to complete partial solutions. Invoke this method repeatedly to get all solutions.

Pre: getDomain() != null.

Returns:
false if there are no more solutions.

setSolutionStrategy

public final void setSolutionStrategy(SolutionStrategy solver)
Set the algorithm which is used to compute my solutions.


hasMoreSolutions

public boolean hasMoreSolutions()

hasFoundSolution

public boolean hasFoundSolution()

hasQueries

public boolean hasQueries()

reset

public final void reset()

reinitialize

public final void reinitialize(boolean doUpdateQueries)