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

fixing bugs in refactored code exposed from White's example

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2014-04-17 11:06:43 -07:00
parent c84ab2fc01
commit 7237be768b
7 changed files with 117 additions and 131 deletions

View file

@ -29,8 +29,6 @@ theory_wmaxsat::theory_wmaxsat(ast_manager& m, ref<filter_model_converter>& mc):
m_mc(mc),
m_vars(m),
m_fmls(m),
m_min_cost_atom(m),
m_min_cost_atoms(m),
m_zweights(m_mpz),
m_old_values(m_mpz),
m_zcost(m_mpz),
@ -138,21 +136,6 @@ rational const& theory_wmaxsat::get_min_cost() {
return m_rmin_cost;
}
expr* theory_wmaxsat::set_min_cost(rational const& c) {
m_normalize = true;
ast_manager& m = get_manager();
std::ostringstream strm;
strm << "cost <= " << c;
m_rmin_cost = c;
m_min_cost_atom = m.mk_fresh_const(strm.str().c_str(), m.mk_bool_sort());
m_min_cost_atoms.push_back(m_min_cost_atom);
m_mc->insert(m_min_cost_atom->get_decl());
m_min_cost_bv = register_var(m_min_cost_atom, false);
return m_min_cost_atom;
}
void theory_wmaxsat::assign_eh(bool_var v, bool is_true) {
TRACE("opt", tout << "Assign " << mk_pp(m_vars[m_bool2var[v]].get(), get_manager()) << " " << is_true << "\n";);
if (is_true) {
@ -194,8 +177,6 @@ void theory_wmaxsat::reset_eh() {
m_cost_save.reset();
m_bool2var.reset();
m_var2bool.reset();
m_min_cost_atom = 0;
m_min_cost_atoms.reset();
m_propagate = false;
m_found_optimal = false;
m_assigned.reset();
@ -231,9 +212,6 @@ expr_ref theory_wmaxsat::mk_block() {
weight += m_zweights[costs[i]];
disj.push_back(m.mk_not(m_vars[costs[i]].get()));
}
if (m_min_cost_atom) {
disj.push_back(m.mk_not(m_min_cost_atom));
}
if (is_optimal()) {
unsynch_mpq_manager mgr;
scoped_mpq q(mgr);
@ -272,9 +250,6 @@ expr_ref theory_wmaxsat::mk_optimal_block(svector<bool_var> const& ws, rational
m_cost_save.push_back(v);
disj.push_back(m.mk_not(m_vars[v].get()));
}
if (m_min_cost_atom) {
disj.push_back(m.mk_not(m_min_cost_atom));
}
expr_ref result(m.mk_or(disj.size(), disj.c_ptr()), m);
return result;
}
@ -297,9 +272,6 @@ void theory_wmaxsat::block() {
weight += m_zweights[costs[i]];
lits.push_back(~literal(m_var2bool[costs[i]]));
}
if (m_min_cost_atom) {
lits.push_back(~literal(m_min_cost_bv));
}
TRACE("opt",
tout << "block: ";
for (unsigned i = 0; i < lits.size(); ++i) {

View file

@ -32,9 +32,6 @@ namespace smt {
mutable unsynch_mpz_manager m_mpz;
app_ref_vector m_vars; // Auxiliary variables per soft clause
expr_ref_vector m_fmls; // Formulas per soft clause
app_ref m_min_cost_atom; // atom tracking modified lower bound
app_ref_vector m_min_cost_atoms;
bool_var m_min_cost_bv; // max cost Boolean variable
vector<rational> m_rweights; // weights of theory variables.
scoped_mpz_vector m_zweights;
scoped_mpz_vector m_old_values;
@ -60,7 +57,6 @@ namespace smt {
bool_var assert_weighted(expr* fml, rational const& w);
bool_var register_var(app* var, bool attach);
rational const& get_min_cost();
expr* set_min_cost(rational const& c);
class numeral_trail : public trail<context> {
typedef scoped_mpz T;
T & m_value;