agg.util.csp
Class Query

java.lang.Object
  extended by agg.util.csp.Query
Direct Known Subclasses:
Query_Incoming, Query_Outgoing, Query_Source, Query_Target, Query_Type

public abstract class Query
extends java.lang.Object

An abstract class that represents a query for a variable domain.


Field Summary
protected  int itsWeight
           
 java.lang.String typeNameOfVariable
           
 
Constructor Summary
Query(Variable tar, int weight)
          Construct myself to be a constant query.
Query(Variable src, Variable tar, int weight)
          Construct myself to be a unary query.
Query(Variable src1, Variable src2, Variable tar, int weight)
          Construct myself to be a binary query.
 
Method Summary
 void activateCorrespondent()
          Activates the correspondent constraint of this query.
 void deactivateCorrespondent()
          Deactivates the correspondent constraint of this query.
abstract  java.util.Enumeration<?> execute()
          Return an Enumeration of candidate values for the target variable.
abstract  java.lang.String getKind()
          Return the name of my implementing class.
abstract  int getSize()
          Return the number of candidate values execute() will provide.
 Variable getSource(int i)
           
protected  java.lang.Object getSourceInstance(int i)
          Return the current instance of the source variable given by the index i.
 java.util.Enumeration<?> getSources()
          Return an enumeration of the variables that need to be instantiated for the query to work.
 Variable getTarget()
          Return the variable that I'm determining the domain for.
 int getWeight()
          Return my weight.
 boolean isApplicable()
          Return true iff all my source variables are instantiated, while my target variable is not.
 boolean isConstant()
          Return true iff I am a constant query.
 void setCorrespondent(BinaryConstraint constraint)
          Sets the correspondent constraint of this query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itsWeight

protected int itsWeight

typeNameOfVariable

public java.lang.String typeNameOfVariable
Constructor Detail

Query

public Query(Variable tar,
             int weight)
Construct myself to be a constant query.


Query

public Query(Variable src,
             Variable tar,
             int weight)
Construct myself to be a unary query.


Query

public Query(Variable src1,
             Variable src2,
             Variable tar,
             int weight)
Construct myself to be a binary query.

Method Detail

isApplicable

public boolean isApplicable()
Return true iff all my source variables are instantiated, while my target variable is not.


isConstant

public boolean isConstant()
Return true iff I am a constant query. That means, the result of execute() is the same for any variable instantiation configuration.


execute

public abstract java.util.Enumeration<?> execute()
Return an Enumeration of candidate values for the target variable.

Pre: isApplicable().


getTarget

public Variable getTarget()
Return the variable that I'm determining the domain for.


getSources

public final java.util.Enumeration<?> getSources()
Return an enumeration of the variables that need to be instantiated for the query to work. Enumeration elements are of type Variable.


getSource

public final Variable getSource(int i)

getSize

public abstract int getSize()
Return the number of candidate values execute() will provide. For non-constant queries, this will most probably be based on estimation. The value may change in response to re-setting the CSP domains with the setDomain() method.

Pre: csp.getDomain() != null.

See Also:
CSP.setDomain(java.lang.Object)

getWeight

public final int getWeight()
Return my weight. This is a constant integer usually chosen inversely proportional to the estimated size of the candidate set returned by a query execution.


getKind

public abstract java.lang.String getKind()
Return the name of my implementing class.


getSourceInstance

protected final java.lang.Object getSourceInstance(int i)
Return the current instance of the source variable given by the index i.

Pre: i < itsSources.size().


setCorrespondent

public void setCorrespondent(BinaryConstraint constraint)
Sets the correspondent constraint of this query.

Parameters:
constraint -

activateCorrespondent

public void activateCorrespondent()
Activates the correspondent constraint of this query.


deactivateCorrespondent

public void deactivateCorrespondent()
Deactivates the correspondent constraint of this query.