3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-19 12:23:38 +00:00

enable partial results

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2014-01-06 16:23:37 -08:00
parent f1710e5618
commit 5adb4a22d1
3 changed files with 22 additions and 15 deletions

View file

@ -53,7 +53,7 @@ namespace opt {
if (m_msolver) { if (m_msolver) {
m_msolver->updt_params(m_params); m_msolver->updt_params(m_params);
is_sat = (*m_msolver)(); is_sat = (*m_msolver)();
if (is_sat == l_true) { if (is_sat != l_false) {
m_msolver->get_model(m_model); m_msolver->get_model(m_model);
} }
} }

View file

@ -295,18 +295,7 @@ public:
switch(r) { switch(r) {
case l_true: { case l_true: {
ctx.regular_stream() << "sat\n"; ctx.regular_stream() << "sat\n";
opt.display_assignment(ctx.regular_stream()); display_result(ctx);
opt_params optp(p);
if (optp.print_model()) {
model_ref mdl;
opt.get_model(mdl);
if (mdl) {
ctx.regular_stream() << "(model " << std::endl;
model_smt2_pp(ctx.regular_stream(), ctx, *(mdl.get()), 2);
// m->display(ctx.regular_stream());
ctx.regular_stream() << ")" << std::endl;
}
}
break; break;
} }
case l_false: case l_false:
@ -314,13 +303,30 @@ public:
break; break;
case l_undef: case l_undef:
ctx.regular_stream() << "unknown\n"; ctx.regular_stream() << "unknown\n";
opt.display_assignment(ctx.regular_stream()); display_result(ctx);
break; break;
} }
if (p.get_bool("print_statistics", false)) { if (p.get_bool("print_statistics", false)) {
display_statistics(ctx); display_statistics(ctx);
} }
} }
void display_result(cmd_context & ctx) {
params_ref p = ctx.params().merge_default_params(ps());
opt::context& opt = m_opt_ctx();
opt.display_assignment(ctx.regular_stream());
opt_params optp(p);
if (optp.print_model()) {
model_ref mdl;
opt.get_model(mdl);
if (mdl) {
ctx.regular_stream() << "(model " << std::endl;
model_smt2_pp(ctx.regular_stream(), ctx, *(mdl.get()), 2);
// m->display(ctx.regular_stream());
ctx.regular_stream() << ")" << std::endl;
}
}
}
private: private:
void display_statistics(cmd_context& ctx) { void display_statistics(cmd_context& ctx) {

View file

@ -139,10 +139,11 @@ namespace opt {
} }
lbool context::execute_maxsat(symbol const& id, bool committed) { lbool context::execute_maxsat(symbol const& id, bool committed) {
model_ref tmp;
maxsmt& ms = *m_maxsmts.find(id); maxsmt& ms = *m_maxsmts.find(id);
lbool result = ms(get_solver()); lbool result = ms(get_solver());
if (result == l_true && committed) ms.commit_assignment(); if (result == l_true && committed) ms.commit_assignment();
if (result == l_true) ms.get_model(m_model); if (result != l_false && (ms.get_model(tmp), tmp.get())) ms.get_model(m_model);
return result; return result;
} }