|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package org.sat4j.tools; |
|
8 |
| |
|
9 |
| import java.io.PrintStream; |
|
10 |
| import java.io.Serializable; |
|
11 |
| import java.math.BigInteger; |
|
12 |
| |
|
13 |
| import org.sat4j.specs.ContradictionException; |
|
14 |
| import org.sat4j.specs.IConstr; |
|
15 |
| import org.sat4j.specs.ISolver; |
|
16 |
| import org.sat4j.specs.IVec; |
|
17 |
| import org.sat4j.specs.IVecInt; |
|
18 |
| import org.sat4j.specs.TimeoutException; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| public abstract class SolverDecorator implements ISolver, Serializable { |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
0
| public int getTimeout() {
|
|
36 |
0
| return solver.getTimeout();
|
|
37 |
| } |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
0
| public String toString(String prefix) {
|
|
45 |
0
| return solver.toString(prefix);
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
0
| public void printStat(PrintStream out, String prefix) {
|
|
55 |
0
| solver.printStat(out, prefix);
|
|
56 |
| } |
|
57 |
| |
|
58 |
| private final ISolver solver; |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
3
| public SolverDecorator(ISolver solver) {
|
|
64 |
3
| this.solver = solver;
|
|
65 |
| } |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
0
| public int newVar() {
|
|
73 |
0
| return solver.newVar();
|
|
74 |
| } |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
3
| public int newVar(int howmany) {
|
|
82 |
3
| return solver.newVar(howmany);
|
|
83 |
| } |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
27
| public IConstr addClause(IVecInt literals) throws ContradictionException {
|
|
91 |
27
| return solver.addClause(literals);
|
|
92 |
| } |
|
93 |
| |
|
94 |
0
| public void addAllClauses(IVec<IVecInt> clauses)
|
|
95 |
| throws ContradictionException { |
|
96 |
0
| solver.addAllClauses(clauses);
|
|
97 |
| } |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
13
| public IConstr addAtMost(IVecInt literals, int degree)
|
|
105 |
| throws ContradictionException { |
|
106 |
13
| return solver.addAtMost(literals, degree);
|
|
107 |
| } |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
0
| public IConstr addAtLeast(IVecInt literals, int degree)
|
|
115 |
| throws ContradictionException { |
|
116 |
0
| return solver.addAtLeast(literals, degree);
|
|
117 |
| } |
|
118 |
| |
|
119 |
0
| public IConstr addPseudoBoolean(IVecInt literals, IVec<BigInteger> coeffs,
|
|
120 |
| boolean moreThan, BigInteger degree) throws ContradictionException { |
|
121 |
0
| return solver.addPseudoBoolean(literals, coeffs, moreThan, degree);
|
|
122 |
| } |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| |
|
129 |
34
| public int[] model() {
|
|
130 |
34
| return solver.model();
|
|
131 |
| } |
|
132 |
| |
|
133 |
| |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
32
| public boolean isSatisfiable() throws TimeoutException {
|
|
139 |
32
| return solver.isSatisfiable();
|
|
140 |
| } |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
| |
|
147 |
5
| public boolean isSatisfiable(IVecInt assumps) throws TimeoutException {
|
|
148 |
5
| return solver.isSatisfiable(assumps);
|
|
149 |
| } |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
| |
|
156 |
0
| public void setTimeout(int t) {
|
|
157 |
0
| solver.setTimeout(t);
|
|
158 |
| } |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
0
| public int nConstraints() {
|
|
166 |
0
| return solver.nConstraints();
|
|
167 |
| } |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
52
| public int nVars() {
|
|
175 |
52
| return solver.nVars();
|
|
176 |
| } |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
0
| public void reset() {
|
|
184 |
0
| solver.reset();
|
|
185 |
| } |
|
186 |
| |
|
187 |
0
| public ISolver decorated() {
|
|
188 |
0
| return solver;
|
|
189 |
| } |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
0
| public boolean removeConstr(IConstr c) {
|
|
197 |
0
| return solver.removeConstr(c);
|
|
198 |
| } |
|
199 |
| } |