public class ModelIterator extends SolverDecorator<ISolver>
ISolver solver = new ModelIterator(SolverFactory.OneSolver());
boolean unsat = true;
while (solver.isSatisfiable()) {
unsat = false;
int[] model = solver.model();
// do something with model
}
if (unsat) {
// UNSAT case
}
It is also possible to limit the number of models returned:
ISolver solver = new ModelIterator(SolverFactory.OneSolver(), 10);will return at most 10 models.
| Constructor and Description |
|---|
ModelIterator(ISolver solver)
Create an iterator over the solutions available in
solver. |
ModelIterator(ISolver solver,
long bound)
Create an iterator over a limited number of solutions available in
solver. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isSatisfiable()
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.
|
int[] |
model()
Provide a model (if any) for a satisfiable formula.
|
long |
numberOfModelsFoundSoFar()
To know the number of models already found.
|
int[] |
primeImplicant()
Provide a prime implicant, i.e. a set of literal that is sufficient to
satisfy all constraints of the problem.
|
void |
reset()
Clean up the internal state of the solver.
|
addAllClauses, addAtLeast, addAtMost, addBlockingClause, addClause, addExactly, clearDecorated, clearLearntClauses, decorated, expireTimeout, findModel, findModel, getLogPrefix, getSearchListener, getSolvingEngine, getStat, getTimeout, getTimeoutMs, isDBSimplificationAllowed, isSatisfiable, isSatisfiable, isSolverKeptHot, isVerbose, model, modelWithInternalVariables, nConstraints, newVar, newVar, nextFreeVarId, nVars, primeImplicant, printInfos, printInfos, printStat, printStat, printStat, realNumberOfVariables, registerLiteral, removeConstr, removeSubsumedConstr, setDBSimplificationAllowed, setExpectedNumberOfClauses, setKeepSolverHot, setLogPrefix, setSearchListener, setTimeout, setTimeoutMs, setTimeoutOnConflicts, setUnitClauseProvider, setVerbose, toString, toString, unsatExplanationpublic ModelIterator(ISolver solver)
solver.
The iterator will look for one new model at each call to isSatisfiable()
and will discard that model at each call to model().solver - a solver containing the constraints to satisfy.isSatisfiable(),
SolverDecorator.isSatisfiable(boolean),
isSatisfiable(IVecInt),
SolverDecorator.isSatisfiable(IVecInt, boolean),
model()public ModelIterator(ISolver solver, long bound)
solver. The iterator will look for one new model at each
call to isSatisfiable() and will discard that model at each call to
model(). At most bound calls to models() will be allowed
before the method isSatisfiable() returns false.solver - a solver containing the constraints to satisfy.bound - the maximum number of models to return.isSatisfiable(),
SolverDecorator.isSatisfiable(boolean),
isSatisfiable(IVecInt),
SolverDecorator.isSatisfiable(IVecInt, boolean),
model()public int[] model()
IProblemmodel in interface IProblemmodel in class SolverDecorator<ISolver>IProblem.isSatisfiable(),
IProblem.isSatisfiable(IVecInt)public boolean isSatisfiable()
throws TimeoutException
IProblemisSatisfiable in interface IProblemisSatisfiable in class SolverDecorator<ISolver>TimeoutExceptionpublic boolean isSatisfiable(IVecInt assumps) throws TimeoutException
IProblemisSatisfiable in interface IProblemisSatisfiable in class SolverDecorator<ISolver>assumps - a set of literals (represented by usual non null integers in
Dimacs format).TimeoutExceptionpublic void reset()
ISolverreset in interface ISolverreset in class SolverDecorator<ISolver>public int[] primeImplicant()
IProblemprimeImplicant in interface IProblemprimeImplicant in class SolverDecorator<ISolver>public long numberOfModelsFoundSoFar()
Copyright © 2013 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.