|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package org.sat4j.minisat.constraints; |
|
8 |
| |
|
9 |
| import java.io.Serializable; |
|
10 |
| import java.math.BigInteger; |
|
11 |
| |
|
12 |
| import org.sat4j.core.Vec; |
|
13 |
| import org.sat4j.minisat.constraints.cnf.Lits; |
|
14 |
| import org.sat4j.minisat.constraints.cnf.WLClause; |
|
15 |
| import org.sat4j.minisat.core.Constr; |
|
16 |
| import org.sat4j.minisat.core.DataStructureFactory; |
|
17 |
| import org.sat4j.minisat.core.ILits; |
|
18 |
| import org.sat4j.minisat.core.Learner; |
|
19 |
| import org.sat4j.minisat.core.Propagatable; |
|
20 |
| import org.sat4j.minisat.core.UnitPropagationListener; |
|
21 |
| import org.sat4j.specs.ContradictionException; |
|
22 |
| import org.sat4j.specs.IVec; |
|
23 |
| import org.sat4j.specs.IVecInt; |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| public abstract class AbstractDataStructureFactory implements |
|
30 |
| DataStructureFactory, Serializable { |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
87931153
| public void conflictDetectedInWatchesFor(int p, int i) {
|
|
38 |
87931153
| for (int j = i + 1; j < tmp.size(); j++) {
|
|
39 |
294311363
| lits.watch(p, tmp.get(j));
|
|
40 |
| } |
|
41 |
| } |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
1939353630
| public IVec<Propagatable> getWatchesFor(int p) {
|
|
49 |
1939353630
| tmp.clear();
|
|
50 |
1939353630
| lits.watches(p).moveTo(tmp);
|
|
51 |
1939353630
| return tmp;
|
|
52 |
| } |
|
53 |
| |
|
54 |
| protected ILits lits = new Lits(); |
|
55 |
| |
|
56 |
| private final IVec<Propagatable> tmp = new Vec<Propagatable>(); |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
171411370
| public ILits getVocabulary() {
|
|
64 |
171411370
| return lits;
|
|
65 |
| } |
|
66 |
| |
|
67 |
| protected UnitPropagationListener solver; |
|
68 |
| |
|
69 |
| protected Learner learner; |
|
70 |
| |
|
71 |
2031
| public void setUnitPropagationListener(UnitPropagationListener s) {
|
|
72 |
2031
| solver = s;
|
|
73 |
| } |
|
74 |
| |
|
75 |
2031
| public void setLearner(Learner learner) {
|
|
76 |
2031
| this.learner = learner;
|
|
77 |
| } |
|
78 |
| |
|
79 |
1334
| public void reset() {
|
|
80 |
1334
| WLClause.resetIds();
|
|
81 |
| } |
|
82 |
| |
|
83 |
18353541
| public void learnConstraint(Constr constr) {
|
|
84 |
18353541
| learner.learn(constr);
|
|
85 |
| } |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
0
| public Constr createCardinalityConstraint(IVecInt literals, int degree)
|
|
94 |
| throws ContradictionException { |
|
95 |
0
| throw new UnsupportedOperationException();
|
|
96 |
| } |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
0
| public Constr createPseudoBooleanConstraint(IVecInt literals,
|
|
105 |
| IVec<BigInteger> coefs, boolean moreThan, BigInteger degree) |
|
106 |
| throws ContradictionException { |
|
107 |
0
| throw new UnsupportedOperationException();
|
|
108 |
| } |
|
109 |
| |
|
110 |
0
| public Constr createUnregisteredPseudoBooleanConstraint(IVecInt literals,
|
|
111 |
| IVec<BigInteger> coefs, BigInteger degree) { |
|
112 |
0
| throw new UnsupportedOperationException();
|
|
113 |
| } |
|
114 |
| |
|
115 |
| } |