SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
GBModuleStatistics.h
Go to the documentation of this file.
1 #pragma once
2 
4 #ifdef SMTRAT_DEVOPTION_Statistics
5 #include <vector>
6 #include <map>
7 #include <iostream>
8 
10 
11 namespace smtrat {
12 class GBModuleStats : public Statistics
13 {
14  public:
15  static GBModuleStats& getInstance(unsigned key);
16 
17  static void printAll(std::ostream& = std::cout);
18 
19  /**
20  * Override Statistics::collect
21  */
22  void collect() {
23  Statistics::addKeyValuePair("Number calls", mNrCalls);
24  Statistics::addKeyValuePair("Constant GB", mNrConstantGBs);
25  Statistics::addKeyValuePair("Infeasible inequalities", mNrInfeasibleInequalities);
26  Statistics::addKeyValuePair("Backend false", mNrBackendReturnsFalse);
27  Statistics::addKeyValuePair("Deduced equalities", mNrDeducedEqualities);
28  Statistics::addKeyValuePair("Deduced inequalities", mNrDeducedInequalities);
29  Statistics::addKeyValuePair("Radical search: Found identity", mNrOfFoundIdentities);
30  Statistics::addKeyValuePair("Radical search: Found equality", mNrOfFoundEqualities);
31 
32  }
33 
34  /**
35  * Count how often the module is called
36  */
37  void called() { mNrCalls++; }
38  /**
39  * Count how often we find a constant Gb
40  */
41  void constantGB() { mNrConstantGBs++; }
42  /**
43  * Count how often we find infeasibility in the inequalitiestable.
44  */
45  void infeasibleInequality() { mNrInfeasibleInequalities++; }
46  /**
47  * Count number of times the backend call returns false
48  */
49  void backendFalse() { mNrBackendReturnsFalse++; }
50  /**
51  * Count the number of strict inequalities added
52  */
53  void StrictInequalityAdded() { mNrOfStrictInequalitiesAdded++; }
54  /**
55  * Count the number of nonstrict inequalities added
56  */
57  void NonStrictInequalityAdded() { mNrOfNonStrictInequalitiesAdded++; }
58  /**
59  * Count the kind of constraint which was added
60  */
61  void constraintAdded(carl::Relation relation) {
62  switch(relation) {
63  case carl::Relation::EQ:
64  EqualityAdded();
65  break;
66  case carl::Relation::GEQ:
67  case carl::Relation::LEQ:
68  NonStrictInequalityAdded();
69  break;
70  case carl::Relation::NEQ:
71  case carl::Relation::GREATER:
72  case carl::Relation::LESS:
73  StrictInequalityAdded();
74  break;
75  }
76  }
77 
78  /**
79  * Count the kind of constraint which was added
80  */
81  void constraintRemoved(carl::Relation relation) {
82  switch(relation) {
83  case carl::Relation::EQ:
84  EqualityRemoved();
85  break;
86  case carl::Relation::GEQ:
87  case carl::Relation::LEQ:
88  NonStrictInequalityRemoved();
89  break;
90  case carl::Relation::NEQ:
91  case carl::Relation::GREATER:
92  case carl::Relation::LESS:
93  StrictInequalityRemoved();
94  break;
95  }
96  }
97  /**
98  * Count the number of equalities added
99  */
100  void EqualityAdded() { mNrOfEqualitiesAdded++; }
101  /**
102  * Count the number of strict inequalities removed
103  */
104  void StrictInequalityRemoved() { mNrOfStrictInequalitiesRemoved++; }
105  /**
106  * Count the number of nonstrict inequalities removed
107  */
108  void NonStrictInequalityRemoved() { mNrOfNonStrictInequalitiesRemoved++; }
109  /**
110  * Count the number of equalities removed
111  */
112  void EqualityRemoved() { mNrOfEqualitiesRemoved++; }
113 
114  /**
115  *
116  */
117  void DeducedEquality() { mNrDeducedEqualities++; }
118 
119  /**
120  * Record how many deductions for inequalities have been found
121  */
122  void DeducedInequality() { mNrDeducedInequalities++; }
123  /**
124  * Record how many conflict sets were returned in each call.
125  * @param nrInfeasibles the number of conflict sets before we return.
126  */
127  void NumberOfConflictSets(unsigned nrInfeasibles) { mNrOfConflictSets.push_back(nrInfeasibles); }
128  /**
129  * Record how big the conflict sets are w.r.t the whole set.
130  * @param ratio The size of the conflict divided through the number of equalities
131  */
132  void EffectivenessOfConflicts(double ratio) { mEffectivenessOfConflicts.push_back(ratio); }
133 
134  void FoundEqualities() {
135  ++mNrOfFoundEqualities;
136  }
137 
138  void FoundIdentities() {
139  ++mNrOfFoundIdentities;
140  }
141  /**
142  *
143  * @param nrOfPops After an equality is removed, how many pop backtracks are coming.
144  */
145  void PopLevel(unsigned nrOfPops) { mPopLevel.push_back(nrOfPops); }
146 
147  void print(std::ostream& os = std::cout);
148  void exportKeyValue(std::ostream& os = std::cout);
149  GBModuleStats() : mNrCalls(0), mNrConstantGBs(0),
150  mNrInfeasibleInequalities(0), mNrDeducedInequalities(0), mNrDeducedEqualities(0),mNrBackendReturnsFalse(0), mNrOfStrictInequalitiesAdded(0),
151  mNrOfNonStrictInequalitiesAdded(0), mNrOfEqualitiesAdded(0), mNrOfStrictInequalitiesRemoved(0),
152  mNrOfNonStrictInequalitiesRemoved(0), mNrOfEqualitiesRemoved(0), mNrOfFoundEqualities(0), mNrOfFoundIdentities(0)
153  {}
154  protected:
155  unsigned mNrCalls;
156  unsigned mNrConstantGBs;
157  unsigned mNrInfeasibleInequalities;
158  unsigned mNrDeducedInequalities;
159  unsigned mNrDeducedEqualities;
160  unsigned mNrBackendReturnsFalse;
161  unsigned mNrOfStrictInequalitiesAdded;
162  unsigned mNrOfNonStrictInequalitiesAdded;
163  unsigned mNrOfEqualitiesAdded;
164  unsigned mNrOfStrictInequalitiesRemoved;
165  unsigned mNrOfNonStrictInequalitiesRemoved;
166  unsigned mNrOfEqualitiesRemoved;
167  unsigned mNrOfFoundEqualities;
168  unsigned mNrOfFoundIdentities;
169 
170  std::vector<unsigned> mNrOfConflictSets;
171  std::vector<double> mEffectivenessOfConflicts;
172  std::vector<unsigned> mPopLevel;
173 
174  private:
175  static std::map<unsigned,GBModuleStats*> instances;
176 };
177 
178 }
179 
180 #endif
void print(std::ostream &stream, const FormulaDB &db, const FormulaID id, const std::size_t level)
Class to create the formulas for axioms.
carl::statistics::Statistics Statistics
Definition: Statistics.h:7