public abstract class Variable extends java.lang.Object implements java.lang.Comparable<Variable>, java.io.Serializable
MultiVariable
to accommodate variables which are themselves constraint networks
(essential for the Meta-CSP approach).| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object |
attributes
A field to set generic attributes
|
static java.util.HashMap<org.metacsp.framework.Variable.FieldOfObject,java.lang.Object> |
backupForSerialization |
protected Variable[] |
dependentVariables |
protected int |
id
ID generation is up to the implementing class.
|
protected java.util.logging.Logger |
logger |
protected ConstraintSolver |
solver
Every variable has a constraint solver.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Variable(ConstraintSolver cs,
int id)
A variable should not be instantiated directly, rather only a ConstraintSolver
should create variables (through the createVariable() methods).
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDependentVariables(Variable... depVars)
|
boolean |
dependsOn(Variable var)
|
boolean |
equals(java.lang.Object o)
Ascertain whether this variable is equal to another.
|
MultiVariable |
getAncestorVariable(java.lang.Class<?> cls)
Get the first ancestor
MultiVariable of this Variable that is of a given type. |
java.lang.Object |
getAttributes() |
java.awt.Paint |
getColor() |
java.lang.String |
getComponent()
Get this
Variable's component. |
ConstraintSolver |
getConstraintSolver()
Get the constraint solver of this Variable.
|
Variable[] |
getDependentVariables()
Get the
Variables that depend on this variable. |
java.lang.String |
getDescription()
Get the description of this
Variable's type. |
abstract Domain |
getDomain()
Get the domain of this Variable.
|
int |
getID()
Get the ID of this variable.
|
java.lang.Object |
getMarking()
Get the marking of this
Variable. |
java.lang.Object |
getOwner() |
MultiVariable |
getParentVariable()
Get the parent variable of this
Variable. |
Variable[] |
getRecursivelyDependentVariables()
|
MultiVariable |
getRootVariable()
Get the highest ancestor
MultiVariable of this Variable (root of the variable hierarchy). |
int |
hashCode() |
boolean |
isDependentVariable()
Returns
true iff this variable appears in the dependency list of
any other variable in the same constraint network. |
void |
removeDependentVariables(Variable... depVars)
|
void |
setAttributes(java.lang.Object attributes) |
void |
setColor(java.awt.Paint c) |
void |
setComponent(java.lang.String component)
Set this
Variable's component. |
void |
setDependentVariables(Variable... depVars)
|
abstract void |
setDomain(Domain d)
Set the domain of this variable.
|
void |
setMarking(java.lang.Object marking)
Set the marking of this
Variable. |
void |
setOwner(java.lang.Object owner) |
void |
setParentVariable(MultiVariable p)
Set the parent variable of this
Variable. |
abstract java.lang.String |
toString()
Get a
String representation of this Variable. |
public static java.util.HashMap<org.metacsp.framework.Variable.FieldOfObject,java.lang.Object> backupForSerialization
protected Variable[] dependentVariables
protected transient java.util.logging.Logger logger
protected int id
protected transient java.lang.Object attributes
protected ConstraintSolver solver
protected Variable(ConstraintSolver cs, int id)
cs - The constraint solver to which this variable refers to.id - The ID of the variable (should be maintained by the ConstraintSolver in some way).public void setDependentVariables(Variable... depVars)
public void addDependentVariables(Variable... depVars)
public Variable[] getDependentVariables()
Variables that depend on this variable. Dependent variables are removed
when this variable is removed.Variables that depend on this variable.public boolean dependsOn(Variable var)
public boolean isDependentVariable()
true iff this variable appears in the dependency list of
any other variable in the same constraint network.true if this variable appears in the dependency list of
any other variable, false otherwise.public Variable[] getRecursivelyDependentVariables()
public void removeDependentVariables(Variable... depVars)
depVars - The dependencies to remove.public void setParentVariable(MultiVariable p)
Variable.p - The parent variable of this Variable.public MultiVariable getParentVariable()
Variable.Variable.public MultiVariable getAncestorVariable(java.lang.Class<?> cls)
MultiVariable of this Variable that is of a given type.cls - The type of the ancestor MultiVariable.MultiVariable of this Variable that is of the given type.public MultiVariable getRootVariable()
MultiVariable of this Variable (root of the variable hierarchy).Variable's variable hierarchy.public void setMarking(java.lang.Object marking)
Variable.marking - an Object representing the marking of this Variable.public java.lang.Object getMarking()
Variable.Object representing the marking of this Variable.public ConstraintSolver getConstraintSolver()
public abstract Domain getDomain()
public abstract void setDomain(Domain d)
d - The domain of the variable.public int getID()
public abstract java.lang.String toString()
String representation of this Variable.toString in class java.lang.ObjectString representation of this Variable.public java.lang.String getComponent()
Variable's component.Variable's component.public void setComponent(java.lang.String component)
Variable's component.component - This Variable's component.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String getDescription()
Variable's type.Variable's type.public java.lang.Object getOwner()
public void setOwner(java.lang.Object owner)
public java.awt.Paint getColor()
public void setColor(java.awt.Paint c)
public java.lang.Object getAttributes()
public void setAttributes(java.lang.Object attributes)