1 |
| package org.sat4j.tools; |
2 |
| |
3 |
| import org.sat4j.core.VecInt; |
4 |
| import org.sat4j.specs.ISolver; |
5 |
| import org.sat4j.specs.IVecInt; |
6 |
| import org.sat4j.specs.TimeoutException; |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| public class RemiUtils { |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
0
| public static IVecInt backbone(ISolver s) throws TimeoutException {
|
26 |
0
| IVecInt backbone = new VecInt();
|
27 |
0
| int nvars = s.nVars();
|
28 |
0
| for (int i = 1; i <= nvars; i++) {
|
29 |
0
| backbone.push(i);
|
30 |
0
| if (!s.isSatisfiable(backbone)) {
|
31 |
| |
32 |
0
| backbone.pop().push(-i);
|
33 |
| } else { |
34 |
0
| backbone.pop().push(-i);
|
35 |
0
| if (!s.isSatisfiable(backbone)) {
|
36 |
| |
37 |
0
| backbone.pop().push(i);
|
38 |
| } else { |
39 |
0
| backbone.pop();
|
40 |
| } |
41 |
| } |
42 |
| } |
43 |
0
| return backbone;
|
44 |
| } |
45 |
| |
46 |
| } |