org.sat4j.pb
Class PseudoBitsAdderDecorator

java.lang.Object
  extended by org.sat4j.tools.SolverDecorator<IPBSolver>
      extended by org.sat4j.pb.PseudoBitsAdderDecorator
All Implemented Interfaces:
Serializable, IPBSolver, IProblem, ISolver

public class PseudoBitsAdderDecorator
extends SolverDecorator<IPBSolver>
implements IPBSolver

A decorator that computes minimal pseudo boolean models.

Author:
daniel
See Also:
Serialized Form

Constructor Summary
PseudoBitsAdderDecorator(IPBSolver solver)
           
 
Method Summary
 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, 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 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"
 ObjectiveFunction getObjectiveFunction()
          Retrieve the objective function from the solver.
 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.
static void main(String[] args)
           
 void setObjectiveFunction(ObjectiveFunction objf)
          Provide an objective function to the solver.
 
Methods inherited from class org.sat4j.tools.SolverDecorator
addAllClauses, addAtLeast, addAtMost, addBlockingClause, addClause, addExactly, clearDecorated, clearLearntClauses, decorated, expireTimeout, findModel, findModel, getLogPrefix, getSearchListener, getStat, getTimeout, getTimeoutMs, isDBSimplificationAllowed, isSatisfiable, isSatisfiable, isVerbose, model, model, modelWithInternalVariables, nConstraints, newVar, newVar, nextFreeVarId, nVars, primeImplicant, printInfos, printStat, printStat, realNumberOfVariables, registerLiteral, removeConstr, removeSubsumedConstr, reset, setDBSimplificationAllowed, setExpectedNumberOfClauses, setLogPrefix, setSearchListener, setTimeout, setTimeoutMs, setTimeoutOnConflicts, setVerbose, toString, toString, unsatExplanation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.sat4j.specs.ISolver
addAllClauses, addAtLeast, addAtMost, addBlockingClause, addClause, addExactly, clearLearntClauses, expireTimeout, getLogPrefix, getSearchListener, getStat, getTimeout, getTimeoutMs, isDBSimplificationAllowed, isVerbose, modelWithInternalVariables, newVar, nextFreeVarId, printStat, printStat, realNumberOfVariables, registerLiteral, removeConstr, removeSubsumedConstr, reset, setDBSimplificationAllowed, setExpectedNumberOfClauses, setLogPrefix, setSearchListener, setTimeout, setTimeoutMs, setTimeoutOnConflicts, setVerbose, toString, unsatExplanation
 
Methods inherited from interface org.sat4j.specs.IProblem
findModel, findModel, isSatisfiable, isSatisfiable, model, model, nConstraints, newVar, nVars, primeImplicant, printInfos
 

Constructor Detail

PseudoBitsAdderDecorator

public PseudoBitsAdderDecorator(IPBSolver solver)
Method Detail

setObjectiveFunction

public void setObjectiveFunction(ObjectiveFunction objf)
Description copied from interface: IPBSolver
Provide an objective function to the solver.

Specified by:
setObjectiveFunction in interface IPBSolver
Parameters:
objf - the objective function

isSatisfiable

public boolean isSatisfiable()
                      throws TimeoutException
Description copied from interface: IProblem
Check the satisfiability of the set of constraints contained inside the solver.

Specified by:
isSatisfiable in interface IProblem
Overrides:
isSatisfiable in class SolverDecorator<IPBSolver>
Returns:
true if the set of constraints is satisfiable, else false.
Throws:
TimeoutException

isSatisfiable

public boolean isSatisfiable(IVecInt assumps)
                      throws TimeoutException
Description copied from interface: IProblem
Check the satisfiability of the set of constraints contained inside the solver.

Specified by:
isSatisfiable in interface IProblem
Overrides:
isSatisfiable in class SolverDecorator<IPBSolver>
Parameters:
assumps - a set of literals (represented by usual non null integers in Dimacs format).
Returns:
true if the set of constraints is satisfiable when literals are satisfied, else false.
Throws:
TimeoutException

main

public static void main(String[] args)

addPseudoBoolean

public IConstr addPseudoBoolean(IVecInt lits,
                                IVec<BigInteger> coeffs,
                                boolean moreThan,
                                BigInteger d)
                         throws ContradictionException
Description copied from interface: IPBSolver
Create a Pseudo-Boolean constraint of the type "at least n or at most n of those literals must be satisfied"

Specified by:
addPseudoBoolean in interface IPBSolver
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, false 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:
ISolver.removeConstr(IConstr)

getObjectiveFunction

public ObjectiveFunction getObjectiveFunction()
Description copied from interface: IPBSolver
Retrieve the objective function from the solver.

Specified by:
getObjectiveFunction in interface IPBSolver
Returns:
the objective function

addAtMost

public IConstr addAtMost(IVecInt literals,
                         IVecInt coeffs,
                         int degree)
                  throws ContradictionException
Description copied from interface: IPBSolver
Create a pseudo boolean constraint of the type "at most".

Specified by:
addAtMost in interface IPBSolver
Parameters:
literals - 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 constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the constraint is found trivially unsat.
See Also:
ISolver.removeConstr(IConstr)

addAtMost

public IConstr addAtMost(IVecInt literals,
                         IVec<BigInteger> coeffs,
                         BigInteger degree)
                  throws ContradictionException
Description copied from interface: IPBSolver
Create a pseudo boolean constraint of the type "at most".

Specified by:
addAtMost in interface IPBSolver
Parameters:
literals - 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 constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the constraint is found trivially unsat.
See Also:
ISolver.removeConstr(IConstr)

addAtLeast

public IConstr addAtLeast(IVecInt literals,
                          IVecInt coeffs,
                          int degree)
                   throws ContradictionException
Description copied from interface: IPBSolver
Create a pseudo-boolean constraint of the type "at least".

Specified by:
addAtLeast in interface IPBSolver
Parameters:
literals - 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 constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the constraint is found trivially unsat.
See Also:
ISolver.removeConstr(IConstr)

addAtLeast

public IConstr addAtLeast(IVecInt literals,
                          IVec<BigInteger> coeffs,
                          BigInteger degree)
                   throws ContradictionException
Description copied from interface: IPBSolver
Create a pseudo-boolean constraint of the type "at least".

Specified by:
addAtLeast in interface IPBSolver
Parameters:
literals - 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 constraint
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the constraint is found trivially unsat.
See Also:
ISolver.removeConstr(IConstr)

addExactly

public IConstr addExactly(IVecInt literals,
                          IVecInt coeffs,
                          int weight)
                   throws ContradictionException
Description copied from interface: IPBSolver
Create a pseudo-boolean constraint of the type "subset sum".

Specified by:
addExactly in interface IPBSolver
Parameters:
literals - 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 satisfied
Returns:
a reference to the constraint added to the solver. It might return an object representing a group of constraints.
Throws:
ContradictionException - iff the constraint is trivially unsatisfiable.

addExactly

public IConstr addExactly(IVecInt literals,
                          IVec<BigInteger> coeffs,
                          BigInteger weight)
                   throws ContradictionException
Description copied from interface: IPBSolver
Create a pseudo-boolean constraint of the type "subset sum".

Specified by:
addExactly in interface IPBSolver
Parameters:
literals - 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 satisfied
Returns:
a reference to the constraint added to the solver. It might return an object representing a group of constraints.
Throws:
ContradictionException - iff the constraint is trivially unsatisfiable.


Copyright © 2011 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.