diff --git a/src/api/api_opt.cpp b/src/api/api_opt.cpp index 8c2faec11..e20c78738 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -199,7 +199,7 @@ extern "C" { Z3_string Z3_API Z3_optimize_get_reason_unknown(Z3_context c, Z3_optimize o) { Z3_TRY; - LOG_Z3_optimize_to_string(c, o); + LOG_Z3_optimize_get_reason_unknown(c, o); RESET_ERROR_CODE(); return mk_c(c)->mk_external_string(to_optimize_ptr(o)->reason_unknown()); Z3_CATCH_RETURN(""); diff --git a/src/ast/display_dimacs.cpp b/src/ast/display_dimacs.cpp index bb9ed94bb..50a1ff6d0 100644 --- a/src/ast/display_dimacs.cpp +++ b/src/ast/display_dimacs.cpp @@ -123,3 +123,8 @@ std::ostream& display_dimacs(std::ostream& out, expr_ref_vector const& fmls, boo } return out; } + +std::ostream& display_wcnf(std::ostream& out, expr_ref_vector const& fmls, vector> const& soft, bool include_names) { + NOT_IMPLEMENTED_YET(); + return out; +} diff --git a/src/ast/display_dimacs.h b/src/ast/display_dimacs.h index 2c70be936..a50684682 100644 --- a/src/ast/display_dimacs.h +++ b/src/ast/display_dimacs.h @@ -22,3 +22,5 @@ Revision History: std::ostream& display_dimacs(std::ostream& out, expr_ref_vector const& fmls, bool include_names); +std::ostream& display_wcnf(std::ostream& out, expr_ref_vector const& fmls, vector> const& soft, bool include_names); + diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 0789cb2a4..2307c2488 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -1550,6 +1550,27 @@ namespace opt { return to_string(true, m_hard_constraints, m_objectives); } + std::string context::to_wcnf() { + import_scoped_state(); + expr_ref_vector asms(m); + normalize(asms); + auto const& objectives = m_objectives; + if (objectives.size() > 1) + throw default_exception("only single objective weighted MaxSAT wcnf output is supported"); + if (objectives.size() == 1) { + auto const& obj = objectives[0]; + if (obj.m_type != O_MAXSMT) + throw default_exception("only single objective weighted MaxSAT wcnf output is supported"); + for (unsigned j = 0; j < obj.m_terms.size(); ++j) { + rational w = obj.m_weights[j]; + if (!w.is_unsigned()) + throw default_exception("only single objective weighted MaxSAT wcnf output is supported"); + } + } + NOT_IMPLEMENTED_YET(); + return std::string(""); + } + std::string context::to_string(bool is_internal, expr_ref_vector const& hard, vector const& objectives) const { smt2_pp_environment_dbg env(m); ast_pp_util visitor(m); diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index 7bf7ce7e2..8a6df7129 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -322,7 +322,7 @@ namespace opt { std::string to_string(bool is_internal, expr_ref_vector const& hard, vector const& objectives) const; std::string to_string_internal() const; - + std::string to_wcnf(); void validate_lex(); void validate_maxsat(symbol const& id);