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