|
1 |
| package org.sat4j; |
|
2 |
| |
|
3 |
| import java.io.FileNotFoundException; |
|
4 |
| import java.io.IOException; |
|
5 |
| |
|
6 |
| import org.sat4j.minisat.SolverFactory; |
|
7 |
| import org.sat4j.reader.InstanceReader; |
|
8 |
| import org.sat4j.reader.ParseFormatException; |
|
9 |
| import org.sat4j.reader.Reader; |
|
10 |
| import org.sat4j.specs.ContradictionException; |
|
11 |
| import org.sat4j.specs.IProblem; |
|
12 |
| import org.sat4j.specs.ISolver; |
|
13 |
| import org.sat4j.specs.IVecInt; |
|
14 |
| import org.sat4j.specs.TimeoutException; |
|
15 |
| import org.sat4j.tools.RemiUtils; |
|
16 |
| import org.sat4j.tools.SolutionCounter; |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| public class MoreThanSAT { |
|
34 |
| |
|
35 |
0
| public static void main(String[] args) {
|
|
36 |
0
| ISolver solver = SolverFactory.newMiniLearning();
|
|
37 |
0
| SolutionCounter sc = new SolutionCounter(solver);
|
|
38 |
0
| solver.setTimeout(3600);
|
|
39 |
0
| Reader reader = new InstanceReader(solver);
|
|
40 |
| |
|
41 |
| |
|
42 |
0
| try {
|
|
43 |
0
| IProblem problem = reader.parseInstance(args[0]);
|
|
44 |
0
| if (problem.isSatisfiable()) {
|
|
45 |
0
| System.out.println("Satisfiable !");
|
|
46 |
0
| System.out.println(reader.decode(problem.model()));
|
|
47 |
0
| IVecInt backbone = RemiUtils.backbone(solver);
|
|
48 |
0
| System.out.println("BackBone:" + backbone);
|
|
49 |
0
| System.out.println("Counting solutions...");
|
|
50 |
0
| System.out.println("Number of solutions : "
|
|
51 |
| + sc.countSolutions()); |
|
52 |
| } else { |
|
53 |
0
| System.out.println("Unsatisfiable !");
|
|
54 |
| } |
|
55 |
| } catch (FileNotFoundException e) { |
|
56 |
0
| e.printStackTrace();
|
|
57 |
| } catch (ParseFormatException e) { |
|
58 |
0
| e.printStackTrace();
|
|
59 |
| } catch (IOException e) { |
|
60 |
0
| e.printStackTrace();
|
|
61 |
| } catch (ContradictionException e) { |
|
62 |
0
| System.out.println("Unsatisfiable (trivial)!");
|
|
63 |
| } catch (TimeoutException e) { |
|
64 |
0
| System.out.println("Timeout, sorry!");
|
|
65 |
| } |
|
66 |
| } |
|
67 |
| } |