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 java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.Collection;
35 import java.util.List;
36
37 import org.sat4j.specs.IConstr;
38 import org.sat4j.specs.ISolverService;
39 import org.sat4j.specs.Lbool;
40 import org.sat4j.specs.RandomAccessModel;
41 import org.sat4j.specs.SearchListener;
42
43
44
45
46
47
48
49 public class MultiTracing<T extends ISolverService> implements
50 SearchListener<T> {
51
52
53
54
55 private static final long serialVersionUID = 1L;
56
57 private final Collection<SearchListener<T>> listeners = new ArrayList<SearchListener<T>>();
58
59 public MultiTracing(SearchListener<T>... listeners) {
60 this.listeners.addAll(Arrays.asList(listeners));
61 }
62
63 public MultiTracing(List<SearchListener<T>> listenersList) {
64 this.listeners.addAll(listenersList);
65 }
66
67 public void assuming(int p) {
68 for (SearchListener<T> sl : this.listeners) {
69 sl.assuming(p);
70 }
71
72 }
73
74 public void propagating(int p, IConstr reason) {
75 for (SearchListener<T> sl : this.listeners) {
76 sl.propagating(p, reason);
77 }
78
79 }
80
81 public void backtracking(int p) {
82 for (SearchListener<T> sl : this.listeners) {
83 sl.backtracking(p);
84 }
85 }
86
87 public void adding(int p) {
88 for (SearchListener<T> sl : this.listeners) {
89 sl.adding(p);
90 }
91
92 }
93
94 public void learn(IConstr c) {
95 for (SearchListener<T> sl : this.listeners) {
96 sl.learn(c);
97 }
98
99 }
100
101 public void delete(int[] clause) {
102 for (SearchListener<T> sl : this.listeners) {
103 sl.delete(clause);
104 }
105
106 }
107
108 public void conflictFound(IConstr confl, int dlevel, int trailLevel) {
109 for (SearchListener<T> sl : this.listeners) {
110 sl.conflictFound(confl, dlevel, trailLevel);
111 }
112
113 }
114
115 public void conflictFound(int p) {
116 for (SearchListener<T> sl : this.listeners) {
117 sl.conflictFound(p);
118 }
119
120 }
121
122 public void solutionFound(int[] model, RandomAccessModel lazyModel) {
123 for (SearchListener<T> sl : this.listeners) {
124 sl.solutionFound(model, lazyModel);
125 }
126
127 }
128
129 public void beginLoop() {
130 for (SearchListener<T> sl : this.listeners) {
131 sl.beginLoop();
132 }
133 }
134
135 public void start() {
136 for (SearchListener<T> sl : this.listeners) {
137 sl.start();
138 }
139
140 }
141
142 public void end(Lbool result) {
143 for (SearchListener<T> sl : this.listeners) {
144 sl.end(result);
145 }
146 }
147
148 public void restarting() {
149 for (SearchListener<T> sl : this.listeners) {
150 sl.restarting();
151 }
152
153 }
154
155 public void backjump(int backjumpLevel) {
156 for (SearchListener<T> sl : this.listeners) {
157 sl.backjump(backjumpLevel);
158 }
159
160 }
161
162 public void init(T solverService) {
163 for (SearchListener<T> sl : this.listeners) {
164 sl.init(solverService);
165 }
166 }
167
168 public void cleaning() {
169 for (SearchListener<T> sl : this.listeners) {
170 sl.cleaning();
171 }
172 }
173
174 }