cadical 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +26 -0
  3. data/README.md +101 -0
  4. data/ext/cadical/cadical/LICENSE +28 -0
  5. data/ext/cadical/cadical/README.md +65 -0
  6. data/ext/cadical/cadical/VERSION +1 -0
  7. data/ext/cadical/cadical/src/analyze.cpp +1360 -0
  8. data/ext/cadical/cadical/src/arena.cpp +30 -0
  9. data/ext/cadical/cadical/src/arena.hpp +105 -0
  10. data/ext/cadical/cadical/src/assume.cpp +616 -0
  11. data/ext/cadical/cadical/src/averages.cpp +34 -0
  12. data/ext/cadical/cadical/src/averages.hpp +37 -0
  13. data/ext/cadical/cadical/src/backbone.cpp +631 -0
  14. data/ext/cadical/cadical/src/backtrack.cpp +177 -0
  15. data/ext/cadical/cadical/src/backward.cpp +231 -0
  16. data/ext/cadical/cadical/src/bins.cpp +22 -0
  17. data/ext/cadical/cadical/src/bins.hpp +22 -0
  18. data/ext/cadical/cadical/src/block.cpp +824 -0
  19. data/ext/cadical/cadical/src/block.hpp +37 -0
  20. data/ext/cadical/cadical/src/cadical.cpp +1026 -0
  21. data/ext/cadical/cadical/src/cadical.hpp +1419 -0
  22. data/ext/cadical/cadical/src/ccadical.cpp +208 -0
  23. data/ext/cadical/cadical/src/ccadical.h +74 -0
  24. data/ext/cadical/cadical/src/checker.cpp +649 -0
  25. data/ext/cadical/cadical/src/checker.hpp +173 -0
  26. data/ext/cadical/cadical/src/clause.cpp +689 -0
  27. data/ext/cadical/cadical/src/clause.hpp +190 -0
  28. data/ext/cadical/cadical/src/collect.cpp +545 -0
  29. data/ext/cadical/cadical/src/compact.cpp +550 -0
  30. data/ext/cadical/cadical/src/condition.cpp +940 -0
  31. data/ext/cadical/cadical/src/config.cpp +101 -0
  32. data/ext/cadical/cadical/src/config.hpp +20 -0
  33. data/ext/cadical/cadical/src/congruence.cpp +7880 -0
  34. data/ext/cadical/cadical/src/congruence.hpp +757 -0
  35. data/ext/cadical/cadical/src/constrain.cpp +64 -0
  36. data/ext/cadical/cadical/src/contract.cpp +27 -0
  37. data/ext/cadical/cadical/src/contract.hpp +139 -0
  38. data/ext/cadical/cadical/src/cover.cpp +704 -0
  39. data/ext/cadical/cadical/src/cover.hpp +34 -0
  40. data/ext/cadical/cadical/src/decide.cpp +347 -0
  41. data/ext/cadical/cadical/src/decompose.cpp +738 -0
  42. data/ext/cadical/cadical/src/decompose.hpp +23 -0
  43. data/ext/cadical/cadical/src/deduplicate.cpp +275 -0
  44. data/ext/cadical/cadical/src/definition.cpp +283 -0
  45. data/ext/cadical/cadical/src/delay.hpp +38 -0
  46. data/ext/cadical/cadical/src/drattracer.cpp +153 -0
  47. data/ext/cadical/cadical/src/drattracer.hpp +55 -0
  48. data/ext/cadical/cadical/src/elim.cpp +1171 -0
  49. data/ext/cadical/cadical/src/elim.hpp +53 -0
  50. data/ext/cadical/cadical/src/elimfast.cpp +570 -0
  51. data/ext/cadical/cadical/src/ema.cpp +95 -0
  52. data/ext/cadical/cadical/src/ema.hpp +68 -0
  53. data/ext/cadical/cadical/src/extend.cpp +289 -0
  54. data/ext/cadical/cadical/src/external.cpp +1034 -0
  55. data/ext/cadical/cadical/src/external.hpp +487 -0
  56. data/ext/cadical/cadical/src/external_propagate.cpp +1316 -0
  57. data/ext/cadical/cadical/src/factor.cpp +1011 -0
  58. data/ext/cadical/cadical/src/factor.hpp +54 -0
  59. data/ext/cadical/cadical/src/file.cpp +506 -0
  60. data/ext/cadical/cadical/src/file.hpp +210 -0
  61. data/ext/cadical/cadical/src/flags.cpp +135 -0
  62. data/ext/cadical/cadical/src/flags.hpp +93 -0
  63. data/ext/cadical/cadical/src/flip.cpp +269 -0
  64. data/ext/cadical/cadical/src/format.cpp +89 -0
  65. data/ext/cadical/cadical/src/format.hpp +36 -0
  66. data/ext/cadical/cadical/src/frattracer.cpp +277 -0
  67. data/ext/cadical/cadical/src/frattracer.hpp +67 -0
  68. data/ext/cadical/cadical/src/gates.cpp +766 -0
  69. data/ext/cadical/cadical/src/heap.hpp +212 -0
  70. data/ext/cadical/cadical/src/idruptracer.cpp +566 -0
  71. data/ext/cadical/cadical/src/idruptracer.hpp +112 -0
  72. data/ext/cadical/cadical/src/instantiate.cpp +365 -0
  73. data/ext/cadical/cadical/src/instantiate.hpp +45 -0
  74. data/ext/cadical/cadical/src/internal.cpp +1265 -0
  75. data/ext/cadical/cadical/src/internal.hpp +1941 -0
  76. data/ext/cadical/cadical/src/inttypes.hpp +34 -0
  77. data/ext/cadical/cadical/src/ipasir.cpp +47 -0
  78. data/ext/cadical/cadical/src/ipasir.h +37 -0
  79. data/ext/cadical/cadical/src/kitten.c +2599 -0
  80. data/ext/cadical/cadical/src/kitten.h +97 -0
  81. data/ext/cadical/cadical/src/level.hpp +33 -0
  82. data/ext/cadical/cadical/src/lidruptracer.cpp +657 -0
  83. data/ext/cadical/cadical/src/lidruptracer.hpp +122 -0
  84. data/ext/cadical/cadical/src/limit.cpp +146 -0
  85. data/ext/cadical/cadical/src/limit.hpp +168 -0
  86. data/ext/cadical/cadical/src/logging.cpp +214 -0
  87. data/ext/cadical/cadical/src/logging.hpp +98 -0
  88. data/ext/cadical/cadical/src/lookahead.cpp +520 -0
  89. data/ext/cadical/cadical/src/lratchecker.cpp +833 -0
  90. data/ext/cadical/cadical/src/lratchecker.hpp +168 -0
  91. data/ext/cadical/cadical/src/lrattracer.cpp +200 -0
  92. data/ext/cadical/cadical/src/lrattracer.hpp +61 -0
  93. data/ext/cadical/cadical/src/lucky.cpp +506 -0
  94. data/ext/cadical/cadical/src/message.cpp +218 -0
  95. data/ext/cadical/cadical/src/message.hpp +65 -0
  96. data/ext/cadical/cadical/src/minimize.cpp +224 -0
  97. data/ext/cadical/cadical/src/mobical.cpp +5588 -0
  98. data/ext/cadical/cadical/src/occs.cpp +52 -0
  99. data/ext/cadical/cadical/src/occs.hpp +36 -0
  100. data/ext/cadical/cadical/src/options.cpp +359 -0
  101. data/ext/cadical/cadical/src/options.hpp +442 -0
  102. data/ext/cadical/cadical/src/parse.cpp +471 -0
  103. data/ext/cadical/cadical/src/parse.hpp +75 -0
  104. data/ext/cadical/cadical/src/phases.cpp +56 -0
  105. data/ext/cadical/cadical/src/phases.hpp +19 -0
  106. data/ext/cadical/cadical/src/probe.cpp +990 -0
  107. data/ext/cadical/cadical/src/profile.cpp +107 -0
  108. data/ext/cadical/cadical/src/profile.hpp +283 -0
  109. data/ext/cadical/cadical/src/proof.cpp +691 -0
  110. data/ext/cadical/cadical/src/proof.hpp +125 -0
  111. data/ext/cadical/cadical/src/propagate.cpp +584 -0
  112. data/ext/cadical/cadical/src/queue.cpp +90 -0
  113. data/ext/cadical/cadical/src/queue.hpp +74 -0
  114. data/ext/cadical/cadical/src/radix.hpp +180 -0
  115. data/ext/cadical/cadical/src/random.cpp +207 -0
  116. data/ext/cadical/cadical/src/random.h +44 -0
  117. data/ext/cadical/cadical/src/random.hpp +98 -0
  118. data/ext/cadical/cadical/src/range.hpp +125 -0
  119. data/ext/cadical/cadical/src/reap.cpp +127 -0
  120. data/ext/cadical/cadical/src/reap.hpp +28 -0
  121. data/ext/cadical/cadical/src/reduce.cpp +278 -0
  122. data/ext/cadical/cadical/src/reluctant.hpp +82 -0
  123. data/ext/cadical/cadical/src/rephase.cpp +402 -0
  124. data/ext/cadical/cadical/src/report.cpp +313 -0
  125. data/ext/cadical/cadical/src/resources.cpp +160 -0
  126. data/ext/cadical/cadical/src/resources.hpp +16 -0
  127. data/ext/cadical/cadical/src/restart.cpp +178 -0
  128. data/ext/cadical/cadical/src/restore.cpp +267 -0
  129. data/ext/cadical/cadical/src/score.cpp +51 -0
  130. data/ext/cadical/cadical/src/score.hpp +16 -0
  131. data/ext/cadical/cadical/src/shrink.cpp +507 -0
  132. data/ext/cadical/cadical/src/signal.cpp +136 -0
  133. data/ext/cadical/cadical/src/signal.hpp +33 -0
  134. data/ext/cadical/cadical/src/solution.cpp +50 -0
  135. data/ext/cadical/cadical/src/solver.cpp +1871 -0
  136. data/ext/cadical/cadical/src/stable.cpp +31 -0
  137. data/ext/cadical/cadical/src/stack.h +110 -0
  138. data/ext/cadical/cadical/src/stats.cpp +920 -0
  139. data/ext/cadical/cadical/src/stats.hpp +418 -0
  140. data/ext/cadical/cadical/src/subsume.cpp +645 -0
  141. data/ext/cadical/cadical/src/sweep.cpp +1960 -0
  142. data/ext/cadical/cadical/src/sweep.hpp +61 -0
  143. data/ext/cadical/cadical/src/terminal.cpp +38 -0
  144. data/ext/cadical/cadical/src/terminal.hpp +96 -0
  145. data/ext/cadical/cadical/src/ternary.cpp +450 -0
  146. data/ext/cadical/cadical/src/testing.hpp +24 -0
  147. data/ext/cadical/cadical/src/tier.cpp +189 -0
  148. data/ext/cadical/cadical/src/tracer.hpp +186 -0
  149. data/ext/cadical/cadical/src/transred.cpp +253 -0
  150. data/ext/cadical/cadical/src/unstable.cpp +29 -0
  151. data/ext/cadical/cadical/src/util.cpp +129 -0
  152. data/ext/cadical/cadical/src/util.hpp +181 -0
  153. data/ext/cadical/cadical/src/var.cpp +39 -0
  154. data/ext/cadical/cadical/src/var.hpp +22 -0
  155. data/ext/cadical/cadical/src/veripbtracer.cpp +427 -0
  156. data/ext/cadical/cadical/src/veripbtracer.hpp +106 -0
  157. data/ext/cadical/cadical/src/version.cpp +107 -0
  158. data/ext/cadical/cadical/src/version.hpp +13 -0
  159. data/ext/cadical/cadical/src/vivify.cpp +1893 -0
  160. data/ext/cadical/cadical/src/vivify.hpp +50 -0
  161. data/ext/cadical/cadical/src/walk.cpp +1088 -0
  162. data/ext/cadical/cadical/src/walk.hpp +91 -0
  163. data/ext/cadical/cadical/src/walk_full_occs.cpp +966 -0
  164. data/ext/cadical/cadical/src/warmup.cpp +403 -0
  165. data/ext/cadical/cadical/src/watch.cpp +126 -0
  166. data/ext/cadical/cadical/src/watch.hpp +77 -0
  167. data/ext/cadical/cadical_ext.c +778 -0
  168. data/ext/cadical/extconf.rb +26 -0
  169. data/lib/cadical/version.rb +3 -0
  170. data/lib/cadical.rb +12 -0
  171. metadata +218 -0
@@ -0,0 +1,402 @@
1
+ #include "internal.hpp"
2
+
3
+ namespace CaDiCaL {
4
+
5
+ /*------------------------------------------------------------------------*/
6
+
7
+ // We experimented with resetting and reinitializing the saved phase with
8
+ // many solvers. Actually RSAT had already such a scheme. Our newest
9
+ // version seems to be quite beneficial for satisfiable instances. In an
10
+ // arithmetic increasing interval in the number of conflicts we either use
11
+ // the original phase (set by the option 'phase'), its inverted value, flip
12
+ // the current phase, pick random phases, then pick the best since the last
13
+ // time a best phase was picked and finally also use local search to find
14
+ // phases which minimize the number of falsified clauses. During
15
+ // stabilization (see 'stabilizing' in 'restart.cpp' when 'stable' is true)
16
+ // we execute a different rephasing schedule. The same applies if local
17
+ // search is disabled.
18
+
19
+ /*------------------------------------------------------------------------*/
20
+
21
+ bool Internal::rephasing () {
22
+ if (!opts.rephase)
23
+ return false;
24
+ if (opts.forcephase)
25
+ return false;
26
+ if (opts.rephase == 2) {
27
+ if (stable)
28
+ return stats.stabconflicts > lim.rephase;
29
+ else
30
+ return false;
31
+ }
32
+ return stats.conflicts > lim.rephase;
33
+ }
34
+
35
+ /*------------------------------------------------------------------------*/
36
+
37
+ // Pick the original default phase.
38
+
39
+ char Internal::rephase_original () {
40
+ stats.rephased.original++;
41
+ signed char val = opts.phase ? 1 : -1; // original = initial
42
+ PHASE ("rephase", stats.rephased.total, "switching to original phase %d",
43
+ val);
44
+ for (auto idx : vars)
45
+ phases.saved[idx] = val;
46
+ return 'O';
47
+ }
48
+
49
+ // Pick the inverted original default phase.
50
+
51
+ char Internal::rephase_inverted () {
52
+ stats.rephased.inverted++;
53
+ signed char val = opts.phase ? -1 : 1; // original = -initial
54
+ PHASE ("rephase", stats.rephased.total,
55
+ "switching to inverted original phase %d", val);
56
+ for (auto idx : vars)
57
+ phases.saved[idx] = val;
58
+ return 'I';
59
+ }
60
+
61
+ // Flip the current phase.
62
+
63
+ char Internal::rephase_flipping () {
64
+ stats.rephased.flipped++;
65
+ PHASE ("rephase", stats.rephased.total,
66
+ "flipping all phases individually");
67
+ for (auto idx : vars)
68
+ phases.saved[idx] *= -1;
69
+ return 'F';
70
+ }
71
+
72
+ // Complete random picking of phases.
73
+
74
+ char Internal::rephase_random () {
75
+ stats.rephased.random++;
76
+ PHASE ("rephase", stats.rephased.total, "resetting all phases randomly");
77
+ Random random (opts.seed); // global seed
78
+ random += stats.rephased.random; // different every time
79
+ for (auto idx : vars)
80
+ phases.saved[idx] = random.generate_bool () ? -1 : 1;
81
+ return '#';
82
+ }
83
+
84
+ // Best phases are those saved at the largest trail height without conflict.
85
+ // See code and comments in 'update_target_and_best' in 'backtrack.cpp'
86
+
87
+ char Internal::rephase_best () {
88
+ stats.rephased.best++;
89
+ PHASE ("rephase", stats.rephased.total,
90
+ "overwriting saved phases by best phases");
91
+ signed char val;
92
+ for (auto idx : vars)
93
+ if ((val = phases.best[idx]))
94
+ phases.saved[idx] = val;
95
+ return 'B';
96
+ }
97
+
98
+ // Trigger local search 'walk' in 'walk.cpp'.
99
+
100
+ char Internal::rephase_walk () {
101
+ stats.rephased.walk++;
102
+ PHASE ("rephase", stats.rephased.total,
103
+ "starting local search to improve current phase");
104
+ if (opts.walkfullocc)
105
+ walk_full_occs ();
106
+ else
107
+ walk ();
108
+ return 'W';
109
+ }
110
+
111
+ /*------------------------------------------------------------------------*/
112
+
113
+ void Internal::rephase () {
114
+
115
+ stats.rephased.total++;
116
+ last.stabilize.rephased++;
117
+ assert (last.stabilize.rephased <= stats.rephased.total);
118
+ PHASE ("rephase", stats.rephased.total,
119
+ "reached rephase limit %" PRId64 " after %" PRId64 " conflicts",
120
+ lim.rephase,
121
+ opts.rephase == 2 ? stats.stabconflicts : stats.conflicts);
122
+
123
+ // Report current 'target' and 'best' and then set 'rephased' below, which
124
+ // will trigger reporting the new 'target' and 'best' after updating it in
125
+ // the next 'update_target_and_best' called from the next 'backtrack'.
126
+ //
127
+ report ('~', 1);
128
+
129
+ backtrack ();
130
+
131
+ size_t count = lim.rephased[stable]++;
132
+ bool single;
133
+ char type;
134
+
135
+ if (opts.stabilize && opts.stabilizeonly)
136
+ single = true;
137
+ else
138
+ single = !opts.stabilize;
139
+
140
+ if (single && !opts.walk) {
141
+ // (inverted,best,flipping,best,random,best,original,best)^\omega
142
+ switch (count % 8) {
143
+ case 0:
144
+ type = rephase_inverted ();
145
+ break;
146
+ case 1:
147
+ type = rephase_best ();
148
+ break;
149
+ case 2:
150
+ type = rephase_flipping ();
151
+ break;
152
+ case 3:
153
+ type = rephase_best ();
154
+ break;
155
+ case 4:
156
+ type = rephase_random ();
157
+ break;
158
+ case 5:
159
+ type = rephase_best ();
160
+ break;
161
+ case 6:
162
+ type = rephase_original ();
163
+ break;
164
+ case 7:
165
+ type = rephase_best ();
166
+ break;
167
+ default:
168
+ type = 0;
169
+ break;
170
+ }
171
+ } else if (single && opts.walk) {
172
+ // (inverted,best,walk,
173
+ // flipping,best,walk,
174
+ // random,best,walk,
175
+ // original,best,walk)^\omega
176
+ switch (count % 12) {
177
+ case 0:
178
+ type = rephase_inverted ();
179
+ break;
180
+ case 1:
181
+ type = rephase_best ();
182
+ break;
183
+ case 2:
184
+ type = rephase_walk ();
185
+ break;
186
+ case 3:
187
+ type = rephase_flipping ();
188
+ break;
189
+ case 4:
190
+ type = rephase_best ();
191
+ break;
192
+ case 5:
193
+ type = rephase_walk ();
194
+ break;
195
+ case 6:
196
+ type = rephase_random ();
197
+ break;
198
+ case 7:
199
+ type = rephase_best ();
200
+ break;
201
+ case 8:
202
+ type = rephase_walk ();
203
+ break;
204
+ case 9:
205
+ type = rephase_original ();
206
+ break;
207
+ case 10:
208
+ type = rephase_best ();
209
+ break;
210
+ case 11:
211
+ type = rephase_walk ();
212
+ break;
213
+ default:
214
+ type = 0;
215
+ break;
216
+ }
217
+ } else if (opts.rephase == 2 && opts.walk) {
218
+ // (inverted,best,walk,
219
+ // flipping,best,walk,
220
+ // random,best,walk,
221
+ // original,best,walk)^\omega
222
+ switch (count % 12) {
223
+ case 0:
224
+ type = rephase_inverted ();
225
+ break;
226
+ case 1:
227
+ type = rephase_best ();
228
+ break;
229
+ case 2:
230
+ type = rephase_walk ();
231
+ break;
232
+ case 3:
233
+ type = rephase_flipping ();
234
+ break;
235
+ case 4:
236
+ type = rephase_best ();
237
+ break;
238
+ case 5:
239
+ type = rephase_walk ();
240
+ break;
241
+ case 6:
242
+ type = rephase_random ();
243
+ break;
244
+ case 7:
245
+ type = rephase_best ();
246
+ break;
247
+ case 8:
248
+ type = rephase_walk ();
249
+ break;
250
+ case 9:
251
+ type = rephase_original ();
252
+ break;
253
+ case 10:
254
+ type = rephase_best ();
255
+ break;
256
+ case 11:
257
+ type = rephase_walk ();
258
+ break;
259
+ default:
260
+ type = 0;
261
+ break;
262
+ }
263
+ } else if (stable && !opts.walk) {
264
+ // original,inverted,(best,original,best,inverted)^\omega
265
+ if (!count)
266
+ type = rephase_original ();
267
+ else if (count == 1)
268
+ type = rephase_inverted ();
269
+ else
270
+ switch ((count - 2) % 4) {
271
+ case 0:
272
+ type = rephase_best ();
273
+ break;
274
+ case 1:
275
+ type = rephase_original ();
276
+ break;
277
+ case 2:
278
+ type = rephase_best ();
279
+ break;
280
+ case 3:
281
+ type = rephase_inverted ();
282
+ break;
283
+ default:
284
+ type = 0;
285
+ break;
286
+ }
287
+ } else if (stable && opts.walk) {
288
+ // original,inverted,(best,walk,original,best,walk,inverted)^\omega
289
+ if (!count)
290
+ type = rephase_original ();
291
+ else if (count == 1)
292
+ type = rephase_inverted ();
293
+ else
294
+ switch ((count - 2) % 6) {
295
+ case 0:
296
+ type = rephase_best ();
297
+ break;
298
+ case 1:
299
+ type = rephase_walk ();
300
+ break;
301
+ case 2:
302
+ type = rephase_original ();
303
+ break;
304
+ case 3:
305
+ type = rephase_best ();
306
+ break;
307
+ case 4:
308
+ type = rephase_walk ();
309
+ break;
310
+ case 5:
311
+ type = rephase_inverted ();
312
+ break;
313
+ default:
314
+ type = 0;
315
+ break;
316
+ }
317
+ } else if (!stable && (!opts.walk || !opts.walknonstable)) {
318
+ // flipping,(random,best,flipping,best)^\omega
319
+ if (!count)
320
+ type = rephase_flipping ();
321
+ else
322
+ switch ((count - 1) % 4) {
323
+ case 0:
324
+ type = rephase_random ();
325
+ break;
326
+ case 1:
327
+ type = rephase_best ();
328
+ break;
329
+ case 2:
330
+ type = rephase_flipping ();
331
+ break;
332
+ case 3:
333
+ type = rephase_best ();
334
+ break;
335
+ default:
336
+ type = 0;
337
+ break;
338
+ }
339
+ } else {
340
+ assert (!stable && opts.walk && opts.walknonstable);
341
+ // flipping,(random,best,walk,flipping,best,walk)^\omega
342
+ if (!count)
343
+ type = rephase_original ();
344
+ else
345
+ switch ((count - 1) % 6) {
346
+ case 0:
347
+ type = rephase_random ();
348
+ break;
349
+ case 1:
350
+ type = rephase_best ();
351
+ break;
352
+ case 2:
353
+ type = rephase_walk ();
354
+ break;
355
+ case 3:
356
+ type = rephase_flipping ();
357
+ break;
358
+ case 4:
359
+ type = rephase_best ();
360
+ break;
361
+ case 5:
362
+ type = rephase_walk ();
363
+ break;
364
+ default:
365
+ type = 0;
366
+ break;
367
+ }
368
+ }
369
+ assert (type);
370
+
371
+ // clear after walk such that random walk can still access the target
372
+ // by using the saved phases
373
+ copy_phases (phases.target);
374
+ target_assigned = 0;
375
+
376
+ int64_t delta = opts.rephaseint * (stats.rephased.total + 1);
377
+ lim.rephase =
378
+ (opts.rephase == 2 ? stats.stabconflicts : stats.conflicts) + delta;
379
+
380
+ PHASE ("rephase", stats.rephased.total,
381
+ "new rephase limit %" PRId64 " after %" PRId64 " conflicts",
382
+ lim.rephase, delta);
383
+
384
+ // This will trigger to report the effect of this new set of phases at the
385
+ // 'backtrack' (actually 'update_target_and_best') after the next
386
+ // conflict, as well as resetting 'best_assigned' then to allow to compute
387
+ // a new "best" assignment at that point.
388
+ //
389
+ last.rephase.conflicts = stats.conflicts;
390
+ rephased = type;
391
+
392
+ if (!marked_failed || unsat_constraint) {
393
+ assert (opts.warmup);
394
+ return;
395
+ }
396
+ if (stable)
397
+ shuffle_scores ();
398
+ else
399
+ shuffle_queue ();
400
+ }
401
+
402
+ } // namespace CaDiCaL
@@ -0,0 +1,313 @@
1
+ #include "internal.hpp"
2
+
3
+ namespace CaDiCaL {
4
+
5
+ #ifndef QUIET
6
+
7
+ /*------------------------------------------------------------------------*/
8
+
9
+ // Provide nicely formatted progress report messages while running through
10
+ // the 'report' function below. The code is so complex, because it should
11
+ // be easy to add and remove reporting of certain statistics, while still
12
+ // providing a nicely looking format with automatically aligned headers.
13
+
14
+ /*------------------------------------------------------------------------*\
15
+
16
+ The 'reports' are shown as 'c <char> ...' with '<char>' as follows:
17
+
18
+ i propagated learned unit clause
19
+ O backtracked after phases reset to original phase
20
+ F backtracked after flipping phases
21
+ # backtracked after randomly setting phases
22
+ B backtracked after resetting to best phases
23
+ W backtracked after local search improved phases
24
+ b blocked clause elimination
25
+ G before garbage collection
26
+ C after garbage collection
27
+ / compacted internal literals and remapped external to internal
28
+ c covered clause elimination
29
+ d decomposed binary implication graph and substituted equivalent literals
30
+ 2 removed duplicated binary clauses
31
+ e bounded variable elimination round
32
+ ^ variable elimination bound increased
33
+ I variable instantiation
34
+ [ start of stable search phase
35
+ ] end of stable search phase
36
+ { start of unstable search phase
37
+ } end of unstable search phase
38
+ P preprocessing round (capital 'P')
39
+ L local search round
40
+ * start of solving without the need to restore clauses
41
+ + start of solving before restoring clauses
42
+ r start of solving after restoring clauses
43
+ 1 end of solving returns satisfiable
44
+ 0 end of solving returns unsatisfiable
45
+ ? end of solving due to interrupt
46
+ k binary backbone extraction ('kernel')
47
+ l lucky phase solving
48
+ p failed literal probing round (lower case 'p')
49
+ . before reducing redundant clauses
50
+ f flushed redundant clauses
51
+ - reduced redundant clauses
52
+ ~ start of resetting phases
53
+ R restart
54
+ s subsumed clause removal round
55
+ 3 ternary resolution round
56
+ t transition reduction of binary implication graph
57
+ u vivified tier1 clauses
58
+ v vivified tier2 clauses
59
+ x vivified tier3 clauses
60
+ w vivified irredundant clauses
61
+
62
+ The order of the list follows the occurrences of 'report' in the source
63
+ files, i.e., obtained from "grep 'report (' *.cpp". Note that some of the
64
+ reports are only printed for higher verbosity level (for instance 'R').
65
+
66
+ \*------------------------------------------------------------------------*/
67
+
68
+ struct Report {
69
+
70
+ const char *header;
71
+ char buffer[32];
72
+ int pos;
73
+
74
+ Report (const char *h, int precision, int min, double value);
75
+ Report () {}
76
+
77
+ void print_header (char *line);
78
+ };
79
+
80
+ /*------------------------------------------------------------------------*/
81
+
82
+ void Report::print_header (char *line) {
83
+ int len = strlen (header);
84
+ for (int i = -1, j = pos - (len + 1) / 2 - 3; i < len; i++, j++)
85
+ line[j] = i < 0 ? ' ' : header[i];
86
+ }
87
+
88
+ Report::Report (const char *h, int precision, int min, double value)
89
+ : header (h) {
90
+ char fmt[32];
91
+ if (precision < 0)
92
+ snprintf (fmt, sizeof fmt, "%%.%df", -precision - 1);
93
+ else
94
+ snprintf (fmt, sizeof fmt, "%%.%df", precision);
95
+ snprintf (buffer, sizeof buffer, fmt, value);
96
+ const int width = strlen (buffer);
97
+ if (precision < 0)
98
+ strcat (buffer, "%");
99
+ if (width >= min)
100
+ return;
101
+ if (precision < 0)
102
+ snprintf (fmt, sizeof fmt, "%%%d.%df%%%%", min, -precision - 1);
103
+ else
104
+ snprintf (fmt, sizeof fmt, "%%%d.%df", min, precision);
105
+ snprintf (buffer, sizeof buffer, fmt, value);
106
+ }
107
+
108
+ /*------------------------------------------------------------------------*/
109
+
110
+ // The following statistics are printed in columns, whenever 'report' is
111
+ // called. For instance 'reduce' with prefix '-' will call it. The other
112
+ // more interesting report is due to learning a unit, called iteration, with
113
+ // prefix 'i'. To add another statistics column, add a corresponding line
114
+ // here. If you want to report something else add 'report (..)' functions.
115
+
116
+ #define TIME opts.reportsolve ? solve_time () : time ()
117
+
118
+ #define MB (current_resident_set_size () / (double) (1l << 20))
119
+
120
+ #define REMAINING (percent (active (), stats.variables_original))
121
+
122
+ #define TRAIL (percent (averages.current.trail.slow, max_var))
123
+
124
+ #define TARGET (percent (target_assigned, max_var))
125
+
126
+ #define BEST (percent (best_assigned, max_var))
127
+
128
+ #define REPORTS \
129
+ /* HEADER, PRECISION, MIN, VALUE */ \
130
+ REPORT ("seconds", 2, 5, TIME) \
131
+ REPORT ("MB", 0, 2, MB) \
132
+ REPORT ("level", 0, 2, averages.current.level) \
133
+ REPORT ("reductions", 0, 1, stats.reductions) \
134
+ REPORT ("restarts", 0, 3, stats.restarts) \
135
+ REPORT ("rate", 0, 2, averages.current.decisions) \
136
+ REPORT ("conflicts", 0, 4, stats.conflicts) \
137
+ REPORT ("redundant", 0, 4, stats.current.redundant) \
138
+ REPORT ("size/glue", 1, 2, \
139
+ relative (averages.current.size, averages.current.glue.slow)) \
140
+ REPORT ("size", 0, 1, averages.current.size) \
141
+ REPORT ("glue", 0, 1, averages.current.glue.slow) \
142
+ REPORT ("tier1", 0, 1, tier1[stable]) \
143
+ REPORT ("tier2", 0, 1, tier2[stable]) \
144
+ REPORT ("trail", -1, 2, TRAIL) \
145
+ REPORT ("irredundant", 0, 4, stats.current.irredundant) \
146
+ REPORT ("variables", 0, 3, active ()) \
147
+ REPORT ("remaining", -1, 2, REMAINING)
148
+
149
+ // Note, keep an empty line before this line (because of '\')!
150
+
151
+ #if 0 // ADDITIONAL STATISTICS TO REPORT
152
+
153
+ REPORT("best", -1, 2, BEST) \
154
+ REPORT("target", -1, 2, TARGET) \
155
+ REPORT("maxvar", 0, 2, external->max_var)
156
+
157
+ #endif
158
+
159
+ static const int num_reports = // as compile time constant
160
+ #define REPORT(HEAD, PREC, MIN, EXPR) 1 +
161
+ REPORTS
162
+ #undef REPORT
163
+ 0;
164
+
165
+ /*------------------------------------------------------------------------*/
166
+
167
+ void Internal::report (char type, int verbose) {
168
+ if (!opts.report)
169
+ return;
170
+ #ifdef LOGGING
171
+ if (!opts.log)
172
+ #endif
173
+ if (opts.quiet || (verbose > opts.verbose))
174
+ return;
175
+ if (!reported) {
176
+ assert (!lim.report);
177
+ reported = true;
178
+ MSG ("%stime measured in %s time %s%s", tout.magenta_code (),
179
+ internal->opts.realtime ? "real" : "process",
180
+ internal->opts.reportsolve ? "in solving" : "since initialization",
181
+ tout.normal_code ());
182
+ }
183
+ Report reports[num_reports];
184
+ int n = 0;
185
+ #define REPORT(HEAD, PREC, MIN, EXPR) \
186
+ assert (n < num_reports); \
187
+ reports[n++] = Report (HEAD, PREC, MIN, (double) (EXPR));
188
+ REPORTS
189
+ #undef REPORT
190
+ if (!lim.report) {
191
+ print_prefix ();
192
+ fputc ('\n', stdout);
193
+ int pos = 4;
194
+ for (int i = 0; i < n; i++) {
195
+ int len = strlen (reports[i].buffer);
196
+ reports[i].pos = pos + (len + 1) / 2;
197
+ pos += len + 1;
198
+ }
199
+ const int max_line = pos + 20, nrows = 3;
200
+ char *line = new char[max_line];
201
+ for (int start = 0; start < nrows; start++) {
202
+ int i;
203
+ for (i = 0; i < max_line; i++)
204
+ line[i] = ' ';
205
+ for (i = start; i < n; i += nrows)
206
+ reports[i].print_header (line);
207
+ for (i = max_line - 1; line[i - 1] == ' '; i--)
208
+ ;
209
+ line[i] = 0;
210
+ print_prefix ();
211
+ tout.yellow ();
212
+ fputs (line, stdout);
213
+ tout.normal ();
214
+ fputc ('\n', stdout);
215
+ }
216
+ print_prefix ();
217
+ fputc ('\n', stdout);
218
+ delete[] line;
219
+ lim.report = 19;
220
+ } else
221
+ lim.report--;
222
+ print_prefix ();
223
+ switch (type) {
224
+ case '[':
225
+ case ']':
226
+ tout.magenta (true);
227
+ break;
228
+ case 's':
229
+ case 'b':
230
+ case 'c':
231
+ tout.green (false);
232
+ break;
233
+ case 'e':
234
+ tout.green (true);
235
+ break;
236
+ case 'p':
237
+ case '2':
238
+ case '3':
239
+ case 'u':
240
+ case 'v':
241
+ case 'w':
242
+ case 'x':
243
+ case 'f':
244
+ case '=':
245
+ tout.blue (false);
246
+ break;
247
+ case 't':
248
+ tout.cyan (false);
249
+ break;
250
+ case 'd':
251
+ tout.blue (true);
252
+ break;
253
+ case 'z':
254
+ case '!':
255
+ tout.cyan (true);
256
+ break;
257
+ case '-':
258
+ tout.normal ();
259
+ break;
260
+ case '/':
261
+ tout.yellow (true);
262
+ break;
263
+ case 'a':
264
+ case 'n':
265
+ tout.red (false);
266
+ break;
267
+ case '0':
268
+ case '1':
269
+ case '?':
270
+ case 'i':
271
+ tout.bold ();
272
+ break;
273
+ case 'L':
274
+ case 'P':
275
+ tout.bold ();
276
+ tout.underline ();
277
+ break;
278
+ case '(':
279
+ case ')':
280
+ tout.bold ();
281
+ tout.yellow ();
282
+ break;
283
+ case '{':
284
+ case '}':
285
+ tout.normal ();
286
+ break;
287
+ default:
288
+ break;
289
+ }
290
+ fputc (type, stdout);
291
+ if (stable || type == ']')
292
+ tout.magenta ();
293
+ else if (preprocessing || type == ')')
294
+ tout.bold (), tout.yellow ();
295
+ else if (type != 'L' && type != 'P')
296
+ tout.normal ();
297
+ for (int i = 0; i < n; i++) {
298
+ fputc (' ', stdout);
299
+ fputs (reports[i].buffer, stdout);
300
+ }
301
+ if (stable || type == 'L' || type == 'P' || type == ']')
302
+ tout.normal ();
303
+ fputc ('\n', stdout);
304
+ fflush (stdout);
305
+ }
306
+
307
+ #else // ifndef QUIET
308
+
309
+ void Internal::report (char, int) {}
310
+
311
+ #endif
312
+
313
+ } // namespace CaDiCaL