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