Skip to content

Commit da9b037

Browse files
fix #4233
1 parent fc6bdb9 commit da9b037

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/opt/wmax.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace opt {
5454
lbool operator()() override {
5555
TRACE("opt", tout << "weighted maxsat\n";);
5656
scoped_ensure_theory wth(*this);
57-
obj_map<expr, rational> soft;
57+
obj_map<expr, rational> soft;
5858
reset();
5959
lbool is_sat = find_mutexes(soft);
6060
if (is_sat != l_true) {
@@ -64,19 +64,18 @@ namespace opt {
6464
expr_ref_vector asms(m);
6565
vector<expr_ref_vector> cores;
6666

67-
obj_map<expr, rational>::iterator it = soft.begin(), end = soft.end();
68-
for (; it != end; ++it) {
69-
assert_weighted(wth(), it->m_key, it->m_value);
70-
if (!is_true(it->m_key)) {
71-
m_upper += it->m_value;
67+
for (auto const& kv : soft) {
68+
assert_weighted(wth(), kv.m_key, kv.m_value);
69+
if (!is_true(kv.m_key)) {
70+
m_upper += kv.m_value;
7271
}
7372
}
7473
wth().init_min_cost(m_upper - m_lower);
7574
trace_bounds("wmax");
76-
77-
TRACE("opt",
78-
s().display(tout)<< "\n";
79-
tout << "lower: " << m_lower << " upper: " << m_upper << "\n";);
75+
76+
TRACE("opt",
77+
s().display(tout) << "\n";
78+
tout << "lower: " << m_lower << " upper: " << m_upper << "\n";);
8079
while (m.inc() && m_lower < m_upper) {
8180
is_sat = s().check_sat(0, nullptr);
8281
if (!m.inc()) {
@@ -104,8 +103,9 @@ namespace opt {
104103
SASSERT(m_lower <= m_upper);
105104
}
106105

107-
update_assignment();
108-
106+
if (m_model)
107+
update_assignment();
108+
109109
if (m.inc() && is_sat == l_undef && m_lower == m_upper) {
110110
is_sat = l_true;
111111
}

0 commit comments

Comments
 (0)