mirror of
https://github.com/Z3Prover/z3
synced 2026-06-13 20:35:39 +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
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue