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