3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-18 06:39:02 +00:00

start wcnf

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-02-26 11:13:44 -08:00
parent be68456c06
commit 08f55f9d1f
5 changed files with 30 additions and 2 deletions

View file

@ -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("");

View file

@ -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<std::pair<expr*,unsigned>> const& soft, bool include_names) {
NOT_IMPLEMENTED_YET();
return out;
}

View file

@ -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<std::pair<expr*,unsigned>> const& soft, bool include_names);

View file

@ -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<objective> const& objectives) const {
smt2_pp_environment_dbg env(m);
ast_pp_util visitor(m);

View file

@ -322,7 +322,7 @@ namespace opt {
std::string to_string(bool is_internal, expr_ref_vector const& hard, vector<objective> const& objectives) const;
std::string to_string_internal() const;
std::string to_wcnf();
void validate_lex();
void validate_maxsat(symbol const& id);