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 package org.sat4j.minisat.core;
29
30 import java.io.PrintWriter;
31 import java.io.Serializable;
32 import java.lang.reflect.Field;
33 import java.util.HashMap;
34 import java.util.Map;
35
36
37
38
39
40
41
42 public class SolverStats implements Serializable {
43 private static final long serialVersionUID = 1L;
44
45 public int starts;
46
47 public long decisions;
48
49 public long propagations;
50
51 public long inspects;
52
53 public long conflicts;
54
55 public long learnedliterals;
56
57 public long learnedbinaryclauses;
58
59 public long learnedternaryclauses;
60
61 public long learnedclauses;
62
63 public long ignoredclauses;
64
65 public long rootSimplifications;
66
67 public long reducedliterals;
68
69 public long changedreason;
70
71 public int reduceddb;
72
73 public int shortcuts;
74
75 public void reset() {
76 starts = 0;
77 decisions = 0;
78 propagations = 0;
79 inspects = 0;
80 shortcuts = 0;
81 conflicts = 0;
82 learnedliterals = 0;
83 learnedclauses = 0;
84 ignoredclauses = 0;
85 learnedbinaryclauses = 0;
86 learnedternaryclauses = 0;
87 rootSimplifications = 0;
88 reducedliterals = 0;
89 changedreason = 0;
90 reduceddb = 0;
91 }
92
93 public void printStat(PrintWriter out, String prefix) {
94 out.println(prefix + "starts\t\t: " + starts);
95 out.println(prefix + "conflicts\t\t: " + conflicts);
96 out.println(prefix + "decisions\t\t: " + decisions);
97 out.println(prefix + "propagations\t\t: " + propagations);
98 out.println(prefix + "inspects\t\t: " + inspects);
99 out.println(prefix + "shortcuts\t\t: " + shortcuts);
100 out.println(prefix + "learnt literals\t: " + learnedliterals);
101 out.println(prefix + "learnt binary clauses\t: " + learnedbinaryclauses);
102 out.println(prefix + "learnt ternary clauses\t: "
103 + learnedternaryclauses);
104 out.println(prefix + "learnt constraints\t: " + learnedclauses);
105 out.println(prefix + "ignored constraints\t: " + ignoredclauses);
106 out.println(prefix + "root simplifications\t: " + rootSimplifications);
107 out.println(prefix + "removed literals (reason simplification)\t: "
108 + reducedliterals);
109 out.println(prefix + "reason swapping (by a shorter reason)\t: "
110 + changedreason);
111 out.println(prefix + "Calls to reduceDB\t: " + reduceddb);
112 }
113
114 public Map<String, Number> toMap() {
115 Map<String, Number> map = new HashMap<String, Number>();
116 for (Field f : this.getClass().getFields()) {
117 try {
118 map.put(f.getName(), (Number) f.get(this));
119 } catch (IllegalArgumentException e) {
120
121 } catch (IllegalAccessException e) {
122
123 }
124 }
125 return map;
126 }
127 }