3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00
This commit is contained in:
Nikolaj Bjorner 2020-04-28 13:44:57 -07:00
parent b571e43f85
commit fa88dabd10

View file

@ -884,8 +884,16 @@ namespace smt {
if (v == null_theory_var) { if (v == null_theory_var) {
v = mk_var(e); v = mk_var(e);
} }
bool found = false;
objective.push_back(std::make_pair(v, m)); for (auto& p : objective) {
if (p.first == v) {
p.second += m;
found = true;
}
}
if (!found) {
objective.push_back(std::make_pair(v, m));
}
} }
return true; return true;
} }
@ -912,9 +920,8 @@ namespace smt {
has_shared = false; has_shared = false;
IF_VERBOSE(4, IF_VERBOSE(4,
for (unsigned i = 0; i < objective.size(); ++i) { for (auto const& o : objective) {
verbose_stream() << objective[i].second verbose_stream() << o.second << " * v" << o.first << " ";
<< " * v" << objective[i].first << " ";
} }
verbose_stream() << " + " << m_objective_consts[v] << "\n";); verbose_stream() << " + " << m_objective_consts[v] << "\n";);
@ -970,9 +977,9 @@ namespace smt {
// add objective function as row. // add objective function as row.
coeffs.reset(); coeffs.reset();
vars.reset(); vars.reset();
for (unsigned i = 0; i < objective.size(); ++i) { for (auto const& o : objective) {
coeffs.push_back(objective[i].second.to_mpq()); coeffs.push_back(o.second.to_mpq());
vars.push_back(objective[i].first); vars.push_back(o.first);
} }
coeffs.push_back(mpq(1)); coeffs.push_back(mpq(1));
vars.push_back(w); vars.push_back(w);