|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectomnics.Constraint
public abstract class Constraint
Represents an abstract constraint. A constraint is a logical relation among several variables, restricting the possible values that variables can take. There are no assumptions regarding the definition of the constraints: they can be represented as the underlying relation of permitted values or as a function defined on a set of variables and returning an integer that represents an evaluation of a given tuple.
| Field Summary | |
|---|---|
static int |
ALLOWED
|
protected Filter |
filter
|
static int |
FORBIDDEN
|
static int |
MAX
|
static int |
MIN
|
protected java.lang.String |
name
|
protected Problem |
problem
|
protected VarSet |
variables
|
| Constructor Summary | |
|---|---|
Constraint(Var... vars)
Creates a new constraint on the specified variables. |
|
Constraint(VarSet variables)
Creates a new constraint on the specified set of variables. |
|
| Method Summary | |
|---|---|
abstract int |
eval(Tuple tuple)
Evaluates a tuple. |
int |
eval(Var x,
java.lang.Object a)
Convenience method that evaluates an assignment (x=a). |
int |
eval(Var x,
Var y,
java.lang.Object a,
java.lang.Object b)
Convenience method that evaluates an assignment (x=a, y=b). |
Filter |
getFilter()
Gets the associated filter (if any). |
java.lang.String |
getName()
Gets the name of the constraint. |
Problem |
getProblem()
Gets the problem this constraint belongs to. |
TupleSet |
getTuples()
Creates and returns a set containing all the tuples that satisfy this constraint. |
Var[] |
getVarArray()
Returns the variables of the constraint as an array. |
VarSet |
getVariables()
Gets a reference to the variables of the constraint. |
void |
setFilter(Filter filter)
Sets a filter for this (global) constraint. |
void |
setName(java.lang.String name)
Sets the name of the constraint. |
void |
setVariables(Var... vars)
Sets the variables of the constraint. |
void |
setVariables(VarSet variables)
Sets the variables of the constraint. |
java.lang.String |
toString()
Returns a string representation of the constraint. |
Var |
variable(int index)
Gets the variable at the specified index |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String name
protected Problem problem
protected VarSet variables
protected Filter filter
public static final int ALLOWED
public static final int FORBIDDEN
public static final int MIN
public static final int MAX
| Constructor Detail |
|---|
public Constraint(VarSet variables)
variables - a set of variablespublic Constraint(Var... vars)
vars - some variables| Method Detail |
|---|
public java.lang.String getName()
public void setName(java.lang.String name)
name - the name given to the constraintpublic Problem getProblem()
public VarSet getVariables()
public void setVariables(VarSet variables)
variables - the variables of the constraintpublic void setVariables(Var... vars)
vars - the variables of the constraintpublic Var[] getVarArray()
public Var variable(int index)
index - an index
public Filter getFilter()
public void setFilter(Filter filter)
filter - a filterFilter
public int eval(Var x,
java.lang.Object a)
x - some variable of the constrainta - some value in x's domain
eval(Tuple),
ValuationStructure
public int eval(Var x,
Var y,
java.lang.Object a,
java.lang.Object b)
x - some variable of the constrainta - some value in x's domainy - some variable of the constraintb - some value in y's domain
eval(Tuple),
ValuationStructurepublic abstract int eval(Tuple tuple)
tuple - some tuple
eval(Tuple),
ValuationStructurepublic TupleSet getTuples()
Warning: if the constrained is not an explicit constraint
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||