1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.sat4j.pb.core;
29
30 import org.sat4j.minisat.core.AssertingClauseGenerator;
31 import org.sat4j.minisat.core.IOrder;
32 import org.sat4j.minisat.core.LearningStrategy;
33 import org.sat4j.pb.constraints.pb.ConflictMapSwitchToClause;
34 import org.sat4j.pb.constraints.pb.IConflict;
35 import org.sat4j.pb.constraints.pb.PBConstr;
36
37 public class PBSolverCautious extends PBSolverCP {
38
39 private static final long serialVersionUID = 1L;
40 public static final int BOUND = 10;
41
42 public PBSolverCautious(AssertingClauseGenerator acg,
43 LearningStrategy<PBDataStructureFactory> learner,
44 PBDataStructureFactory dsf, IOrder order) {
45 super(acg, learner, dsf, order);
46 ConflictMapSwitchToClause.UPPERBOUND = BOUND;
47 }
48
49 public PBSolverCautious(AssertingClauseGenerator acg,
50 LearningStrategy<PBDataStructureFactory> learner,
51 PBDataStructureFactory dsf, IOrder order, int bound) {
52 super(acg, learner, dsf, order);
53 ConflictMapSwitchToClause.UPPERBOUND = bound;
54 }
55
56 @Override
57 IConflict chooseConflict(PBConstr myconfl, int level) {
58 return ConflictMapSwitchToClause.createConflict(myconfl, level);
59 }
60
61 @Override
62 public String toString(String prefix) {
63 return super.toString(prefix)
64 + "\n"
65 + prefix
66 + "When dealing with too large coefficients, simplify asserted PB constraints to clauses";
67 }
68
69 @Override
70 protected void updateNumberOfReductions(IConflict confl) {
71 stats.numberOfReductions += ((ConflictMapSwitchToClause) confl)
72 .getNumberOfReductions();
73 }
74
75 @Override
76 protected void updateNumberOfReducedLearnedConstraints(IConflict confl) {
77 if (((ConflictMapSwitchToClause) confl).hasBeenReduced())
78 stats.numberOfLearnedConstraintsReduced++;
79 }
80
81 }