public abstract class AbstractOutputSolver extends Object implements ISolver
Modifier and Type | Field and Description |
---|---|
protected boolean |
firstConstr |
protected boolean |
fixedNbClauses |
protected int |
nbclauses |
protected int |
nbvars |
Constructor and Description |
---|
AbstractOutputSolver() |
Modifier and Type | Method and Description |
---|---|
void |
addAllClauses(IVec<IVecInt> clauses)
Create clauses from a set of set of literals.
|
IConstr |
addBlockingClause(IVecInt literals)
Add a clause in order to prevent an assignment to occur.
|
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.
|
String |
getLogPrefix() |
<S extends ISolverService> |
getSearchListener()
Get the current SearchListener.
|
ISolver |
getSolvingEngine()
Retrieve the real engine in case the engine is decorated by one or
several decorator.
|
Map<String,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.
|
boolean |
isSolverKeptHot()
Ask to the solver if it is in "hot" mode, meaning that the heuristics is
not reset after call is isSatisfiable().
|
boolean |
isVerbose()
To know if the solver is in verbose mode (output allowed) or not.
|
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(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 |
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.
|
int[] |
primeImplicant()
Provide a prime implicant, i.e. a set of literal that is sufficient to
satisfy all constraints of the problem.
|
void |
printInfos(PrintWriter output,
String prefix)
To print additional informations regarding the problem.
|
void |
printStat(PrintStream output,
String prefix)
Display statistics to the given output stream Please use writers instead
of stream.
|
void |
printStat(PrintWriter output,
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.
|
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 |
setDBSimplificationAllowed(boolean status)
Set whether the solver is allowed to simplify the formula by propagating
the truth value of top level satisfied variables.
|
void |
setKeepSolverHot(boolean value)
Changed the behavior of the SAT solver heuristics between successive
calls.
|
void |
setLogPrefix(String prefix)
Set the prefix used to display information.
|
<S extends ISolverService> |
setSearchListener(SearchListener<S> sl)
Allow the user to hook a listener to the solver to be notified of the
main steps of the search process.
|
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.
|
void |
setUnitClauseProvider(UnitClauseProvider upl)
Allow the solver to ask for unit clauses before each restarts.
|
void |
setVerbose(boolean value)
Set the verbosity of the solver
|
IVecInt |
unsatExplanation()
Retrieve an explanation of the inconsistency in terms of assumption
literals.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAtLeast, addAtMost, addClause, addExactly, modelWithInternalVariables, newVar, nextFreeVarId, printStat, realNumberOfVariables, registerLiteral, reset, setExpectedNumberOfClauses, toString
primeImplicant, printInfos
protected int nbvars
protected int nbclauses
protected boolean fixedNbClauses
protected boolean firstConstr
public boolean removeConstr(IConstr c)
ISolver
removeConstr
in interface ISolver
c
- a constraint returned by one of the add method.public void addAllClauses(IVec<IVecInt> clauses) throws ContradictionException
ISolver
addAllClauses
in interface ISolver
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.ContradictionException
- iff the vector of literals is empty or if it contains only
falsified literals after unit propagationISolver.addClause(IVecInt)
public void setTimeout(int t)
ISolver
setTimeout
in interface ISolver
t
- the timeout (in s)public void setTimeoutMs(long t)
ISolver
setTimeoutMs
in interface ISolver
t
- the timeout (in milliseconds)public int getTimeout()
ISolver
getTimeout
in interface ISolver
public long getTimeoutMs()
ISolver
getTimeoutMs
in interface ISolver
public void expireTimeout()
ISolver
expireTimeout
in interface ISolver
public boolean isSatisfiable(IVecInt assumps, boolean global) throws TimeoutException
IProblem
isSatisfiable
in interface IProblem
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.TimeoutException
public boolean isSatisfiable(boolean global) throws TimeoutException
IProblem
isSatisfiable
in interface IProblem
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 void printInfos(PrintWriter output, String prefix)
IProblem
printInfos
in interface IProblem
output
- the place to print the informationprefix
- the prefix to put in front of each linepublic void setTimeoutOnConflicts(int count)
ISolver
setTimeoutOnConflicts
in interface ISolver
count
- the timeout (in number of conflicts)public boolean isDBSimplificationAllowed()
ISolver
isDBSimplificationAllowed
in interface ISolver
public void setDBSimplificationAllowed(boolean status)
ISolver
setDBSimplificationAllowed
in interface ISolver
public void printStat(PrintStream output, String prefix)
ISolver
printStat
in interface ISolver
prefix
- the prefix to put in front of each lineISolver.printStat(PrintWriter, String)
public void printStat(PrintWriter output, String prefix)
ISolver
public Map<String,Number> getStat()
ISolver
public void clearLearntClauses()
ISolver
clearLearntClauses
in interface ISolver
public int[] model()
IProblem
model
in interface IProblem
IProblem.isSatisfiable()
,
IProblem.isSatisfiable(IVecInt)
public boolean model(int var)
RandomAccessModel
model
in interface RandomAccessModel
var
- the variable id in Dimacs format#model()
public boolean isSatisfiable() throws TimeoutException
IProblem
isSatisfiable
in interface IProblem
TimeoutException
public boolean isSatisfiable(IVecInt assumps) throws TimeoutException
IProblem
isSatisfiable
in interface IProblem
assumps
- 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 IProblem
null
if no model is foundTimeoutException
- 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 IProblem
null
if no model is foundTimeoutException
- if a model cannot be found within the given timeout.public boolean removeSubsumedConstr(IConstr c)
ISolver
removeSubsumedConstr
in interface ISolver
c
- a constraint returned by one of the add method. It must be the
latest constr added to the solver.public IConstr addBlockingClause(IVecInt literals) throws ContradictionException
ISolver
addBlockingClause
in interface ISolver
ContradictionException
public <S extends ISolverService> SearchListener<S> getSearchListener()
ISolver
getSearchListener
in interface ISolver
public <S extends ISolverService> void setSearchListener(SearchListener<S> sl)
ISolver
setSearchListener
in interface ISolver
sl
- a Search Listener.public boolean isVerbose()
ISolver
public void setVerbose(boolean value)
ISolver
setVerbose
in interface ISolver
value
- true to allow the solver to output messages on the console,
false either.public void setLogPrefix(String prefix)
ISolver
setLogPrefix
in interface ISolver
prefix
- the prefix to be in front of each line of textpublic String getLogPrefix()
getLogPrefix
in interface ISolver
public IVecInt unsatExplanation()
ISolver
unsatExplanation
in interface ISolver
IProblem.isSatisfiable(IVecInt)
,
IProblem.isSatisfiable(IVecInt, boolean)
public int[] primeImplicant()
IProblem
primeImplicant
in interface IProblem
public int nConstraints()
IProblem
nConstraints
in interface IProblem
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
howmany
- number of variables to createIProblem.nVars()
public int nVars()
IProblem
nVars
in interface IProblem
IProblem.newVar(int)
public boolean isSolverKeptHot()
ISolver
isSolverKeptHot
in interface ISolver
public void setKeepSolverHot(boolean value)
ISolver
setKeepSolverHot
in interface ISolver
value
- true to keep the heuristics values across calls, false either.public ISolver getSolvingEngine()
ISolver
getSolvingEngine
in interface ISolver
public void setUnitClauseProvider(UnitClauseProvider upl)
ISolver
setUnitClauseProvider
in interface ISolver
upl
- an object able to provide unit clauses.Copyright © 2013 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.