3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-08 15:13:23 +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

@ -435,6 +435,32 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
static void optimize_on_model(opt::on_model_t& o, model_ref& m) {
Z3_context c = (Z3_context) o.c;
auto model_eh = (void(*)(void*)) o.on_model;
Z3_model_ref * m_ref = (Z3_model_ref*) o.m;
m_ref->m_model = m.get();
model_eh(o.user_context);
}
void Z3_API Z3_optimize_register_model_eh(
Z3_context c,
Z3_optimize o,
Z3_model m,
void* user_context,
Z3_model_eh model_eh) {
Z3_TRY;
std::function<void(opt::on_model_t&, model_ref&)> _model_eh = optimize_on_model;
opt::on_model_t ctx;
ctx.c = c;
ctx.m = m;
ctx.user_context = user_context;
ctx.on_model = model_eh;
to_optimize_ptr(o)->register_on_model(ctx, _model_eh);
Z3_CATCH;
}
};