1 |
| package org.sat4j.minisat.constraints.pb; |
2 |
| |
3 |
| import java.math.BigInteger; |
4 |
| |
5 |
| import org.sat4j.minisat.core.AssertingClauseGenerator; |
6 |
| import org.sat4j.minisat.core.DataStructureFactory; |
7 |
| import org.sat4j.minisat.core.IOrder; |
8 |
| import org.sat4j.minisat.core.LearningStrategy; |
9 |
| import org.sat4j.specs.ContradictionException; |
10 |
| import org.sat4j.specs.IConstr; |
11 |
| import org.sat4j.specs.IVec; |
12 |
| import org.sat4j.specs.IVecInt; |
13 |
| |
14 |
| public class PBSolverWithImpliedClause extends PBSolver { |
15 |
| |
16 |
1
| public PBSolverWithImpliedClause(AssertingClauseGenerator acg,
|
17 |
| LearningStrategy learner, DataStructureFactory dsf, IOrder order) { |
18 |
1
| super(acg, learner, dsf, order);
|
19 |
| } |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| private static final long serialVersionUID = 1L; |
25 |
| |
26 |
0
| public IConstr addPseudoBoolean(IVecInt literals, IVec<BigInteger> coeffs,
|
27 |
| boolean moreThan, BigInteger degree) throws ContradictionException { |
28 |
0
| IVecInt vlits = dimacs2internal(literals);
|
29 |
| assert vlits.size() == literals.size(); |
30 |
| assert literals.size() == coeffs.size(); |
31 |
0
| PBConstr result = (PBConstr) dsfactory.createPseudoBooleanConstraint(
|
32 |
| vlits, coeffs, moreThan, degree); |
33 |
0
| if (result != null) {
|
34 |
0
| IVecInt clits = result.computeAnImpliedClause();
|
35 |
0
| if (clits != null) {
|
36 |
0
| addConstr(dsfactory.createClause(clits));
|
37 |
| } |
38 |
| } |
39 |
0
| return addConstr(result);
|
40 |
| } |
41 |
| |
42 |
0
| @Override
|
43 |
| public String toString(String prefix) { |
44 |
0
| return super.toString(prefix)+"\n"+prefix+"Add implied clauses in preprocessing";
|
45 |
| } |
46 |
| } |