Skip to content

Commit fa88dab

Browse files
fix #4135
1 parent b571e43 commit fa88dab

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/smt/theory_dense_diff_logic_def.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,16 @@ namespace smt {
884884
if (v == null_theory_var) {
885885
v = mk_var(e);
886886
}
887-
888-
objective.push_back(std::make_pair(v, m));
887+
bool found = false;
888+
for (auto& p : objective) {
889+
if (p.first == v) {
890+
p.second += m;
891+
found = true;
892+
}
893+
}
894+
if (!found) {
895+
objective.push_back(std::make_pair(v, m));
896+
}
889897
}
890898
return true;
891899
}
@@ -912,9 +920,8 @@ namespace smt {
912920
has_shared = false;
913921

914922
IF_VERBOSE(4,
915-
for (unsigned i = 0; i < objective.size(); ++i) {
916-
verbose_stream() << objective[i].second
917-
<< " * v" << objective[i].first << " ";
923+
for (auto const& o : objective) {
924+
verbose_stream() << o.second << " * v" << o.first << " ";
918925
}
919926
verbose_stream() << " + " << m_objective_consts[v] << "\n";);
920927

@@ -970,9 +977,9 @@ namespace smt {
970977
// add objective function as row.
971978
coeffs.reset();
972979
vars.reset();
973-
for (unsigned i = 0; i < objective.size(); ++i) {
974-
coeffs.push_back(objective[i].second.to_mpq());
975-
vars.push_back(objective[i].first);
980+
for (auto const& o : objective) {
981+
coeffs.push_back(o.second.to_mpq());
982+
vars.push_back(o.first);
976983
}
977984
coeffs.push_back(mpq(1));
978985
vars.push_back(w);

0 commit comments

Comments
 (0)