|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sat4j.tools.SolverDecorator<T>
org.sat4j.tools.xplain.Xplain<T>
T - a subinterface to ISolver.public class Xplain<T extends ISolver>
Explanation framework for SAT4J. The explanation uses selector variables and assumptions. It is based on a two steps method: 1) extraction of a set of assumptions implying the inconsistency 2) minimization of that set.
| Field Summary | |
|---|---|
protected IVecInt |
assump
|
protected Map<Integer,IConstr> |
constrs
|
| Constructor Summary | |
|---|---|
Xplain(T solver)
|
|
Xplain(T solver,
boolean skipDuplicatedEntries)
|
|
| Method Summary | |
|---|---|
IConstr |
addAtLeast(IVecInt literals,
int degree)
Create a cardinality constraint of the type "at least n of those literals must be satisfied" |
IConstr |
addAtMost(IVecInt literals,
int degree)
Create a cardinality constraint of the type "at most n of those literals must be satisfied" |
IConstr |
addClause(IVecInt literals)
Create a clause from a set of literals The literals are represented by non null integers such that opposite literals a represented by opposite values. |
IConstr |
addExactly(IVecInt literals,
int n)
Create a cardinality constraint of the type "exactly n of those literals must be satisfied". |
void |
cancelExplanation()
|
protected int |
createNewVar(IVecInt literals)
|
protected void |
discardLastestVar()
|
Collection<IConstr> |
explain()
|
int[] |
findModel()
Look for a model satisfying all the clauses available in the problem. |
int[] |
findModel(IVecInt assumps)
Look for a model satisfying all the clauses available in the problem. |
Collection<IConstr> |
getConstraints()
|
boolean |
isSatisfiable()
Check the satisfiability of the set of constraints contained inside the solver. |
boolean |
isSatisfiable(boolean global)
Check the satisfiability of the set of constraints contained inside the solver. |
boolean |
isSatisfiable(IVecInt assumps)
Check the satisfiability of the set of constraints contained inside the solver. |
boolean |
isSatisfiable(IVecInt assumps,
boolean global)
Check the satisfiability of the set of constraints contained inside the solver. |
int[] |
minimalExplanation()
|
int[] |
model()
Provide a model (if any) for a satisfiable formula. |
boolean |
removeConstr(IConstr c)
Remove a constraint returned by one of the add method from the solver. |
boolean |
removeSubsumedConstr(IConstr c)
Remove a constraint returned by one of the add method from the solver that is subsumed by a constraint already in the solver or to be added to the solver. |
void |
setMinimizationStrategy(MinimizationStrategy strategy)
|
String |
toString(String prefix)
Display a textual representation of the solver configuration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Map<Integer,IConstr> constrs
protected IVecInt assump
| Constructor Detail |
|---|
public Xplain(T solver,
boolean skipDuplicatedEntries)
public Xplain(T solver)
| Method Detail |
|---|
public IConstr addClause(IVecInt literals)
throws ContradictionException
ISolver
addClause in interface ISolveraddClause in class SolverDecorator<T extends ISolver>literals - a set of literals
ContradictionException - iff the vector of literals is empty or if it contains only
falsified literals after unit propagationISolver.removeConstr(IConstr)protected int createNewVar(IVecInt literals)
literals -
protected void discardLastestVar()
public IConstr addExactly(IVecInt literals,
int n)
throws ContradictionException
ISolver
addExactly in interface ISolveraddExactly in class SolverDecorator<T extends ISolver>literals - a set of literals. The vector can be reused since the solver
is not supposed to keep a reference to that vector.n - the number of literals that must be satisfied
ContradictionException - iff the constraint is trivially unsatisfiable.
public IConstr addAtLeast(IVecInt literals,
int degree)
throws ContradictionException
ISolver
addAtLeast in interface ISolveraddAtLeast in class SolverDecorator<T extends ISolver>literals - a set of literals. The vector can be reused since the solver
is not supposed to keep a reference to that vector.degree - the degree (n) of the cardinality constraint
ContradictionException - iff the vector of literals is empty or if degree literals are
not remaining unfalsified after unit propagationISolver.removeConstr(IConstr)
public IConstr addAtMost(IVecInt literals,
int degree)
throws ContradictionException
ISolver
addAtMost in interface ISolveraddAtMost in class SolverDecorator<T extends ISolver>literals - a set of literals The vector can be reused since the solver is
not supposed to keep a reference to that vector.degree - the degree (n) of the cardinality constraint
ContradictionException - iff the vector of literals is empty or if it contains more
than degree satisfied literals after unit propagationISolver.removeConstr(IConstr)
public int[] minimalExplanation()
throws TimeoutException
minimalExplanation in interface ExplainerTimeoutException
public Collection<IConstr> explain()
throws TimeoutException
TimeoutExceptionpublic void cancelExplanation()
public Collection<IConstr> getConstraints()
public int[] findModel()
throws TimeoutException
IProblem
if (isSatisfiable()) {
return model();
}
return null;
findModel in interface IProblemfindModel in class SolverDecorator<T extends ISolver>null if no model is found
TimeoutException - if a model cannot be found within the given timeout.
public int[] findModel(IVecInt assumps)
throws TimeoutException
IProblem
if (isSatisfiable(assumpt)) {
return model();
}
return null;
findModel in interface IProblemfindModel in class SolverDecorator<T extends ISolver>null if no model is found
TimeoutException - if a model cannot be found within the given timeout.
public boolean isSatisfiable()
throws TimeoutException
IProblem
isSatisfiable in interface IProblemisSatisfiable in class SolverDecorator<T extends ISolver>TimeoutException
public boolean isSatisfiable(boolean global)
throws TimeoutException
IProblem
isSatisfiable in interface IProblemisSatisfiable in class SolverDecorator<T extends ISolver>global - whether that call is part of a global process (i.e.
optimization) or not. if (global), the timeout will not be
reset between each call.
TimeoutException
public boolean isSatisfiable(IVecInt assumps)
throws TimeoutException
IProblem
isSatisfiable in interface IProblemisSatisfiable in class SolverDecorator<T extends ISolver>assumps - a set of literals (represented by usual non null integers in
Dimacs format).
TimeoutException
public boolean isSatisfiable(IVecInt assumps,
boolean global)
throws TimeoutException
IProblem
isSatisfiable in interface IProblemisSatisfiable in class SolverDecorator<T extends ISolver>assumps - a set of literals (represented by usual non null integers in
Dimacs format).global - whether that call is part of a global process (i.e.
optimization) or not. if (global), the timeout will not be
reset between each call.
TimeoutExceptionpublic int[] model()
IProblem
model in interface IProblemmodel in class SolverDecorator<T extends ISolver>IProblem.isSatisfiable(),
IProblem.isSatisfiable(IVecInt)public String toString(String prefix)
ISolver
toString in interface ISolvertoString in class SolverDecorator<T extends ISolver>prefix - the prefix to use on each line.
public void setMinimizationStrategy(MinimizationStrategy strategy)
setMinimizationStrategy in interface Explainerpublic boolean removeConstr(IConstr c)
ISolver
removeConstr in interface ISolverremoveConstr in class SolverDecorator<T extends ISolver>c - a constraint returned by one of the add method.
public boolean removeSubsumedConstr(IConstr c)
ISolver
removeSubsumedConstr in interface ISolverremoveSubsumedConstr in class SolverDecorator<T extends ISolver>c - a constraint returned by one of the add method. It must be the
latest constr added to the solver.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||