|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sat4j.pb.tools.DependencyHelper<T,C>
T
- The class of the objects to map into boolean variables.C
- The class of the object to map to each constraint.public class DependencyHelper<T,C>
Helper class intended to make life easier to people to feed a sat solver programmatically.
Field Summary | |
---|---|
boolean |
explanationEnabled
|
INegator<T> |
NO_NEGATION
|
Constructor Summary | |
---|---|
DependencyHelper(IPBSolver solver)
|
|
DependencyHelper(IPBSolver solver,
boolean explanationEnabled)
|
Method Summary | |
---|---|
void |
addToObjectiveFunction(T thing,
java.math.BigInteger weight)
Add a weighted literal to the objective function. |
void |
addToObjectiveFunction(T thing,
int weight)
Add a weighted literal to the objective function. |
void |
and(C name,
T thing,
T... otherThings)
Create a constraint of the form thing <=> (thing1 and thing 2 ... and thingn) |
ImplicationNamer<T,C> |
atMost(int i,
T... things)
Create a constraint stating that at most i domain object should be set to true. |
void |
clause(C name,
T... things)
Create a clause (thing1 or thing 2 ... or thingn) |
void |
discard(IVec<T> things)
|
DisjunctionRHS<T,C> |
disjunction(T... lhs)
|
boolean |
getBooleanValueFor(T t)
Retrieve the boolean value associated with a domain object in the solution found by the solver. |
int |
getNumberOfConstraints()
|
int |
getNumberOfVariables()
|
java.lang.String |
getObjectiveFunction()
|
IVec<T> |
getSolution()
Retrieve the solution found. |
java.math.BigInteger |
getSolutionCost()
|
boolean |
hasASolution()
|
boolean |
hasASolution(java.util.Collection<T> assumps)
|
boolean |
hasASolution(IVec<T> assumps)
|
void |
iff(C name,
T thing,
T... otherThings)
Create a constraint using equivalency chains thing <=> (thing1 <=> thing2 <=> ... <=> thingn) |
void |
ifThenElse(C name,
T thing,
T conditionThing,
T thenThing,
T elseThing)
Create a constraint of the form thing <=> (if conditionThing then thenThing else elseThing) |
ImplicationRHS<T,C> |
implication(T... lhs)
Create a logical implication of the form lhs -> rhs |
void |
or(C name,
T thing,
T... otherThings)
Create a constraint of the form thing <=> (thing1 or thing 2 ... or thingn) |
void |
setFalse(T thing,
C name)
Add a constraint to set the value of a domain object to false. |
void |
setNegator(INegator<T> negator)
|
void |
setObjectiveFunction(WeightedObject<T>... wobj)
Add an objective function to ask for a solution that minimize the objective function. |
void |
setTrue(T thing,
C name)
Add a constraint to set the value of a domain object to true. |
void |
stopExplanation()
Stop the explanation computation. |
void |
stopSolver()
Stop the SAT solver that is looking for a solution. |
java.util.Set<C> |
why()
Explain the reason of the inconsistency of the set of constraints. |
java.util.Set<C> |
why(T thing)
Explain a domain object has been set to true in a solution. |
java.util.Set<C> |
whyNot(T thing)
Explain a domain object has been set to false in a solution. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final INegator<T> NO_NEGATION
public boolean explanationEnabled
Constructor Detail |
---|
public DependencyHelper(IPBSolver solver)
solver
- the solver to be used to solve the problem.public DependencyHelper(IPBSolver solver, boolean explanationEnabled)
Method Detail |
---|
public void setNegator(INegator<T> negator)
public IVec<T> getSolution()
#hasASolution()}
public java.math.BigInteger getSolutionCost()
public boolean getBooleanValueFor(T t)
t
- a domain object
public boolean hasASolution() throws TimeoutException
TimeoutException
public boolean hasASolution(IVec<T> assumps) throws TimeoutException
TimeoutException
public boolean hasASolution(java.util.Collection<T> assumps) throws TimeoutException
TimeoutException
public java.util.Set<C> why() throws TimeoutException
TimeoutException
#hasASolution()}
public java.util.Set<C> why(T thing) throws TimeoutException
TimeoutException
#hasASolution()}
public java.util.Set<C> whyNot(T thing) throws TimeoutException
TimeoutException
#hasASolution()}
public void setTrue(T thing, C name) throws ContradictionException
thing
- the domain objectname
- the name of the constraint, to be used in an explanation if
needed.
ContradictionException
- if the set of constraints appears to be trivially
inconsistent.public void setFalse(T thing, C name) throws ContradictionException
thing
- the domain objectname
- the name of the constraint, to be used in an explanation if
needed.
ContradictionException
- if the set of constraints appears to be trivially
inconsistent.public ImplicationRHS<T,C> implication(T... lhs)
lhs
- some domain objects. They form a conjunction in the left hand
side of the implication.
public DisjunctionRHS<T,C> disjunction(T... lhs)
public ImplicationNamer<T,C> atMost(int i, T... things) throws ContradictionException
i
- the maximum number of domain object to set to true.things
- the domain objects.
ContradictionException
public void clause(C name, T... things) throws ContradictionException
name
- things
-
ContradictionException
public void iff(C name, T thing, T... otherThings) throws ContradictionException
thing
- a domain objectthings
- other domain objects.
ContradictionException
public void and(C name, T thing, T... otherThings) throws ContradictionException
name
- thing
- otherThings
-
ContradictionException
public void or(C name, T thing, T... otherThings) throws ContradictionException
name
- thing
- otherThings
-
ContradictionException
public void ifThenElse(C name, T thing, T conditionThing, T thenThing, T elseThing) throws ContradictionException
name
- thing
- otherThings
-
ContradictionException
public void setObjectiveFunction(WeightedObject<T>... wobj)
wobj
- a set of weighted objects (pairs of domain object and
BigInteger).public void addToObjectiveFunction(T thing, int weight)
thing
- weight
- public void addToObjectiveFunction(T thing, java.math.BigInteger weight)
thing
- weight
- public void stopSolver()
public void stopExplanation()
public void discard(IVec<T> things) throws ContradictionException
ContradictionException
public java.lang.String getObjectiveFunction()
public int getNumberOfVariables()
public int getNumberOfConstraints()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |