3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

add new model event handler for incremental optimization

This commit is contained in:
Nikolaj Bjorner 2021-02-05 17:11:04 -08:00
parent 2c472aaa10
commit 16448104eb
7 changed files with 94 additions and 1 deletions

View file

@ -382,6 +382,13 @@ namespace opt {
model_ref md = m->copy();
fix_model(md);
}
if (m_on_model_eh && m) {
model_ref md = m->copy();
if (!m_model_fixed.contains(md.get()))
fix_model(md);
m_on_model_eh(m_on_model_ctx, md);
m_model_fixed.pop_back();
}
}

View file

@ -66,6 +66,14 @@ namespace opt {
It handles combinations of objectives.
*/
struct on_model_t {
void* c;
void* m;
void* user_context;
void* on_model;
};
class context :
public opt_wrapper,
public pareto_callback,
@ -143,6 +151,8 @@ namespace opt {
};
ast_manager& m;
on_model_t m_on_model_ctx;
std::function<void(on_model_t&, model_ref&)> m_on_model_eh;
arith_util m_arith;
bv_util m_bv;
expr_ref_vector m_hard_constraints;
@ -245,6 +255,11 @@ namespace opt {
void model_updated(model* mdl) override;
void register_on_model(on_model_t& ctx, std::function<void(on_model_t&, model_ref&)>& on_model) {
m_on_model_ctx = ctx;
m_on_model_eh = on_model;
}
private:
lbool execute(objective const& obj, bool committed, bool scoped);
lbool execute_min_max(unsigned index, bool committed, bool scoped, bool is_max);