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
26
27
28
29
30 package org.sat4j.tools;
31
32 import org.sat4j.specs.IConstr;
33 import org.sat4j.specs.ISolverService;
34 import org.sat4j.specs.Lbool;
35
36
37
38
39 public class ConflictDepthTracing extends SearchListenerAdapter<ISolverService> {
40
41
42
43
44 private static final long serialVersionUID = 1L;
45
46
47
48
49 private int counter;
50 private int nVar;
51
52 private final IVisualizationTool conflictDepthVisu;
53 private final IVisualizationTool conflictDepthRestartVisu;
54 private final IVisualizationTool conflictDepthCleanVisu;
55
56
57
58
59
60
61 public ConflictDepthTracing(IVisualizationTool conflictDepthVisu,
62 IVisualizationTool conflictDepthRestartVisu,
63 IVisualizationTool conflictDepthCleanVisu) {
64 this.conflictDepthVisu = conflictDepthVisu;
65 this.conflictDepthRestartVisu = conflictDepthRestartVisu;
66 this.conflictDepthCleanVisu = conflictDepthCleanVisu;
67 this.counter = 0;
68 }
69
70 @Override
71 public void conflictFound(IConstr confl, int dlevel, int trailLevel) {
72 this.conflictDepthVisu.addPoint(this.counter, trailLevel);
73 this.conflictDepthRestartVisu.addInvisiblePoint(this.counter,
74 trailLevel);
75 this.conflictDepthCleanVisu.addInvisiblePoint(this.counter, trailLevel);
76 this.counter++;
77 }
78
79 @Override
80 public void end(Lbool result) {
81 this.conflictDepthVisu.end();
82 this.conflictDepthRestartVisu.end();
83 this.conflictDepthCleanVisu.end();
84 }
85
86 @Override
87 public void start() {
88 this.conflictDepthVisu.init();
89 this.conflictDepthRestartVisu.init();
90 this.conflictDepthCleanVisu.init();
91 this.counter = 0;
92 }
93
94 @Override
95 public void restarting() {
96 this.conflictDepthRestartVisu.addPoint(this.counter, this.nVar);
97 this.conflictDepthCleanVisu.addPoint(this.counter, 0);
98 this.conflictDepthVisu.addInvisiblePoint(this.counter, this.nVar);
99 }
100
101 @Override
102 public void init(ISolverService solverService) {
103 this.nVar = solverService.nVars();
104 }
105
106 @Override
107 public void cleaning() {
108 this.conflictDepthRestartVisu.addPoint(this.counter, 0);
109 this.conflictDepthCleanVisu.addPoint(this.counter, this.nVar);
110 this.conflictDepthVisu.addInvisiblePoint(this.counter, this.nVar);
111 }
112 }