mirror of
https://github.com/Z3Prover/z3
synced 2026-06-08 10:00:56 +00:00
refactor solver to include settable stats
This commit is contained in:
parent
241c6211d6
commit
1f5132c396
22 changed files with 42 additions and 30 deletions
|
|
@ -232,7 +232,9 @@ public:
|
|||
}
|
||||
ctx.validate_check_sat_result(r);
|
||||
}
|
||||
t.collect_statistics(result->m_stats);
|
||||
statistics stats;
|
||||
t.collect_statistics(stats);
|
||||
result->add_statistics(stats);
|
||||
}
|
||||
|
||||
if (ctx.produce_unsat_cores()) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ namespace spacer {
|
|||
return m_base_defs.is_proxy (a, def);
|
||||
}
|
||||
|
||||
void iuc_solver::collect_statistics (statistics &st) const {
|
||||
void iuc_solver::collect_statistics_core (statistics &st) const {
|
||||
m_solver.collect_statistics (st);
|
||||
st.update ("time.iuc_solver.get_iuc", m_iuc_sw.get_seconds());
|
||||
st.update ("time.iuc_solver.get_iuc.hyp_reduce1", m_hyp_reduce1_sw.get_seconds());
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public:
|
|||
|
||||
/* check_sat_result interface */
|
||||
|
||||
void collect_statistics(statistics &st) const override ;
|
||||
void collect_statistics_core(statistics &st) const override ;
|
||||
virtual void reset_statistics();
|
||||
|
||||
void get_unsat_core(expr_ref_vector &r) override;
|
||||
|
|
|
|||
|
|
@ -1745,7 +1745,7 @@ namespace opt {
|
|||
m_pareto1 = p != nullptr;
|
||||
}
|
||||
|
||||
void context::collect_statistics(statistics& stats) const {
|
||||
void context::collect_statistics_core(statistics& stats) const {
|
||||
if (m_solver)
|
||||
m_solver->collect_statistics(stats);
|
||||
if (m_simplify)
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ namespace opt {
|
|||
void get_model_core(model_ref& _m) override;
|
||||
void get_box_model(model_ref& _m, unsigned index) override;
|
||||
void fix_model(model_ref& _m) override;
|
||||
void collect_statistics(statistics& stats) const override;
|
||||
void collect_statistics_core(statistics& stats) const override;
|
||||
proof* get_proof_core() override { return nullptr; }
|
||||
void get_labels(svector<symbol> & r) override;
|
||||
void get_unsat_core(expr_ref_vector & r) override;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace opt {
|
|||
virtual void collect_param_descrs(param_descrs & r) {
|
||||
m_solver->collect_param_descrs(r);
|
||||
}
|
||||
virtual void collect_statistics(statistics & st) const {
|
||||
virtual void collect_statistics_core(statistics & st) const {
|
||||
m_solver->collect_statistics(st);
|
||||
if (m_bvsls) m_bvsls->collect_statistics(st);
|
||||
if (m_pbsls) m_pbsls->collect_statistics(st);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace opt {
|
|||
m_context.collect_param_descrs(r);
|
||||
}
|
||||
|
||||
void opt_solver::collect_statistics(statistics & st) const {
|
||||
void opt_solver::collect_statistics_core(statistics & st) const {
|
||||
m_context.collect_statistics(st);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace opt {
|
|||
solver* translate(ast_manager& m, params_ref const& p) override;
|
||||
void updt_params(params_ref const& p) override;
|
||||
void collect_param_descrs(param_descrs & r) override;
|
||||
void collect_statistics(statistics & st) const override;
|
||||
void collect_statistics_core(statistics & st) const override;
|
||||
void assert_expr_core(expr * t) override;
|
||||
void push_core() override;
|
||||
void pop_core(unsigned n) override;
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ public:
|
|||
if (p1.euf() && !get_euf())
|
||||
ensure_euf();
|
||||
}
|
||||
void collect_statistics(statistics & st) const override {
|
||||
void collect_statistics_core(statistics & st) const override {
|
||||
if (m_preprocess) m_preprocess->collect_statistics(st);
|
||||
m_solver.collect_statistics(st);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ public:
|
|||
ensure_euf();
|
||||
}
|
||||
|
||||
void collect_statistics(statistics & st) const override {
|
||||
void collect_statistics_core(statistics & st) const override {
|
||||
m_solver.collect_statistics(st);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ namespace {
|
|||
insert_ctrl_c(r);
|
||||
}
|
||||
|
||||
void collect_statistics(statistics & st) const override {
|
||||
void collect_statistics_core(statistics & st) const override {
|
||||
m_context.collect_statistics(st);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,9 +70,6 @@ simple_check_sat_result::simple_check_sat_result(ast_manager & m):
|
|||
m_proof(m) {
|
||||
}
|
||||
|
||||
void simple_check_sat_result::collect_statistics(statistics & st) const {
|
||||
st.copy(m_stats);
|
||||
}
|
||||
|
||||
void simple_check_sat_result::get_unsat_core(expr_ref_vector & r) {
|
||||
if (m_status == l_false) {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ protected:
|
|||
lbool m_status = l_undef;
|
||||
model_converter_ref m_mc0;
|
||||
double m_time = 0;
|
||||
statistics m_stats;
|
||||
|
||||
public:
|
||||
check_sat_result(ast_manager& m): m(m), m_log(m), m_proof(m) {}
|
||||
virtual ~check_sat_result() = default;
|
||||
|
|
@ -53,7 +55,18 @@ public:
|
|||
void dec_ref() { SASSERT(m_ref_count > 0); m_ref_count--; if (m_ref_count == 0) dealloc(this); }
|
||||
lbool set_status(lbool r) { return m_status = r; }
|
||||
lbool status() const { return m_status; }
|
||||
virtual void collect_statistics(statistics & st) const = 0;
|
||||
void collect_statistics(statistics &st) const {
|
||||
collect_statistics_core(st);
|
||||
st.copy(m_stats);
|
||||
}
|
||||
void add_statistics(statistics const &st) {
|
||||
m_stats.copy(st);
|
||||
}
|
||||
void reset_statistics() {
|
||||
m_stats.reset();
|
||||
}
|
||||
|
||||
virtual void collect_statistics_core(statistics &st) const = 0;
|
||||
virtual void get_unsat_core(expr_ref_vector & r) = 0;
|
||||
void set_model_converter(model_converter* mc) { m_mc0 = mc; }
|
||||
model_converter* mc0() const { return m_mc0.get(); }
|
||||
|
|
@ -92,7 +105,6 @@ public:
|
|||
\brief Very simple implementation of the check_sat_result object.
|
||||
*/
|
||||
struct simple_check_sat_result : public check_sat_result {
|
||||
statistics m_stats;
|
||||
model_ref m_model;
|
||||
expr_ref_vector m_core;
|
||||
proof_ref m_proof;
|
||||
|
|
@ -100,9 +112,9 @@ struct simple_check_sat_result : public check_sat_result {
|
|||
|
||||
simple_check_sat_result(ast_manager & m);
|
||||
ast_manager& get_manager() const override { return m_proof.get_manager(); }
|
||||
void collect_statistics(statistics & st) const override;
|
||||
void get_unsat_core(expr_ref_vector & r) override;
|
||||
void get_model_core(model_ref & m) override;
|
||||
void collect_statistics_core(statistics &st) const override {}
|
||||
proof * get_proof_core() override;
|
||||
std::string reason_unknown() const override;
|
||||
void get_labels(svector<symbol> & r) override;
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ public:
|
|||
return m_solver1->display(out, n, es);
|
||||
}
|
||||
|
||||
void collect_statistics(statistics & st) const override {
|
||||
void collect_statistics_core(statistics & st) const override {
|
||||
m_solver2->collect_statistics(st);
|
||||
if (m_use_solver1_results)
|
||||
m_solver1->collect_statistics(st);
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public:
|
|||
return s->check_sat_core(num_assumptions, _assumptions.data());
|
||||
}
|
||||
|
||||
void collect_statistics(statistics& st) const override {
|
||||
void collect_statistics_core(statistics& st) const override {
|
||||
s->collect_statistics(st);
|
||||
m_preprocess.collect_statistics(st);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ public:
|
|||
return s->check_sat_core(num_assumptions, assumptions);
|
||||
}
|
||||
|
||||
void collect_statistics(statistics& st) const override { s->collect_statistics(st); }
|
||||
void collect_statistics_core(statistics& st) const override { s->collect_statistics(st); }
|
||||
|
||||
void get_model_core(model_ref& mdl) override { s->get_model_core(mdl); }
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
void pop_params() override {m_base->pop_params();}
|
||||
|
||||
void collect_param_descrs(param_descrs & r) override { m_base->collect_param_descrs(r); }
|
||||
void collect_statistics(statistics & st) const override { m_base->collect_statistics(st); }
|
||||
void collect_statistics_core(statistics & st) const override { m_base->collect_statistics(st); }
|
||||
unsigned get_num_assertions() const override { return m_base->get_num_assertions(); }
|
||||
expr * get_assertion(unsigned idx) const override { return m_base->get_assertion(idx); }
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class tactic2solver : public solver_na2as {
|
|||
bool m_produce_models;
|
||||
bool m_produce_proofs;
|
||||
bool m_produce_unsat_cores;
|
||||
statistics m_stats;
|
||||
// statistics m_stats;
|
||||
bool m_minimizing = false;
|
||||
|
||||
public:
|
||||
|
|
@ -70,7 +70,7 @@ public:
|
|||
void pop_core(unsigned n) override;
|
||||
lbool check_sat_core2(unsigned num_assumptions, expr * const * assumptions) override;
|
||||
|
||||
void collect_statistics(statistics & st) const override;
|
||||
void collect_statistics_core(statistics & st) const override;
|
||||
void get_unsat_core(expr_ref_vector & r) override;
|
||||
void get_model_core(model_ref & m) override;
|
||||
proof * get_proof_core() override;
|
||||
|
|
@ -284,8 +284,9 @@ lbool tactic2solver::check_sat_core2(unsigned num_assumptions, expr * const * as
|
|||
m_result->m_unknown = ex.what();
|
||||
m_result->m_proof = pr;
|
||||
}
|
||||
m_tactic->collect_statistics(m_result->m_stats);
|
||||
m_tactic->collect_statistics(m_stats);
|
||||
statistics stats;
|
||||
m_tactic->collect_statistics(stats);
|
||||
m_result->add_statistics(stats);
|
||||
m_result->m_model = md;
|
||||
m_result->m_proof = pr;
|
||||
if (m_produce_unsat_cores) {
|
||||
|
|
@ -311,7 +312,7 @@ solver* tactic2solver::translate(ast_manager& m, params_ref const& p) {
|
|||
}
|
||||
|
||||
|
||||
void tactic2solver::collect_statistics(statistics & st) const {
|
||||
void tactic2solver::collect_statistics_core(statistics & st) const {
|
||||
st.copy(m_stats);
|
||||
if (m_stats.size() == 0 && m_tactic)
|
||||
m_tactic->collect_statistics(st);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ public:
|
|||
void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); }
|
||||
void set_produce_models(bool f) override { m_solver->set_produce_models(f); }
|
||||
void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); }
|
||||
void collect_statistics(statistics & st) const override { m_solver->collect_statistics(st); }
|
||||
void collect_statistics_core(statistics & st) const override { m_solver->collect_statistics(st); }
|
||||
void get_unsat_core(expr_ref_vector & r) override { m_solver->get_unsat_core(r); }
|
||||
void set_phase(expr* e) override { m_solver->set_phase(e); }
|
||||
phase* get_phase() override { return m_solver->get_phase(); }
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); }
|
||||
void set_produce_models(bool f) override { m_solver->set_produce_models(f); }
|
||||
void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); }
|
||||
void collect_statistics(statistics & st) const override { m_solver->collect_statistics(st); }
|
||||
void collect_statistics_core(statistics & st) const override { m_solver->collect_statistics(st); }
|
||||
void get_unsat_core(expr_ref_vector & r) override { m_solver->get_unsat_core(r); }
|
||||
void set_phase(expr* e) override { m_solver->set_phase(e); }
|
||||
phase* get_phase() override { return m_solver->get_phase(); }
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public:
|
|||
void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); m_rewriter.collect_param_descrs(r);}
|
||||
void set_produce_models(bool f) override { m_solver->set_produce_models(f); }
|
||||
void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); }
|
||||
void collect_statistics(statistics & st) const override {
|
||||
void collect_statistics_core(statistics & st) const override {
|
||||
m_rewriter.collect_statistics(st);
|
||||
m_solver->collect_statistics(st);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2032,7 +2032,7 @@ namespace smtfd {
|
|||
|
||||
void set_produce_models(bool f) override { }
|
||||
void set_progress_callback(progress_callback * callback) override { }
|
||||
void collect_statistics(statistics & st) const override {
|
||||
void collect_statistics_core(statistics & st) const override {
|
||||
if (m_fd_sat_solver) {
|
||||
m_fd_sat_solver->collect_statistics(st);
|
||||
m_fd_core_solver->collect_statistics(st);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue