1 package org.sat4j.pb.tools;
2
3 import java.io.FileNotFoundException;
4 import java.io.FileOutputStream;
5 import java.io.PrintStream;
6
7 import org.sat4j.pb.constraints.pb.PBConstr;
8 import org.sat4j.specs.IConstr;
9 import org.sat4j.specs.Lbool;
10 import org.sat4j.specs.SearchListener;
11
12 public class ConflictTracing implements SearchListener {
13
14 private static final long serialVersionUID = 1L;
15
16 private final String filename;
17 private PrintStream out;
18 private long index = 1;
19
20 public ConflictTracing(String filename) {
21 this.filename = filename;
22 updateWriter();
23 }
24
25 private void updateWriter() {
26 try {
27 out = new PrintStream(new FileOutputStream(filename + ".dat"));
28 } catch (FileNotFoundException e) {
29 out = System.out;
30 }
31 }
32
33 public void adding(int p) {
34
35
36 }
37
38 public void assuming(int p) {
39
40
41 }
42
43 public void backjump(int backjumpLevel) {
44
45
46 }
47
48 public void backtracking(int p) {
49
50
51 }
52
53 public void beginLoop() {
54
55
56 }
57
58 public void conflictFound(IConstr confl, int dlevel, int trailLevel) {
59
60
61 }
62
63 public void conflictFound(int p) {
64
65
66 }
67
68 public void delete(int[] clause) {
69
70
71 }
72
73 public void end(Lbool result) {
74 out.close();
75 }
76
77 public void learn(IConstr c) {
78 PBConstr myConstr = (PBConstr) c;
79 if (myConstr.size() > 0) {
80 out.printf("%d %d %d\n", index++, myConstr.getCoef(0), myConstr
81 .size());
82 }
83 }
84
85 public void propagating(int p, IConstr reason) {
86
87
88 }
89
90 public void restarting() {
91
92
93 }
94
95 public void solutionFound() {
96
97
98 }
99
100 public void start() {
101
102
103 }
104
105 }