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 |
|
package org.sat4j; |
26 |
|
|
27 |
|
import java.io.FileNotFoundException; |
28 |
|
import java.io.IOException; |
29 |
|
import java.io.PrintWriter; |
30 |
|
|
31 |
|
import org.sat4j.minisat.SolverFactory; |
32 |
|
import org.sat4j.reader.InstanceReader; |
33 |
|
import org.sat4j.reader.ParseFormatException; |
34 |
|
import org.sat4j.reader.Reader; |
35 |
|
import org.sat4j.specs.ContradictionException; |
36 |
|
import org.sat4j.specs.IProblem; |
37 |
|
import org.sat4j.specs.ISolver; |
38 |
|
import org.sat4j.specs.IVecInt; |
39 |
|
import org.sat4j.specs.TimeoutException; |
40 |
|
import org.sat4j.tools.RemiUtils; |
41 |
|
import org.sat4j.tools.SolutionCounter; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@author |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0,42 |
|
51 |
|
public class MoreThanSAT { |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
58 |
0
|
private MoreThanSAT() {... |
59 |
|
|
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 7 |
Complexity Density: 0,37 |
|
62 |
0
|
public static void main(final String[] args) {... |
63 |
0
|
final ISolver solver = SolverFactory.newMiniLearning(); |
64 |
0
|
final SolutionCounter sc = new SolutionCounter(solver); |
65 |
0
|
solver.setTimeout(3600); |
66 |
0
|
Reader reader = new InstanceReader(solver); |
67 |
|
|
68 |
|
|
69 |
0
|
try { |
70 |
0
|
final IProblem problem = reader.parseInstance(args[0]); |
71 |
0
|
if (problem.isSatisfiable()) { |
72 |
0
|
System.out.println(Messages.getString("MoreThanSAT.0")); |
73 |
0
|
reader.decode(problem.model(), new PrintWriter(System.out)); |
74 |
0
|
IVecInt backbone = RemiUtils.backbone(solver); |
75 |
0
|
System.out |
76 |
|
.println(Messages.getString("MoreThanSAT.1") + backbone); |
77 |
0
|
System.out.println(Messages.getString("MoreThanSAT.2")); |
78 |
0
|
System.out.println(Messages.getString("MoreThanSAT.3") |
79 |
|
+ sc.countSolutions()); |
80 |
|
} else { |
81 |
0
|
System.out.println(Messages.getString("MoreThanSAT.4")); |
82 |
|
} |
83 |
|
} catch (FileNotFoundException e) { |
84 |
0
|
e.printStackTrace(); |
85 |
|
} catch (ParseFormatException e) { |
86 |
0
|
e.printStackTrace(); |
87 |
|
} catch (IOException e) { |
88 |
0
|
e.printStackTrace(); |
89 |
|
} catch (ContradictionException e) { |
90 |
0
|
System.out.println(Messages.getString("MoreThanSAT.5")); |
91 |
|
} catch (TimeoutException e) { |
92 |
0
|
System.out.println(Messages.getString("MoreThanSAT.6")); |
93 |
|
} |
94 |
|
} |
95 |
|
} |