mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
fix #4233
This commit is contained in:
parent
fc6bdb9708
commit
da9b037f2a
|
@ -54,7 +54,7 @@ namespace opt {
|
||||||
lbool operator()() override {
|
lbool operator()() override {
|
||||||
TRACE("opt", tout << "weighted maxsat\n";);
|
TRACE("opt", tout << "weighted maxsat\n";);
|
||||||
scoped_ensure_theory wth(*this);
|
scoped_ensure_theory wth(*this);
|
||||||
obj_map<expr, rational> soft;
|
obj_map<expr, rational> soft;
|
||||||
reset();
|
reset();
|
||||||
lbool is_sat = find_mutexes(soft);
|
lbool is_sat = find_mutexes(soft);
|
||||||
if (is_sat != l_true) {
|
if (is_sat != l_true) {
|
||||||
|
@ -64,19 +64,18 @@ namespace opt {
|
||||||
expr_ref_vector asms(m);
|
expr_ref_vector asms(m);
|
||||||
vector<expr_ref_vector> cores;
|
vector<expr_ref_vector> cores;
|
||||||
|
|
||||||
obj_map<expr, rational>::iterator it = soft.begin(), end = soft.end();
|
for (auto const& kv : soft) {
|
||||||
for (; it != end; ++it) {
|
assert_weighted(wth(), kv.m_key, kv.m_value);
|
||||||
assert_weighted(wth(), it->m_key, it->m_value);
|
if (!is_true(kv.m_key)) {
|
||||||
if (!is_true(it->m_key)) {
|
m_upper += kv.m_value;
|
||||||
m_upper += it->m_value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wth().init_min_cost(m_upper - m_lower);
|
wth().init_min_cost(m_upper - m_lower);
|
||||||
trace_bounds("wmax");
|
trace_bounds("wmax");
|
||||||
|
|
||||||
TRACE("opt",
|
TRACE("opt",
|
||||||
s().display(tout)<< "\n";
|
s().display(tout) << "\n";
|
||||||
tout << "lower: " << m_lower << " upper: " << m_upper << "\n";);
|
tout << "lower: " << m_lower << " upper: " << m_upper << "\n";);
|
||||||
while (m.inc() && m_lower < m_upper) {
|
while (m.inc() && m_lower < m_upper) {
|
||||||
is_sat = s().check_sat(0, nullptr);
|
is_sat = s().check_sat(0, nullptr);
|
||||||
if (!m.inc()) {
|
if (!m.inc()) {
|
||||||
|
@ -104,8 +103,9 @@ namespace opt {
|
||||||
SASSERT(m_lower <= m_upper);
|
SASSERT(m_lower <= m_upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_assignment();
|
if (m_model)
|
||||||
|
update_assignment();
|
||||||
|
|
||||||
if (m.inc() && is_sat == l_undef && m_lower == m_upper) {
|
if (m.inc() && is_sat == l_undef && m_lower == m_upper) {
|
||||||
is_sat = l_true;
|
is_sat = l_true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue