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.tools;
29
30 import java.io.PrintStream;
31 import java.io.PrintWriter;
32 import java.io.Serializable;
33 import java.util.Map;
34
35 import org.sat4j.specs.ContradictionException;
36 import org.sat4j.specs.IConstr;
37 import org.sat4j.specs.ISolver;
38 import org.sat4j.specs.IVec;
39 import org.sat4j.specs.IVecInt;
40 import org.sat4j.specs.TimeoutException;
41
42
43
44
45
46
47
48
49 public abstract class SolverDecorator<T extends ISolver> implements ISolver, Serializable {
50
51
52
53
54 private static final long serialVersionUID = 1L;
55
56 public boolean isDBSimplificationAllowed() {
57 return solver.isDBSimplificationAllowed();
58 }
59
60 public void setDBSimplificationAllowed(boolean status) {
61 solver.setDBSimplificationAllowed(status);
62 }
63
64
65
66
67 public void setTimeoutOnConflicts(int count) {
68 solver.setTimeoutOnConflicts(count);
69 }
70
71
72
73
74 public void printInfos(PrintWriter out, String prefix) {
75 solver.printInfos(out, prefix);
76 }
77
78
79
80
81 public boolean isSatisfiable(boolean global) throws TimeoutException {
82 return solver.isSatisfiable(global);
83 }
84
85
86
87
88 public boolean isSatisfiable(IVecInt assumps, boolean global)
89 throws TimeoutException {
90 return solver.isSatisfiable(assumps, global);
91 }
92
93
94
95
96
97
98 public void clearLearntClauses() {
99 solver.clearLearntClauses();
100 }
101
102
103
104
105
106
107 public int[] findModel() throws TimeoutException {
108 return solver.findModel();
109 }
110
111
112
113
114
115
116 public int[] findModel(IVecInt assumps) throws TimeoutException {
117 return solver.findModel(assumps);
118 }
119
120
121
122
123
124
125 public boolean model(int var) {
126 return solver.model(var);
127 }
128
129 public void setExpectedNumberOfClauses(int nb) {
130 solver.setExpectedNumberOfClauses(nb);
131 }
132
133
134
135
136
137
138 public int getTimeout() {
139 return solver.getTimeout();
140 }
141
142 public long getTimeoutMs() {
143 return solver.getTimeoutMs();
144 }
145
146
147
148
149
150
151 public String toString(String prefix) {
152 return solver.toString(prefix);
153 }
154
155
156
157
158
159
160
161 @Deprecated
162 public void printStat(PrintStream out, String prefix) {
163 solver.printStat(out, prefix);
164 }
165
166 public void printStat(PrintWriter out, String prefix) {
167 solver.printStat(out, prefix);
168 }
169
170 private T solver;
171
172
173
174
175 public SolverDecorator(T solver) {
176 this.solver = solver;
177 }
178
179 @Deprecated
180 public int newVar() {
181 return solver.newVar();
182 }
183
184
185
186
187
188
189 public int newVar(int howmany) {
190 return solver.newVar(howmany);
191 }
192
193
194
195
196
197
198 public IConstr addClause(IVecInt literals) throws ContradictionException {
199 return solver.addClause(literals);
200 }
201
202 public void addAllClauses(IVec<IVecInt> clauses)
203 throws ContradictionException {
204 solver.addAllClauses(clauses);
205 }
206
207
208
209
210
211
212 public IConstr addAtMost(IVecInt literals, int degree)
213 throws ContradictionException {
214 return solver.addAtMost(literals, degree);
215 }
216
217
218
219
220
221
222 public IConstr addAtLeast(IVecInt literals, int degree)
223 throws ContradictionException {
224 return solver.addAtLeast(literals, degree);
225 }
226
227
228
229
230
231
232 public int[] model() {
233 return solver.model();
234 }
235
236
237
238
239
240
241 public boolean isSatisfiable() throws TimeoutException {
242 return solver.isSatisfiable();
243 }
244
245
246
247
248
249
250 public boolean isSatisfiable(IVecInt assumps) throws TimeoutException {
251 return solver.isSatisfiable(assumps);
252 }
253
254
255
256
257
258
259 public void setTimeout(int t) {
260 solver.setTimeout(t);
261 }
262
263
264
265
266
267
268 public void setTimeoutMs(long t) {
269 solver.setTimeoutMs(t);
270 }
271
272
273
274
275
276
277 public void expireTimeout() {
278 solver.expireTimeout();
279 }
280
281
282
283
284
285
286 public int nConstraints() {
287 return solver.nConstraints();
288 }
289
290
291
292
293
294
295 public int nVars() {
296 return solver.nVars();
297 }
298
299
300
301
302
303
304 public void reset() {
305 solver.reset();
306 }
307
308 public T decorated() {
309 return solver;
310 }
311
312
313
314
315
316
317
318 public T clearDecorated() {
319 T decorated = solver;
320 solver = null;
321 return decorated;
322 }
323
324
325
326
327
328
329 public boolean removeConstr(IConstr c) {
330 return solver.removeConstr(c);
331 }
332
333
334
335
336
337
338 public Map<String, Number> getStat() {
339 return solver.getStat();
340 }
341
342 }