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 void reset() {
74          starts = 0;
75          decisions = 0;
76          propagations = 0;
77          inspects = 0;
78          conflicts = 0;
79          learnedliterals = 0;
80          learnedclauses = 0;
81          ignoredclauses = 0;
82          learnedbinaryclauses = 0;
83          learnedternaryclauses = 0;
84          rootSimplifications = 0;
85          reducedliterals = 0;
86          changedreason = 0;
87          reduceddb = 0;
88      }
89  
90      public void printStat(PrintWriter out, String prefix) {
91          out.println(prefix + "starts\t\t: " + starts);
92          out.println(prefix + "conflicts\t\t: " + conflicts);
93          out.println(prefix + "decisions\t\t: " + decisions);
94          out.println(prefix + "propagations\t\t: " + propagations);
95          out.println(prefix + "inspects\t\t: " + inspects);
96          out.println(prefix + "learnt literals\t: " + learnedliterals);
97          out
98                  .println(prefix + "learnt binary clauses\t: "
99                          + learnedbinaryclauses);
100         out.println(prefix + "learnt ternary clauses\t: "
101                 + learnedternaryclauses);
102         out.println(prefix + "learnt clauses\t: " + learnedclauses);
103         out.println(prefix + "ignored clauses\t: " + ignoredclauses);
104         out.println(prefix + "root simplifications\t: " + rootSimplifications);
105         out.println(prefix + "removed literals (reason simplification)\t: "
106                 + reducedliterals);
107         out.println(prefix + "reason swapping (by a shorter reason)\t: "
108                 + changedreason);
109         out.println(prefix + "Calls to reduceDB\t: " + reduceddb);
110     }
111 
112     public Map<String, Number> toMap() {
113         Map<String, Number> map = new HashMap<String, Number>();
114         for (Field f : this.getClass().getDeclaredFields()) {
115             try {
116                 map.put(f.getName(), (Number) f.get(this));
117             } catch (IllegalArgumentException e) {
118                 e.printStackTrace();
119             } catch (IllegalAccessException e) {
120                 e.printStackTrace();
121             }
122         }
123         return map;
124     }
125 }