|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sat4j.tools.AbstractOutputSolver org.sat4j.tools.DimacsOutputSolver
public class DimacsOutputSolver
Solver used to display in a writer the CNF instance in Dimacs format. That solver is useful to produce CNF files to be used by third party solvers.
Field Summary |
---|
Fields inherited from class org.sat4j.tools.AbstractOutputSolver |
---|
firstConstr, fixedNbClauses, nbclauses, nbvars |
Constructor Summary | |
---|---|
DimacsOutputSolver()
|
|
DimacsOutputSolver(PrintWriter pw)
|
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". |
int[] |
modelWithInternalVariables()
That method is designed to be used to retrieve the real model of the current set of constraints, i.e. to provide the truth value of boolean variables used internally in the solver (for encoding purposes for instance). |
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)
Declare howmany variables in the problem (and thus in the
vocabulary), that will be represented using the Dimacs format by integers
ranging from 1 to howmany. |
int |
nextFreeVarId(boolean reserve)
Ask the solver for a free variable identifier, in Dimacs format (i.e. a positive number). |
int |
nVars()
To know the number of variables used in the solver as declared by newVar() In case the method newVar() has not been used, the method returns the number of variables used in the solver. |
boolean |
primeImplicant(int p)
Check if a given literal is part of the prime implicant computed by the IProblem.primeImplicant() method. |
int |
realNumberOfVariables()
Retrieve the real number of variables used in the solver. |
void |
registerLiteral(int p)
Tell the solver to consider that the literal is in the CNF. |
void |
reset()
Clean up the internal state of the solver. |
void |
setExpectedNumberOfClauses(int nb)
To inform the solver of the expected number of clauses to read. |
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, toString, wait, wait, wait |
Constructor Detail |
---|
public DimacsOutputSolver()
public DimacsOutputSolver(PrintWriter pw)
Method Detail |
---|
public int newVar()
ISolver
public int newVar(int howmany)
IProblem
howmany
variables in the problem (and thus in the
vocabulary), that will be represented using the Dimacs format by integers
ranging from 1 to howmany. That feature allows encodings to create
additional variables with identifier starting at howmany+1.
newVar
in interface IProblem
newVar
in class AbstractOutputSolver
howmany
- number of variables to create
IProblem.nVars()
public void setExpectedNumberOfClauses(int nb)
ISolver
p cnf
line is
read in dimacs formatted input file.
Note that this method is supposed to be called AFTER a call to
newVar(int)
nb
- the expected number of clauses.IProblem.newVar(int)
public IConstr addClause(IVecInt literals) throws ContradictionException
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)
public IConstr addAtMost(IVecInt literals, int degree) throws ContradictionException
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 IConstr addAtLeast(IVecInt literals, int degree) throws ContradictionException
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 addExactly(IVecInt literals, int n) throws ContradictionException
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 void reset()
ISolver
public String toString(String prefix)
ISolver
prefix
- the prefix to use on each line.
public int nConstraints()
IProblem
nConstraints
in interface IProblem
nConstraints
in class AbstractOutputSolver
public int nVars()
IProblem
nVars
in interface IProblem
nVars
in class AbstractOutputSolver
IProblem.newVar(int)
public int nextFreeVarId(boolean reserve)
ISolver
ISolver.realNumberOfVariables()
method.
reserve
- if true, the maxVarId is updated in the solver, i.e.
successive calls to nextFreeVarId(true) will return increasing
variable id while successive calls to nextFreeVarId(false)
will always answer the same.
ISolver.realNumberOfVariables()
public int[] modelWithInternalVariables()
ISolver
IProblem.model()
,
ModelIterator
public int realNumberOfVariables()
ISolver
ISolver.nextFreeVarId(boolean)
method.
ISolver.nextFreeVarId(boolean)
public void registerLiteral(int p)
ISolver
p
- the literal in Dimacs format that should appear in the model.public boolean primeImplicant(int p)
IProblem
IProblem.primeImplicant()
method.
p
- a literal in Dimacs format
IProblem.primeImplicant()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |