org.sat4j.specs
Interface ISolver

All Superinterfaces:
IProblem
All Known Implementing Classes:
Minimal4CardinalityModel, Minimal4InclusionModel, ModelIterator, PBSolver, SolutionCounter, Solver, SolverDecorator

public interface ISolver
extends IProblem

That interface contains all the services available on a SAT solver.

Author:
leberre

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.
 IConstr addPseudoBoolean(IVecInt lits, IVec<java.math.BigInteger> coeffs, boolean moreThan, java.math.BigInteger d)
          Create a Pseudo-Boolean constraint of the type "at least n of those literals must be satisfied"
 int getTimeout()
          Useful to check the internal timeout of 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).
 void printStat(java.io.PrintStream out, java.lang.String prefix)
          Display statistics to the given output stream
 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 setTimeout(int t)
          To set the internal timeout of the solver.
 java.lang.String toString(java.lang.String prefix)
          Display a textual representation of the solver configuration.
 
Methods inherited from interface org.sat4j.specs.IProblem
isSatisfiable, isSatisfiable, model, nConstraints, nVars
 

Method Detail

newVar

int newVar()
Create a new variable in the solver (and thus in the vocabulary). WE STRONGLY ENCOURAGE TO PRECOMPUTE THE NUMBER OF VARIABLES NEEDED AND TO USE newVar(howmany) INSTEAD. IF YOU EXPERIENCE A PROBLEM OF EFFICIENCY WHEN READING/BUILDING YOUR SAT INSTANCE, PLEASE CHECK THAT YOU ARE NOT USING THAT METHOD.

Returns:
the number of variables available in the vocabulary, which is the identifier of the new variable.

newVar

int newVar(int howmany)
Create howmany variables in the solver (and thus in the vocabulary).

Parameters:
howmany - number of variables to create
Returns:
the total number of variables available in the solver (the highest variable number)

addClause

IConstr addClause(IVecInt literals)
                  throws ContradictionException
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. (clasical Dimacs way of representing literals).

Parameters:
literals - a set of literals
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the vector of literals is empty or if it contains only falsified literals after unit propagation
See Also:
removeConstr(IConstr)

removeConstr

boolean removeConstr(IConstr c)
Remove a constraint returned by one of the add method from the solver. All learnt clauses will be cleared.

Parameters:
c - a constraint returned by one of the add method.
Returns:
true if the constraint was sucessfully removed.

addAllClauses

void addAllClauses(IVec<IVecInt> clauses)
                   throws ContradictionException
Create clauses from a set of set of literals. This is convenient to create in a single call all the clauses (mandatory for the distributed version of the solver). It is mainly a loop to addClause().

Parameters:
clauses - 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.
Throws:
ContradictionException - iff the vector of literals is empty or if it contains only falsified literals after unit propagation
See Also:
addClause(IVecInt)

addAtMost

IConstr addAtMost(IVecInt literals,
                  int degree)
                  throws ContradictionException
Create a cardinality constraint of the type "at most n of those literals must be satisfied"

Parameters:
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 of the cardinality constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the vector of literals is empty or if it contains more than degree satisfied literals after unit propagation
See Also:
removeConstr(IConstr)

addAtLeast

IConstr addAtLeast(IVecInt literals,
                   int degree)
                   throws ContradictionException
Create a cardinality constraint of the type "at least n of those literals must be satisfied"

Parameters:
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 of the cardinality constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the vector of literals is empty or if degree literals are not remaining unfalsified after unit propagation
See Also:
removeConstr(IConstr)

addPseudoBoolean

IConstr addPseudoBoolean(IVecInt lits,
                         IVec<java.math.BigInteger> coeffs,
                         boolean moreThan,
                         java.math.BigInteger d)
                         throws ContradictionException
Create a Pseudo-Boolean constraint of the type "at least n of those literals must be satisfied"

Parameters:
lits - a set of literals. The vector can be reused since the solver is not supposed to keep a reference to that vector.
coeffs - the coefficients of the literals. The vector can be reused since the solver is not supposed to keep a reference to that vector.
moreThan - true if it is a constraint >= degree
d - the degree of the cardinality constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the vector of literals is empty or if the constraint is falsified after unit propagation
See Also:
removeConstr(IConstr)

setTimeout

void setTimeout(int t)
To set the internal timeout of the solver. When the timeout is reached, a timeout exception is launched by the solver.

Parameters:
t - the timeout (in s)

getTimeout

int getTimeout()
Useful to check the internal timeout of the solver.

Returns:
the internal timeout of the solver (in second)

reset

void reset()
Clean up the internal state of the solver.


printStat

void printStat(java.io.PrintStream out,
               java.lang.String prefix)
Display statistics to the given output stream

Parameters:
out -
prefix - the prefix to put in front of each line

toString

java.lang.String toString(java.lang.String prefix)
Display a textual representation of the solver configuration.

Parameters:
prefix - the prefix to use on each line.
Returns:
a textual description of the solver internals.