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 package org.sat4j.minisat.constraints;
27
28 import java.io.Serializable;
29 import java.math.BigInteger;
30
31 import org.sat4j.core.Vec;
32 import org.sat4j.minisat.core.Constr;
33 import org.sat4j.minisat.core.DataStructureFactory;
34 import org.sat4j.minisat.core.ILits;
35 import org.sat4j.minisat.core.Learner;
36 import org.sat4j.minisat.core.Propagatable;
37 import org.sat4j.minisat.core.UnitPropagationListener;
38 import org.sat4j.specs.ContradictionException;
39 import org.sat4j.specs.IVec;
40 import org.sat4j.specs.IVecInt;
41
42
43
44
45
46 public abstract class AbstractDataStructureFactory<L extends ILits> implements
47 DataStructureFactory<L>, Serializable {
48
49
50
51
52
53
54 public void conflictDetectedInWatchesFor(int p, int i) {
55 for (int j = i + 1; j < tmp.size(); j++) {
56 lits.watch(p, tmp.get(j));
57 }
58 }
59
60
61
62
63
64
65 public IVec<Propagatable> getWatchesFor(int p) {
66 tmp.clear();
67 lits.watches(p).moveTo(tmp);
68 return tmp;
69 }
70
71 protected L lits;
72
73 protected AbstractDataStructureFactory() {
74 lits = createLits();
75 }
76
77 protected abstract L createLits();
78
79 private final IVec<Propagatable> tmp = new Vec<Propagatable>();
80
81
82
83
84
85
86 public L getVocabulary() {
87 return lits;
88 }
89
90 protected UnitPropagationListener solver;
91
92 protected Learner learner;
93
94 public void setUnitPropagationListener(UnitPropagationListener s) {
95 solver = s;
96 }
97
98 public void setLearner(Learner learner) {
99 this.learner = learner;
100 }
101
102 public void reset() {
103 }
104
105 public void learnConstraint(Constr constr) {
106 learner.learn(constr);
107 }
108
109
110
111
112
113
114
115 public Constr createCardinalityConstraint(IVecInt literals, int degree)
116 throws ContradictionException {
117 throw new UnsupportedOperationException();
118 }
119
120
121
122
123
124
125
126 public Constr createPseudoBooleanConstraint(IVecInt literals,
127 IVec<BigInteger> coefs, boolean moreThan, BigInteger degree)
128 throws ContradictionException {
129 throw new UnsupportedOperationException();
130 }
131
132 public Constr createUnregisteredPseudoBooleanConstraint(IVecInt literals,
133 IVec<BigInteger> coefs, BigInteger degree) {
134 throw new UnsupportedOperationException();
135 }
136
137 }