|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sat4j.tools.DimacsStringSolver
public class DimacsStringSolver
Solver used to write down a CNF into a String. It is especially useful compared to the DimacsOutputSolver because the number of clauses does not need to be known in advance.
| Constructor Summary | |
|---|---|
DimacsStringSolver()
|
|
DimacsStringSolver(int initSize)
|
|
| Method Summary | |
|---|---|
void |
addAllClauses(IVec<IVecInt> clauses)
Create clauses from a set of set of literals. |
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. |
void |
clearLearntClauses()
Remove clauses learned during the solving process. |
void |
expireTimeout()
Expire the timeout of the solver. |
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. |
java.lang.StringBuffer |
getOut()
|
java.util.Map<java.lang.String,java.lang.Number> |
getStat()
To obtain a map of the available statistics from the solver. |
int |
getTimeout()
Useful to check the internal timeout of the solver. |
long |
getTimeoutMs()
Useful to check the internal timeout of the solver. |
boolean |
isDBSimplificationAllowed()
Indicate whether the solver is allowed to simplify the formula by propagating the truth value of top level satisfied variables. |
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[] |
model()
Provide a model (if any) for a satisfiable formula. |
boolean |
model(int var)
Provide the truth value of a specific variable in the model. |
int |
nConstraints()
To know the number of constraints currently available in the solver. |
int |
newVar()
Create a new variable in the solver (and thus in the vocabulary). |
int |
newVar(int howmany)
Create howmany variables in the solver (and thus in the
vocabulary). |
int |
nVars()
To know the number of variables used in the solver. |
void |
printInfos(java.io.PrintWriter output,
java.lang.String prefix)
To print additional informations regarding the problem. |
void |
printStat(java.io.PrintStream output,
java.lang.String prefix)
Display statistics to the given output stream Please use writers instead of stream. |
void |
printStat(java.io.PrintWriter output,
java.lang.String prefix)
Display statistics to the given output writer |
boolean |
removeConstr(IConstr c)
Remove a constraint returned by one of the add method from the solver. |
void |
reset()
Clean up the internal state of the solver. |
void |
setDBSimplificationAllowed(boolean status)
Set whether the solver is allowed to simplify the formula by propagating the truth value of top level satisfied variables. |
void |
setExpectedNumberOfClauses(int nb)
To inform the solver of the expected number of clauses to read. |
protected void |
setNbVars(int howmany)
|
void |
setTimeout(int t)
To set the internal timeout of the solver. |
void |
setTimeoutMs(long t)
To set the internal timeout of the solver. |
void |
setTimeoutOnConflicts(int count)
To set the internal timeout of the solver. |
java.lang.String |
toString()
|
java.lang.String |
toString(java.lang.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 |
| Constructor Detail |
|---|
public DimacsStringSolver()
public DimacsStringSolver(int initSize)
| Method Detail |
|---|
public java.lang.StringBuffer getOut()
public int newVar()
ISolver
newVar in interface ISolverpublic int newVar(int howmany)
ISolverhowmany variables in the solver (and thus in the
vocabulary).
newVar in interface ISolverhowmany - number of variables to create
protected void setNbVars(int howmany)
public void setExpectedNumberOfClauses(int nb)
ISolverp cnf line is
read in dimacs formatted input file.
Note that this method is supposed to be called AFTER a call to newVar(int)
setExpectedNumberOfClauses in interface ISolvernb - the expected number of clauses.ISolver.newVar(int)
public IConstr addClause(IVecInt literals)
throws ContradictionException
ISolver
addClause in interface ISolverliterals - a set of literals
ContradictionException - iff the vector of literals is empty or if it contains only
falsified literals after unit propagationISolver.removeConstr(IConstr)public boolean removeConstr(IConstr c)
ISolver
removeConstr in interface ISolverc - a constraint returned by one of the add method.
public void addAllClauses(IVec<IVecInt> clauses)
throws ContradictionException
ISolver
addAllClauses in interface ISolverclauses - a vector of set (VecInt) of literals in the dimacs format. The
vector can be reused since the solver is not supposed to keep
a reference to that vector.
ContradictionException - iff the vector of literals is empty or if it contains only
falsified literals after unit propagationISolver.addClause(IVecInt)
public IConstr addAtMost(IVecInt literals,
int degree)
throws ContradictionException
ISolver
addAtMost in interface ISolverliterals - 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 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 IConstr addAtLeast(IVecInt literals,
int degree)
throws ContradictionException
ISolver
addAtLeast in interface ISolverliterals - 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 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 void setTimeout(int t)
ISolver
setTimeout in interface ISolvert - the timeout (in s)public void setTimeoutMs(long t)
ISolver
setTimeoutMs in interface ISolvert - the timeout (in milliseconds)public int getTimeout()
ISolver
getTimeout in interface ISolverpublic long getTimeoutMs()
ISolver
getTimeoutMs in interface ISolverpublic void reset()
ISolver
reset in interface ISolver
public void printStat(java.io.PrintStream output,
java.lang.String prefix)
ISolver
printStat in interface ISolverprefix - the prefix to put in front of each lineISolver.printStat(PrintWriter, String)
public void printStat(java.io.PrintWriter output,
java.lang.String prefix)
ISolver
printStat in interface ISolverprefix - the prefix to put in front of each linepublic java.util.Map<java.lang.String,java.lang.Number> getStat()
ISolver
getStat in interface ISolverpublic java.lang.String toString(java.lang.String prefix)
ISolver
toString in interface ISolverprefix - the prefix to use on each line.
public void clearLearntClauses()
ISolver
clearLearntClauses in interface ISolverpublic int[] model()
IProblem
model in interface IProblemIProblem.isSatisfiable(),
IProblem.isSatisfiable(IVecInt)public boolean model(int var)
IProblem
model in interface IProblemvar - the variable id in Dimacs format
IProblem.model()
public boolean isSatisfiable()
throws TimeoutException
IProblem
isSatisfiable in interface IProblemTimeoutException
public boolean isSatisfiable(IVecInt assumps)
throws TimeoutException
IProblem
isSatisfiable in interface IProblemassumps - a set of literals (represented by usual non null integers
in Dimacs format).
TimeoutException
public int[] findModel()
throws TimeoutException
IProblem
if (isSatisfiable()) {
return model();
}
return null;
findModel in interface IProblemnull 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 IProblemnull if no model is found
TimeoutException - if a model cannot be found within the given timeout.public int nConstraints()
IProblem
nConstraints in interface IProblempublic int nVars()
IProblem
nVars in interface IProblempublic java.lang.String toString()
toString in class java.lang.Objectpublic void expireTimeout()
ISolver
expireTimeout in interface ISolver
public boolean isSatisfiable(IVecInt assumps,
boolean global)
throws TimeoutException
IProblem
isSatisfiable in interface IProblemassumps - 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.
TimeoutException
public boolean isSatisfiable(boolean global)
throws TimeoutException
IProblem
isSatisfiable in interface IProblemglobal - 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 void printInfos(java.io.PrintWriter output,
java.lang.String prefix)
IProblem
printInfos in interface IProblemoutput - the place to print the informationprefix - the prefix to put in front of each linepublic void setTimeoutOnConflicts(int count)
ISolver
setTimeoutOnConflicts in interface ISolvercount - the timeout (in number of counflicts)public boolean isDBSimplificationAllowed()
ISolver
isDBSimplificationAllowed in interface ISolverpublic void setDBSimplificationAllowed(boolean status)
ISolver
setDBSimplificationAllowed in interface ISolver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||