|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sat4j.tools.SolverDecorator<IPBSolver>
org.sat4j.pb.PBSolverDecorator
org.sat4j.maxsat.WeightedMaxSatDecorator
public class WeightedMaxSatDecorator
A decorator for solving weighted MAX SAT problems. The first value of the list of literals in the addClause() method contains the weight of the clause.
Field Summary | |
---|---|
protected int |
nbnewvar
|
protected int |
nborigvars
|
protected boolean[] |
prevboolmodel
|
protected int[] |
prevfullmodel
|
protected int[] |
prevmodel
|
static BigInteger |
SAT4J_MAX_BIG_INTEGER
|
protected BigInteger |
top
|
Constructor Summary | |
---|---|
WeightedMaxSatDecorator(IPBSolver solver)
|
Method Summary | |
---|---|
IConstr |
addClause(IVecInt literals)
Add a set of literals to the solver. |
IConstr |
addHardClause(IVecInt literals)
Add a hard clause in the solver, i.e. a clause that must be satisfied. |
void |
addLiteralsToMinimize(IVecInt literals)
Set some literals whose sum must be minimized. |
IConstr |
addSoftClause(BigInteger weight,
IVecInt literals)
|
IConstr |
addSoftClause(int weight,
IVecInt literals)
Add a soft clause to the solver. |
IConstr |
addSoftClause(IVecInt literals)
Add a soft clause in the solver, i.e. a clause with a weight of 1. |
void |
addWeightedLiteralsToMinimize(IVecInt literals,
IVec<BigInteger> coefficients)
Set some literals whose sum must be minimized. |
void |
addWeightedLiteralsToMinimize(IVecInt literals,
IVecInt coefficients)
Set some literals whose sum must be minimized. |
boolean |
admitABetterSolution()
Look for a solution of the optimization problem. |
boolean |
admitABetterSolution(IVecInt assumps)
Look for a solution of the optimization problem when some literals are satisfied. |
Number |
calculateObjective()
Compute the value of the objective function for the current solution. |
void |
discard()
Discard the current solution in the optimization problem. |
void |
discardCurrentSolution()
Discard the current solution in the optimization problem. |
void |
forceObjectiveValueTo(Number forcedValue)
Force the value of the objective function. |
Number |
getObjectiveValue()
Read only access to the value of the objective function for the current solution. |
boolean |
hasNoObjectiveFunction()
If the optimization problem has no objective function, then it is a simple decision problem. |
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 |
newVar(int howmany)
Create howmany variables in the solver (and thus in the
vocabulary). |
boolean |
nonOptimalMeansSatisfiable()
A suboptimal solution has different meaning depending of the optimization problem considered. |
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. |
void |
setTopWeight(BigInteger top)
|
Methods inherited from class org.sat4j.pb.PBSolverDecorator |
---|
addPseudoBoolean, getObjectiveFunction, setObjectiveFunction |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.sat4j.specs.IProblem |
---|
findModel, findModel, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, nConstraints, nVars, printInfos |
Methods inherited from interface org.sat4j.specs.ISolver |
---|
addAllClauses, addAtLeast, addAtMost, addBlockingClause, clearLearntClauses, expireTimeout, getLogPrefix, getSearchListener, getStat, getTimeout, getTimeoutMs, isDBSimplificationAllowed, isVerbose, newVar, nextFreeVarId, printStat, printStat, removeConstr, removeSubsumedConstr, setDBSimplificationAllowed, setLogPrefix, setSearchListener, setTimeout, setTimeoutMs, setTimeoutOnConflicts, setVerbose, toString, unsatExplanation |
Field Detail |
---|
public static final BigInteger SAT4J_MAX_BIG_INTEGER
protected int nborigvars
protected int nbnewvar
protected int[] prevmodel
protected boolean[] prevboolmodel
protected int[] prevfullmodel
protected BigInteger top
Constructor Detail |
---|
public WeightedMaxSatDecorator(IPBSolver solver)
Method Detail |
---|
public int newVar(int howmany)
ISolver
howmany
variables in the solver (and thus in the
vocabulary).
newVar
in interface ISolver
newVar
in class SolverDecorator<IPBSolver>
howmany
- number of variables to create
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)
setExpectedNumberOfClauses
in interface ISolver
setExpectedNumberOfClauses
in class SolverDecorator<IPBSolver>
nb
- the expected number of clauses.ISolver.newVar(int)
public int[] model()
IProblem
model
in interface IProblem
model
in class SolverDecorator<IPBSolver>
IProblem.isSatisfiable()
,
IProblem.isSatisfiable(IVecInt)
public boolean model(int var)
IProblem
model
in interface IProblem
model
in class SolverDecorator<IPBSolver>
var
- the variable id in Dimacs format
IProblem.model()
public void setTopWeight(BigInteger top)
public IConstr addClause(IVecInt literals) throws ContradictionException
addClause
in interface ISolver
addClause
in class SolverDecorator<IPBSolver>
literals
- a weighted clause, the weight being the first element of the
vector.
ContradictionException
- iff the vector of literals is empty or if it contains only
falsified literals after unit propagation#setTopWeight(int)
public IConstr addHardClause(IVecInt literals) throws ContradictionException
literals
- the clause
ContradictionException
public IConstr addSoftClause(IVecInt literals) throws ContradictionException
literals
- the clause.
ContradictionException
public IConstr addSoftClause(int weight, IVecInt literals) throws ContradictionException
weight
- the weight of the clauseliterals
- the clause
ContradictionException
public IConstr addSoftClause(BigInteger weight, IVecInt literals) throws ContradictionException
ContradictionException
public void addLiteralsToMinimize(IVecInt literals)
literals
- the sum of those literals must be minimized.public void addWeightedLiteralsToMinimize(IVecInt literals, IVec<BigInteger> coefficients)
literals
- the sum of those literals must be minimized.coefficients
- the weight of the literals.public void addWeightedLiteralsToMinimize(IVecInt literals, IVecInt coefficients)
literals
- the sum of those literals must be minimized.coefficients
- the weight of the literals.public boolean admitABetterSolution() throws TimeoutException
IOptimizationProblem
admitABetterSolution
in interface IOptimizationProblem
TimeoutException
- if the solver cannot answer in reasonable time.ISolver.setTimeout(int)
public boolean admitABetterSolution(IVecInt assumps) throws TimeoutException
IOptimizationProblem
admitABetterSolution
in interface IOptimizationProblem
assumps
- a set of literals in Dimacs format.
TimeoutException
- if the solver cannot answer in reasonable time.ISolver.setTimeout(int)
public void reset()
ISolver
reset
in interface ISolver
reset
in class SolverDecorator<IPBSolver>
public boolean hasNoObjectiveFunction()
IOptimizationProblem
hasNoObjectiveFunction
in interface IOptimizationProblem
public boolean nonOptimalMeansSatisfiable()
IOptimizationProblem
nonOptimalMeansSatisfiable
in interface IOptimizationProblem
public Number calculateObjective()
IOptimizationProblem
calculateObjective
in interface IOptimizationProblem
IOptimizationProblem.getObjectiveValue()
public void discardCurrentSolution() throws ContradictionException
IOptimizationProblem
discardCurrentSolution
in interface IOptimizationProblem
ContradictionException
- if a trivial inconsistency is detected.public Number getObjectiveValue()
IOptimizationProblem
getObjectiveValue
in interface IOptimizationProblem
public void discard() throws ContradictionException
IOptimizationProblem
discard
in interface IOptimizationProblem
ContradictionException
- if a trivial inconsistency is detected.IOptimizationProblem.discardCurrentSolution()
public void forceObjectiveValueTo(Number forcedValue) throws ContradictionException
IOptimizationProblem
forceObjectiveValueTo
in interface IOptimizationProblem
ContradictionException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |