|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Term>
org.opt4j.satdecoding.Constraint
public class Constraint
A linear pseudo-Boolean Constraint as used in an Integer Linear
Program (ILP). A set of Constraints specify a search space.
This Constraint consists of a list of Terms, an
Constraint.Operator and a right hand side. E.g., 4a - 3b + not(c) <= 7
is a valid Constraint consisting of three Literals
a, b, not(c) with coefficients 4, 3, 1 , the less or equal
operator from Constraint.Operator, and the right hand side 7.
This implementation is a plain data structure, i.e., 4a - 3a + c <= 1
is not simplified to a + c <= 1. Moreover, two Constraints
are equal if they have an equal Constraint.Operator, right hand side, and equal
Terms in the same order.
| Nested Class Summary | |
|---|---|
static class |
Constraint.Operator
The Constraint.Operators correspond to the Boolean operators <=,=,>=. |
| Field Summary | |
|---|---|
protected Constraint.Operator |
operator
|
protected int |
rhs
|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
Constraint()
Constructs a linear Constraint with >=1. |
|
Constraint(Constraint.Operator operator,
int rhs)
Constructs a linear Constraint. |
|
Constraint(java.lang.String operator,
int rhs)
Constructs a linear Constraint. |
|
| Method Summary | |
|---|---|
void |
add(int coeff,
Literal lit)
Add a Literal with specified coefficient. |
void |
add(Literal lit)
Add a Literal with the coefficient 1. |
boolean |
contains(Literal literal)
Returns true if the Constraint contains the
Literal. |
Constraint |
copy()
Copies the Constraint. |
boolean |
equals(java.lang.Object obj)
|
java.lang.Iterable<java.lang.Integer> |
getCoefficients()
Returns an iterable of the coefficients. |
java.lang.Iterable<Literal> |
getLiterals()
Returns an iterable of the Literals. |
Constraint.Operator |
getOperator()
Returns the Constraint.Operator. |
int |
getRhs()
Return the right hand side value. |
int |
getViolationCount(Model model)
Specifies if the Constraint is satisfied for a given
Model. |
int |
hashCode()
|
boolean |
isSatisfied(Model model)
Checks, if this constraint is satisfied for a given model. |
void |
setOperator(Constraint.Operator operator)
Sets the Constraint.Operator. |
void |
setRhs(int rhs)
Sets the right hand side value. |
java.lang.String |
toString()
|
| Methods inherited from class java.util.ArrayList |
|---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
containsAll, iterator, listIterator, listIterator, removeAll, retainAll, subList |
| Field Detail |
|---|
protected Constraint.Operator operator
protected int rhs
| Constructor Detail |
|---|
public Constraint()
Constraint with >=1.
public Constraint(java.lang.String operator,
int rhs)
Constraint.
operator - the operator (<=,=,>=) as a Stringrhs - the right-hand-side value
public Constraint(Constraint.Operator operator,
int rhs)
Constraint.
operator - the operatorrhs - the right-hand-side value| Method Detail |
|---|
public java.lang.Iterable<java.lang.Integer> getCoefficients()
public java.lang.Iterable<Literal> getLiterals()
Literals.
public Constraint.Operator getOperator()
Constraint.Operator.
setOperator(org.opt4j.satdecoding.Constraint.Operator)public void setOperator(Constraint.Operator operator)
Constraint.Operator.
operator - the operator to be setgetOperator()public int getRhs()
setRhs(int)public void setRhs(int rhs)
rhs - the right hand side value to setgetRhs()public java.lang.String toString()
toString in class java.util.AbstractCollection<Term>public boolean isSatisfied(Model model)
model - the model
public int getViolationCount(Model model)
Constraint is satisfied for a given
Model.
model - the model
true if this constraint is satisfied for the modelpublic void add(Literal lit)
Literal with the coefficient 1.
lit - the literal
public void add(int coeff,
Literal lit)
Literal with specified coefficient.
coeff - the coefficientlit - the literalpublic Constraint copy()
Constraint.
public boolean contains(Literal literal)
true if the Constraint contains the
Literal.
literal - the literal
true if the constrain} contains the literalpublic int hashCode()
hashCode in interface java.util.Collection<Term>hashCode in interface java.util.List<Term>hashCode in class java.util.AbstractList<Term>public boolean equals(java.lang.Object obj)
equals in interface java.util.Collection<Term>equals in interface java.util.List<Term>equals in class java.util.AbstractList<Term>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||