public class ObjectiveReducerPBSolverDecorator extends Object implements IPBSolver
| Constructor and Description |
|---|
ObjectiveReducerPBSolverDecorator(IPBSolver decorated) |
| Modifier and Type | Method and Description |
|---|---|
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 |
addAtLeast(IVecInt literals,
IVec<BigInteger> coeffs,
BigInteger degree)
Create a pseudo-boolean constraint of the type "at least".
|
IConstr |
addAtLeast(IVecInt literals,
IVecInt coeffs,
int degree)
Create a pseudo-boolean constraint of the type "at least".
|
IConstr |
addAtMost(IVecInt literals,
int degree)
Create a cardinality constraint of the type "at most n of those literals
must be satisfied"
|
IConstr |
addAtMost(IVecInt literals,
IVec<BigInteger> coeffs,
BigInteger degree)
Create a pseudo boolean constraint of the type "at most".
|
IConstr |
addAtMost(IVecInt literals,
IVecInt coeffs,
int degree)
Create a pseudo boolean constraint of the type "at most".
|
IConstr |
addBlockingClause(IVecInt literals)
Add a clause in order to prevent an assignment to occur.
|
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".
|
IConstr |
addExactly(IVecInt literals,
IVec<BigInteger> coeffs,
BigInteger weight)
Create a pseudo-boolean constraint of the type "subset sum".
|
IConstr |
addExactly(IVecInt literals,
IVecInt coeffs,
int weight)
Create a pseudo-boolean constraint of the type "subset sum".
|
IConstr |
addPseudoBoolean(IVecInt lits,
IVec<BigInteger> coeffs,
boolean moreThan,
BigInteger d)
Create a Pseudo-Boolean constraint of the type "at least n or at most n
of those literals must be satisfied"
|
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() |
ObjectiveFunction |
getObjectiveFunction()
Retrieve the objective function from the solver.
|
<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 globalTimeout)
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 globalTimeout)
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[] |
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.
|
int[] |
primeImplicant()
Provide a prime implicant, i.e. a set of literal that is sufficient to
satisfy all constraints of the problem.
|
boolean |
primeImplicant(int p)
Check if a given literal is part of the prime implicant computed by the
IProblem.primeImplicant() method. |
void |
printInfos(PrintWriter out)
To print additional informations regarding the problem.
|
void |
printInfos(PrintWriter out,
String prefix)
To print additional informations regarding the problem.
|
void |
printStat(PrintStream out,
String prefix)
Display statistics to the given output stream Please use writers instead
of stream.
|
void |
printStat(PrintWriter out)
Display statistics to the given output writer
|
void |
printStat(PrintWriter out,
String prefix)
Display statistics to the given output writer
|
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.
|
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 |
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.
|
void |
setKeepSolverHot(boolean keepHot)
Changed the behavior of the SAT solver heuristics between successive
calls.
|
void |
setLogPrefix(String prefix)
Set the prefix used to display information.
|
void |
setObjectiveFunction(ObjectiveFunction obj)
Provide an objective function to the solver.
|
<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 |
setVerbose(boolean value)
Set the verbosity of the solver
|
String |
toString(String prefix)
Display a textual representation of the solver configuration.
|
IVecInt |
unsatExplanation()
Retrieve an explanation of the inconsistency in terms of assumption
literals.
|
public ObjectiveReducerPBSolverDecorator(IPBSolver decorated)
public int[] model()
IProblemmodel in interface IProblemIProblem.isSatisfiable(),
IProblem.isSatisfiable(IVecInt)public int newVar()
ISolverpublic IConstr addPseudoBoolean(IVecInt lits, IVec<BigInteger> coeffs, boolean moreThan, BigInteger d) throws ContradictionException
IPBSolveraddPseudoBoolean in interface IPBSolverlits - 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, false if it is a
constraint <= degreed - the degree of the cardinality constraintContradictionException - iff the vector of literals is empty or if the constraint is
falsified after unit propagationISolver.removeConstr(IConstr)public boolean model(int var)
RandomAccessModelmodel in interface RandomAccessModelvar - the variable id in Dimacs format#model()public int nextFreeVarId(boolean reserve)
ISolverISolver.realNumberOfVariables() method.nextFreeVarId in interface ISolverreserve - 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[] primeImplicant()
IProblemprimeImplicant in interface IProblempublic boolean primeImplicant(int p)
IProblemIProblem.primeImplicant() method.primeImplicant in interface IProblemp - a literal in Dimacs formatIProblem.primeImplicant()public IConstr addAtMost(IVecInt literals, IVecInt coeffs, int degree) throws ContradictionException
IPBSolveraddAtMost in interface IPBSolverliterals - 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.degree - the degree of the pseudo-boolean constraintContradictionException - iff the constraint is found trivially unsat.ISolver.removeConstr(IConstr)public boolean isSatisfiable()
throws TimeoutException
IProblemisSatisfiable in interface IProblemTimeoutExceptionpublic boolean isSatisfiable(IVecInt assumps, boolean globalTimeout) throws TimeoutException
IProblemisSatisfiable in interface IProblemassumps - a set of literals (represented by usual non null integers in
Dimacs format).globalTimeout - 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.TimeoutExceptionpublic void registerLiteral(int p)
ISolverregisterLiteral in interface ISolverp - the literal in Dimacs format that should appear in the model.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.IProblem.newVar(int)public IConstr addAtMost(IVecInt literals, IVec<BigInteger> coeffs, BigInteger degree) throws ContradictionException
IPBSolveraddAtMost in interface IPBSolverliterals - 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.degree - the degree of the pseudo-boolean constraintContradictionException - iff the constraint is found trivially unsat.ISolver.removeConstr(IConstr)public boolean isSatisfiable(boolean globalTimeout)
throws TimeoutException
IProblemisSatisfiable in interface IProblemglobalTimeout - 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.TimeoutExceptionpublic IConstr addClause(IVecInt literals) throws ContradictionException
ISolveraddClause in interface ISolverliterals - a set of literalsContradictionException - iff the vector of literals is empty or if it contains only
falsified literals after unit propagationISolver.removeConstr(IConstr)public boolean isSatisfiable(IVecInt assumps) throws TimeoutException
IProblemisSatisfiable in interface IProblemassumps - a set of literals (represented by usual non null integers in
Dimacs format).TimeoutExceptionpublic IConstr addAtLeast(IVecInt literals, IVecInt coeffs, int degree) throws ContradictionException
IPBSolveraddAtLeast in interface IPBSolverliterals - 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.degree - the degree of the pseudo-boolean constraintContradictionException - iff the constraint is found trivially unsat.ISolver.removeConstr(IConstr)public int[] findModel()
throws TimeoutException
IProblem
if (isSatisfiable()) {
return model();
}
return null;
findModel in interface IProblemnull if no model is foundTimeoutException - if a model cannot be found within the given timeout.public IConstr addBlockingClause(IVecInt literals) throws ContradictionException
ISolveraddBlockingClause in interface ISolverContradictionExceptionpublic boolean removeConstr(IConstr c)
ISolverremoveConstr in interface ISolverc - a constraint returned by one of the add method.public int[] findModel(IVecInt assumps) throws TimeoutException
IProblem
if (isSatisfiable(assumpt)) {
return model();
}
return null;
findModel in interface IProblemnull if no model is foundTimeoutException - if a model cannot be found within the given timeout.public IConstr addAtLeast(IVecInt literals, IVec<BigInteger> coeffs, BigInteger degree) throws ContradictionException
IPBSolveraddAtLeast in interface IPBSolverliterals - 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.degree - the degree of the pseudo-boolean constraintContradictionException - iff the constraint is found trivially unsat.ISolver.removeConstr(IConstr)public boolean removeSubsumedConstr(IConstr c)
ISolverremoveSubsumedConstr in interface ISolverc - a constraint returned by one of the add method. It must be the
latest constr added to the solver.public int nConstraints()
IProblemnConstraints in interface IProblempublic int newVar(int howmany)
IProblemhowmany 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 IProblemhowmany - number of variables to createIProblem.nVars()public void addAllClauses(IVec<IVecInt> clauses) throws ContradictionException
ISolveraddAllClauses 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 addExactly(IVecInt literals, IVecInt coeffs, int weight) throws ContradictionException
IPBSolveraddExactly in interface IPBSolverliterals - 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.weight - the number of literals that must be satisfiedContradictionException - iff the constraint is trivially unsatisfiable.public int nVars()
IProblemnVars in interface IProblemIProblem.newVar(int)public void printInfos(PrintWriter out, String prefix)
IProblemprintInfos in interface IProblemout - the place to print the informationprefix - the prefix to put in front of each linepublic IConstr addAtMost(IVecInt literals, int degree) throws ContradictionException
ISolveraddAtMost 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 (n) of the cardinality constraintContradictionException - iff the vector of literals is empty or if it contains more
than degree satisfied literals after unit propagationISolver.removeConstr(IConstr)public IConstr addExactly(IVecInt literals, IVec<BigInteger> coeffs, BigInteger weight) throws ContradictionException
IPBSolveraddExactly in interface IPBSolverliterals - 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.weight - the number of literals that must be satisfiedContradictionException - iff the constraint is trivially unsatisfiable.public void printInfos(PrintWriter out)
IProblemprintInfos in interface IProblemout - the place to print the information#setLogPrefix(String)public IConstr addAtLeast(IVecInt literals, int degree) throws ContradictionException
ISolveraddAtLeast 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 (n) of the cardinality constraintContradictionException - iff the vector of literals is empty or if degree literals are
not remaining unfalsified after unit propagationISolver.removeConstr(IConstr)public void setObjectiveFunction(ObjectiveFunction obj)
IPBSolversetObjectiveFunction in interface IPBSolverobj - the objective functionpublic ObjectiveFunction getObjectiveFunction()
IPBSolvergetObjectiveFunction in interface IPBSolverpublic IConstr addExactly(IVecInt literals, int n) throws ContradictionException
ISolveraddExactly 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.n - the number of literals that must be satisfiedContradictionException - iff the constraint is trivially unsatisfiable.public void setTimeout(int t)
ISolversetTimeout in interface ISolvert - the timeout (in s)public void setTimeoutOnConflicts(int count)
ISolversetTimeoutOnConflicts in interface ISolvercount - the timeout (in number of conflicts)public void setTimeoutMs(long t)
ISolversetTimeoutMs in interface ISolvert - the timeout (in milliseconds)public int getTimeout()
ISolvergetTimeout in interface ISolverpublic long getTimeoutMs()
ISolvergetTimeoutMs in interface ISolverpublic void expireTimeout()
ISolverexpireTimeout in interface ISolverpublic void reset()
ISolverpublic void printStat(PrintStream out, String prefix)
ISolverprintStat in interface ISolverprefix - the prefix to put in front of each lineISolver.printStat(PrintWriter, String)public void printStat(PrintWriter out, String prefix)
ISolverpublic void printStat(PrintWriter out)
ISolverprintStat in interface ISolverISolver.setLogPrefix(String)public Map<String,Number> getStat()
ISolverpublic String toString(String prefix)
ISolverpublic void clearLearntClauses()
ISolverclearLearntClauses in interface ISolverpublic void setDBSimplificationAllowed(boolean status)
ISolversetDBSimplificationAllowed in interface ISolverpublic boolean isDBSimplificationAllowed()
ISolverisDBSimplificationAllowed in interface ISolverpublic <S extends ISolverService> void setSearchListener(SearchListener<S> sl)
ISolversetSearchListener in interface ISolversl - a Search Listener.public <S extends ISolverService> SearchListener<S> getSearchListener()
ISolvergetSearchListener in interface ISolverpublic boolean isVerbose()
ISolverpublic void setVerbose(boolean value)
ISolversetVerbose in interface ISolvervalue - true to allow the solver to output messages on the console,
false either.public void setLogPrefix(String prefix)
ISolversetLogPrefix in interface ISolverprefix - the prefix to be in front of each line of textpublic String getLogPrefix()
getLogPrefix in interface ISolverpublic IVecInt unsatExplanation()
ISolverunsatExplanation in interface ISolverIProblem.isSatisfiable(IVecInt),
IProblem.isSatisfiable(IVecInt, boolean)public int[] modelWithInternalVariables()
ISolvermodelWithInternalVariables in interface ISolverIProblem.model(),
ModelIteratorpublic int realNumberOfVariables()
ISolverISolver.nextFreeVarId(boolean) method.realNumberOfVariables in interface ISolverISolver.nextFreeVarId(boolean)public boolean isSolverKeptHot()
ISolverisSolverKeptHot in interface ISolverpublic void setKeepSolverHot(boolean keepHot)
ISolversetKeepSolverHot in interface ISolverkeepHot - true to keep the heuristics values across calls, false either.public ISolver getSolvingEngine()
ISolvergetSolvingEngine in interface ISolverCopyright © 2013 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.