File tree 1 file changed +15
-8
lines changed
1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -884,8 +884,16 @@ namespace smt {
884
884
if (v == null_theory_var) {
885
885
v = mk_var (e);
886
886
}
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
+ }
889
897
}
890
898
return true ;
891
899
}
@@ -912,9 +920,8 @@ namespace smt {
912
920
has_shared = false ;
913
921
914
922
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 << " " ;
918
925
}
919
926
verbose_stream () << " + " << m_objective_consts[v] << " \n " ;);
920
927
@@ -970,9 +977,9 @@ namespace smt {
970
977
// add objective function as row.
971
978
coeffs.reset ();
972
979
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 );
976
983
}
977
984
coeffs.push_back (mpq (1 ));
978
985
vars.push_back (w);
You can’t perform that action at this time.
0 commit comments