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 learnUnit(int p) {
102 for (SearchListener<T> sl : this.listeners) {
103 sl.learnUnit(p);
104 }
105 }
106
107 public void delete(int[] clause) {
108 for (SearchListener<T> sl : this.listeners) {
109 sl.delete(clause);
110 }
111
112 }
113
114 public void conflictFound(IConstr confl, int dlevel, int trailLevel) {
115 for (SearchListener<T> sl : this.listeners) {
116 sl.conflictFound(confl, dlevel, trailLevel);
117 }
118
119 }
120
121 public void conflictFound(int p) {
122 for (SearchListener<T> sl : this.listeners) {
123 sl.conflictFound(p);
124 }
125
126 }
127
128 public void solutionFound(int[] model, RandomAccessModel lazyModel) {
129 for (SearchListener<T> sl : this.listeners) {
130 sl.solutionFound(model, lazyModel);
131 }
132
133 }
134
135 public void beginLoop() {
136 for (SearchListener<T> sl : this.listeners) {
137 sl.beginLoop();
138 }
139 }
140
141 public void start() {
142 for (SearchListener<T> sl : this.listeners) {
143 sl.start();
144 }
145
146 }
147
148 public void end(Lbool result) {
149 for (SearchListener<T> sl : this.listeners) {
150 sl.end(result);
151 }
152 }
153
154 public void restarting() {
155 for (SearchListener<T> sl : this.listeners) {
156 sl.restarting();
157 }
158
159 }
160
161 public void backjump(int backjumpLevel) {
162 for (SearchListener<T> sl : this.listeners) {
163 sl.backjump(backjumpLevel);
164 }
165
166 }
167
168 public void init(T solverService) {
169 for (SearchListener<T> sl : this.listeners) {
170 sl.init(solverService);
171 }
172 }
173
174 public void cleaning() {
175 for (SearchListener<T> sl : this.listeners) {
176 sl.cleaning();
177 }
178 }
179
180 }