5 #ifdef SMTRAT_DEVOPTION_Statistics
8 #include <carl-arith/ran/common/RealRoots.h>
15 using carl::operator<<;
27 case ProjectionType::leading_coefficient:
return "leading_coefficient";
28 case ProjectionType::coefficient:
return "coefficient";
29 case ProjectionType::derivative:
return "derivative";
30 case ProjectionType::factor:
return "factor";
36 carl::statistics::MultiCounter<std::pair<std::size_t, std::size_t>> m_depth_section_common_zeros_count;
38 carl::statistics::MultiCounter<std::size_t> m_interval_point_count_by_depth;
39 carl::statistics::MultiCounter<std::size_t> m_interval_open_count_by_depth;
40 carl::statistics::MultiCounter<std::size_t> m_interval_halfopen_count_by_depth;
41 carl::statistics::MultiCounter<std::size_t> m_interval_closed_count_by_depth;
42 carl::statistics::MultiCounter<std::size_t> m_interval_unbounded_count_by_depth;
43 carl::statistics::MultiCounter<std::size_t> m_interval_halfunbounded_count_by_depth;
45 carl::statistics::MultiCounter<std::size_t> m_representation_equational_count_by_depth;
47 carl::statistics::MultiCounter<std::size_t> m_rules_intersection_count_by_depth;
49 carl::statistics::Timer m_proj_timer;
51 boost::container::flat_map<ProjectionType, carl::statistics::Series> m_proj_x_total_degree;
52 boost::container::flat_map<ProjectionType, carl::statistics::Series> m_proj_x_degree;
53 boost::container::flat_map<ProjectionType, carl::statistics::Series> m_proj_x_level;
55 carl::statistics::Series m_proj_realroots_num_roots;
56 std::size_t m_proj_realroots_nullified_count;
58 carl::statistics::MultiCounter<std::size_t> m_filter_poly_count_by_depth;
59 carl::statistics::MultiCounter<std::pair<std::size_t, std::size_t>> m_filter_poly_count_by_depth_and_num_factors;
60 carl::statistics::MultiCounter<std::pair<std::size_t, std::size_t>> m_filter_poly_count_by_depth_and_num_roots;
61 carl::statistics::MultiCounter<std::size_t> m_filter_poly_count_independent_by_depth;
63 std::size_t m_current_max_level;
65 std::size_t m_filter_current_level;
66 bool m_filter_current_underlying_algebraic;
67 bool m_filter_current_indep;
69 carl::statistics::Timer m_timer_filter_roots;
70 carl::statistics::Timer m_timer_filter_roots_callback;
72 carl::statistics::MultiCounter<std::size_t> m_filter_root_by_depth;
73 carl::statistics::MultiCounter<std::size_t> m_filter_root_algebraic_by_depth;
74 carl::statistics::MultiCounter<std::size_t> m_filter_root_sample_algebraic_by_depth;
75 carl::statistics::MultiCounter<std::size_t> m_filter_root_optional_by_depth;
76 carl::statistics::MultiCounter<std::size_t> m_filter_root_inclusive_by_depth;
79 bool enabled()
const {
84 Statistics::addKeyValuePair(
"heuristics.section.common_zeros_count.by_depth", m_depth_section_common_zeros_count);
86 Statistics::addKeyValuePair(
"heuristics.interval.point_count.by_depth", m_interval_point_count_by_depth);
87 Statistics::addKeyValuePair(
"heuristics.interval.open_count.by_depth", m_interval_open_count_by_depth);
88 Statistics::addKeyValuePair(
"heuristics.interval.halfopen_count.by_depth", m_interval_halfopen_count_by_depth);
89 Statistics::addKeyValuePair(
"heuristics.interval.closed_count.by_depth", m_interval_closed_count_by_depth);
90 Statistics::addKeyValuePair(
"heuristics.interval.unbounded_count.by_depth", m_interval_unbounded_count_by_depth);
91 Statistics::addKeyValuePair(
"heuristics.interval.halfunbounded_count.by_depth", m_interval_halfunbounded_count_by_depth);
93 Statistics::addKeyValuePair(
"heuristics.representation.equational_count.by_depth", m_representation_equational_count_by_depth);
95 Statistics::addKeyValuePair(
"heuristics.rules.intersection_count.by_depth", m_rules_intersection_count_by_depth);
97 for (
const auto& [k, v] : m_proj_x_total_degree) {
98 Statistics::addKeyValuePair(
"projections." + to_string(k) +
".total_degree", v);
100 for (
const auto& [k, v] : m_proj_x_degree) {
101 Statistics::addKeyValuePair(
"projections." + to_string(k) +
".degree", v);
103 for (
const auto& [k, v] : m_proj_x_level) {
104 Statistics::addKeyValuePair(
"projections." + to_string(k) +
".level", v);
107 Statistics::addKeyValuePair(
"projections.real_roots.num_roots", m_proj_realroots_num_roots);
108 Statistics::addKeyValuePair(
"projections.real_roots.nullified.count", m_proj_realroots_nullified_count);
110 Statistics::addKeyValuePair(
"projections.timer", m_proj_timer);
112 Statistics::addKeyValuePair(
"filter.poly_count.by_depth", m_filter_poly_count_by_depth);
113 Statistics::addKeyValuePair(
"filter.poly_count.by_depth_and_num_factors", m_filter_poly_count_by_depth_and_num_factors);
114 Statistics::addKeyValuePair(
"filter.poly_count.by_depth_and_num_roots", m_filter_poly_count_by_depth_and_num_roots);
115 Statistics::addKeyValuePair(
"filter.poly_count.independent.by_depth", m_filter_poly_count_independent_by_depth);
117 Statistics::addKeyValuePair(
"filter.timer.filter_roots", m_timer_filter_roots);
118 Statistics::addKeyValuePair(
"filter.timer.filter_roots_callback", m_timer_filter_roots_callback);
120 Statistics::addKeyValuePair(
"filter.root.by_depth", m_filter_root_by_depth);
121 Statistics::addKeyValuePair(
"filter.root.algebraic.by_depth", m_filter_root_algebraic_by_depth);
122 Statistics::addKeyValuePair(
"filter.root.sample_algebraic.by_depth", m_filter_root_sample_algebraic_by_depth);
123 Statistics::addKeyValuePair(
"filter.root.optional.by_depth", m_filter_root_optional_by_depth);
124 Statistics::addKeyValuePair(
"filter.root.inclusive.by_depth", m_filter_root_inclusive_by_depth);
130 void projection_start() {
131 m_proj_timer.start_this();
133 void projection_end() {
134 m_proj_timer.finish();
137 void projection_poly(
const ProjectionType&
type, std::size_t total_degree, std::size_t degree, std::size_t level) {
138 m_proj_x_total_degree.try_emplace(
type).first->second.add(total_degree);
139 m_proj_x_degree.try_emplace(
type).first->second.add(degree);
140 m_proj_x_level.try_emplace(
type).first->second.add(level);
144 void leading_coefficient(std::size_t total_degree, std::size_t degree, std::size_t level) { projection_poly(ProjectionType::leading_coefficient, total_degree, degree, level); }
145 void coefficient (std::size_t total_degree, std::size_t degree, std::size_t level) { projection_poly(ProjectionType::coefficient , total_degree, degree, level); }
146 void derivative (std::size_t total_degree, std::size_t degree, std::size_t level) { projection_poly(ProjectionType::derivative , total_degree, degree, level); }
147 void factor (std::size_t total_degree, std::size_t degree, std::size_t level) { projection_poly(ProjectionType::factor , total_degree, degree, level); }
149 void real_roots_result(
const carl::RealRootsResult<RAN>&
result) {
150 if (
result.is_nullified()) {
151 m_proj_realroots_nullified_count++;
153 m_proj_realroots_num_roots.add(
result.is_nullified() ? 0 :
result.roots().size());
159 void set_max_level(std::size_t level) {
160 m_current_max_level = level;
162 void filter_roots_start(std::size_t level, std::size_t num_factors, std::size_t num_roots,
const cadcells::Assignment& ass) {
163 assert(m_current_max_level>=level);
164 m_filter_poly_count_by_depth.inc(m_current_max_level-level, 1);
165 m_filter_poly_count_by_depth_and_num_factors.inc(std::make_pair((std::size_t)m_current_max_level-level, num_factors), 1);
166 m_filter_poly_count_by_depth_and_num_roots.inc(std::make_pair((std::size_t)m_current_max_level-level, num_roots), 1);
168 m_filter_current_level = level;
169 m_filter_current_underlying_algebraic = std::find_if(ass.begin(), ass.end(), [](
const auto& m) { return !m.second.is_numeric(); }) != ass.end();
170 m_filter_current_indep =
true;
172 m_timer_filter_roots.start_this();
174 void filter_roots_end() {
175 if (m_filter_current_indep) {
176 m_filter_poly_count_independent_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
179 m_timer_filter_roots.finish();
182 m_filter_root_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
183 if (!ran.is_numeric()) {
184 m_filter_root_algebraic_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
186 if (m_filter_current_underlying_algebraic || !ran.is_numeric()) {
187 m_filter_root_sample_algebraic_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
190 m_timer_filter_roots_callback.start_this();
192 void filter_roots_filter_end() {
193 m_timer_filter_roots.finish();
197 m_filter_current_indep =
false;
200 m_filter_root_inclusive_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
201 m_filter_current_indep =
false;
204 m_filter_root_optional_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
206 void filter_roots_got_inclusive_optional(
const cadcells::RAN&) {
207 m_filter_root_optional_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
208 m_filter_root_inclusive_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
214 void section_common_zeros(std::size_t depth, std::size_t num_common_eq_constr) {
215 m_depth_section_common_zeros_count.inc(std::make_pair(depth,num_common_eq_constr), 1);
218 void got_bound(
const datastructures::SymbolicInterval& interval) {
219 if (interval.is_section()) {
220 m_interval_point_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
222 if(interval.lower().is_infty() && interval.upper().is_infty()) {
223 m_interval_unbounded_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
224 }
else if (interval.lower().is_infty() || interval.upper().is_infty()) {
225 m_interval_halfunbounded_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
227 if(interval.lower().is_weak() && interval.upper().is_weak()) {
228 m_interval_closed_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
229 }
else if(interval.lower().is_strict() && interval.upper().is_strict()) {
230 m_interval_open_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
232 m_interval_halfopen_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
236 void got_representation_equational(std::size_t num) {
237 m_representation_equational_count_by_depth.inc(m_current_max_level-m_filter_current_level, num);
243 void detect_intersection() {
244 m_rules_intersection_count_by_depth.inc(m_current_max_level-m_filter_current_level, 1);
248 CADCellsStatistics &statistics();
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.
carl::Assignment< RAN > Assignment
QuantifierType type(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
carl::statistics::Statistics Statistics