|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpaul.Constraints.Constraint<V,Info> jpaul.Constraints.LtConstraint<V,Info>
public final class LtConstraint<V extends Var<Info>,Info>
LtConstraint
models a "less than"
constraint: the value of variable vs
is smaller than
the value of variable vd
, according to the order
relation from the corresponding lattice. This order is implicitly
given by the join
operation of the two variables.
The two variables must represent information from the same lattice
(i.e., the same join
operation)
Field Summary | |
---|---|
V |
vd
|
V |
vs
|
Fields inherited from class jpaul.Constraints.Constraint |
---|
AVG_COST, HIGH_COST, LOW_COST, VERY_LOW_COST |
Constructor Summary | |
---|---|
LtConstraint(V vs,
V vd)
Creates a LtConstraint with default cost Constraint.LOW_COST . |
|
LtConstraint(V vs,
V vd,
int cost)
Creates an LtConstraint with the meaning
"value of variable vs is smaller than the
value of the variable vd ." |
Method Summary | |
---|---|
void |
action(SolAccessor<V,Info> sa)
Performs the action attached to this constraint. |
int |
cost()
Returns a rough estimate of the evaluation cost of this constraint. |
boolean |
equals(java.lang.Object o)
|
int |
hashCode()
|
java.util.Collection<V> |
in()
|
java.util.Collection<V> |
out()
|
Constraint<V,Info> |
rewrite(UnionFind<V> uf)
Rewrites this constraint by replacing each
variable with the representative of its equivalence class. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final V extends Var<Info> vs
public final V extends Var<Info> vd
Constructor Detail |
---|
public LtConstraint(V vs, V vd)
LtConstraint
with default cost Constraint.LOW_COST
.
public LtConstraint(V vs, V vd, int cost)
LtConstraint
with the meaning
"value of variable vs
is smaller than the
value of the variable vd
."
cost
- Relative cost of this constraint.Method Detail |
---|
public int cost()
Constraint
this
constraint. This cost has only a relative
meaning: e.g., a constraint is more/less costly than another.
A constraint solver may choose to iterate first over the cheap
constraints, and only next iterate over the other, more
expensive constraints.
The cost should influence only the speed, not the correctness:
the solution of a system of constraints should satisfy all
constraints, regardless of their cost.
By default, it returns AVG_COST
.
cost
in class Constraint<V extends Var<Info>,Info>
public java.util.Collection<V> in()
in
in class Constraint<V extends Var<Info>,Info>
public java.util.Collection<V> out()
out
in class Constraint<V extends Var<Info>,Info>
public void action(SolAccessor<V,Info> sa)
Constraint
sa.
get
.
sa.
join
to join the computed
values to several out-variables.
Note1: It is a serious mistake to write an
action
method that reads/modifies variables that
are not listed in the collections returned by
in()
/out()
. If you ever suspect
such an error, please set ConstraintSystem.CHECK_IN_OUT
to true
.
Note2: The solver initializes each variable to
null
(null
is considered equivalent
to the bottom element of the correspoding lattice). The body
of action
should be prepared to receive a
null
result from sa.get
.
action
in class Constraint<V extends Var<Info>,Info>
sa
- Provides access to the values of the variables that
are read/modified.public Constraint<V,Info> rewrite(UnionFind<V> uf)
Constraint
this
constraint by replacing each
variable with the representative of its equivalence class.
The real implementation of this method is optional: the
default implementation returns this
constraint,
unmodified. This is safe: the constraint writer does not need
to be aware of variable unification, as the
SolAccessor
passed by the constraint solver
already deals with it.
Implementing rewrite
may be useful when
unification causes several constraints to become identical:
e.g., consider v1 <= v2
and v3 <=
v4
, after we unify v1
with v3
and v2
with v4
. Implementing
rewrite
, equals
(and
hashCode
) allows the solver to avoid working with
several identical constraints.
rewrite
in class Constraint<V extends Var<Info>,Info>
uf
- Union-find structure; for each variable
v
, uf.find(v)
is the representative
of its equivalence class.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
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 |