5 #ifdef SMTRAT_DEVOPTION_Statistics
10 class OCApproximationStatistics :
public Statistics {
12 using Counter = std::map<std::size_t, std::size_t>;
14 bool m_currently_approximated =
false;
16 std::size_t m_considered_cells = 0;
17 std::size_t m_approximated_cells = 0;
18 std::size_t m_approximated_cells_success = 0;
20 Counter m_approximated_degree_counter;
22 std::vector<std::pair<std::size_t,std::size_t>> m_taylor_ignored;
23 std::size_t m_taylor_grad_zero = 0;
25 std::size_t m_unbounded_levels = 0;
26 std::size_t m_half_unbounded_levels = 0;
27 std::vector<std::size_t> m_cell_dimensions;
29 std::size_t m_resultants = 0;
30 std::size_t m_discriminants = 0;
31 std::size_t m_ldcfs = 0;
32 Counter m_constructed_degree_counter;
34 std::size_t m_involved_too_often = 0;
35 std::size_t m_apx_too_often = 0;
36 bool m_max_considered_reached =
false;
37 bool m_max_apx_reached =
false;
39 void collectCounterStats(Counter c,
const std::string& name) {
43 for (
const auto& [key, value] : c) {
46 if (key > max) max = key;
48 double mean = ((double) sum) / ((double) n);
49 Statistics::addKeyValuePair(
"total_"+name, n);
50 Statistics::addKeyValuePair(
"max_"+name, max);
51 Statistics::addKeyValuePair(
"mean_"+name, mean);
55 bool enabled()
const {
60 Statistics::addKeyValuePair(
"considered", m_considered_cells);
61 Statistics::addKeyValuePair(
"approximated", m_approximated_cells);
62 Statistics::addKeyValuePair(
"success", m_approximated_cells_success);
64 collectCounterStats(m_approximated_degree_counter,
"apx_degrees");
66 Statistics::addKeyValuePair(
"unbounded_levels", m_unbounded_levels);
67 Statistics::addKeyValuePair(
"half_unbounded_levels", m_half_unbounded_levels);
68 std::size_t sumDimensions = 0;
69 for (
const std::size_t d : m_cell_dimensions) sumDimensions += d;
70 Statistics::addKeyValuePair(
"mean_cell_dimension", ((
double) sumDimensions) / ((
double) m_cell_dimensions.size()));
72 std::size_t maxIgnoredVars = 0;
74 std::size_t total = 0;
75 for (
const auto& item : m_taylor_ignored) {
76 sum += ((double) item.first) / ((double) item.second);
78 if (item.first > maxIgnoredVars) maxIgnoredVars = item.first;
80 double meanIgnoredVars = sum/((double) m_taylor_ignored.size());
81 Statistics::addKeyValuePair(
"max_taylor_ignored_vars", maxIgnoredVars);
82 Statistics::addKeyValuePair(
"total_taylor_ignored_vars", total);
83 Statistics::addKeyValuePair(
"mean_taylor_ignored_vars", meanIgnoredVars);
84 Statistics::addKeyValuePair(
"taylor_failure", m_taylor_grad_zero);
86 Statistics::addKeyValuePair(
"resultants", m_resultants);
87 Statistics::addKeyValuePair(
"discriminants", m_discriminants);
88 Statistics::addKeyValuePair(
"leading_coefficients", m_ldcfs);
89 collectCounterStats(m_constructed_degree_counter,
"construction_degrees");
91 Statistics::addKeyValuePair(
"involved_too_often", m_involved_too_often);
92 Statistics::addKeyValuePair(
"apx_too_often", m_apx_too_often);
93 Statistics::addKeyValuePair(
"max_considered_reached", m_max_considered_reached);
94 Statistics::addKeyValuePair(
"max_apx_reached", m_max_apx_reached);
98 m_currently_approximated =
false;
101 void success(std::size_t d) {
102 if (m_currently_approximated) ++m_approximated_cells_success;
103 m_cell_dimensions.push_back(d);
105 void approximationConsidered() {++m_considered_cells;}
106 void approximated(std::size_t d) {
107 ++m_approximated_degree_counter[d];
108 if (!m_currently_approximated) {
109 ++m_approximated_cells;
110 m_currently_approximated =
true;
114 void taylorIgnoredVars(std::size_t ignored, std::size_t total) {m_taylor_ignored.emplace_back(ignored, total);}
115 void taylorFailure() {++m_taylor_grad_zero;}
117 void unboundedLevel() {++m_unbounded_levels;}
118 void halfUnboundedLevel() {++m_half_unbounded_levels;}
119 void cellDimension(std::size_t d) {m_cell_dimensions.push_back(d);}
123 void coefficient() {++m_ldcfs;}
124 void degree(std::size_t d) {++m_constructed_degree_counter[d];}
126 void involvedTooOften() {++m_involved_too_often;}
127 void apxTooOften() {++m_apx_too_often;}
128 void maxConsideredReached() {m_max_considered_reached =
true;}
129 void maxApxReached() {m_max_apx_reached =
true;}
131 static OCApproximationStatistics& get_instance() {
132 static OCApproximationStatistics& statistics = statistics_get<OCApproximationStatistics>(
"onecell-approximation");
Poly resultant(carl::Variable variable, const Poly &p, const Poly &q)
Computes the resultant of two polynomials.
Poly discriminant(carl::Variable variable, const Poly &p)
Computes the discriminant of a polynomial.
std::size_t cellDimension(const CADCell &cell, const std::size_t uptoLevel)
Class to create the formulas for axioms.
carl::statistics::Statistics Statistics