@@ -146,13 +146,10 @@ namespace smt {
146
146
*/
147
147
template <typename Ext>
148
148
theory_var theory_arith<Ext>::find_infeasible_int_base_var() {
149
- theory_var v = find_bounded_infeasible_int_base_var ();
150
- if (v != null_theory_var) {
151
- TRACE (" find_infeasible_int_base_var" , display_var (tout, v););
152
- return v;
153
- }
149
+ theory_var r = find_bounded_infeasible_int_base_var ();
150
+ CTRACE (" find_infeasible_int_base_var" , r != null_theory_var, display_var (tout << " bounded infeasible" , r););
151
+
154
152
unsigned n = 0 ;
155
- theory_var r = null_theory_var;
156
153
157
154
#define SELECT_VAR (VAR ) if (r == null_theory_var) { n = 1 ; r = VAR; } else { n++; SASSERT (n >= 2 ); if (m_random () % n == 0 ) r = VAR; }
158
155
@@ -172,6 +169,7 @@ namespace smt {
172
169
}
173
170
}
174
171
}
172
+ CTRACE (" find_infeasible_int_base_var" , r != null_theory_var, tout << " found small value v" << r << " \n " );
175
173
}
176
174
177
175
if (r == null_theory_var) {
@@ -181,6 +179,8 @@ namespace smt {
181
179
SELECT_VAR (v);
182
180
}
183
181
}
182
+ CTRACE (" find_infeasible_int_base_var" , r != null_theory_var, tout << " found base v" << r << " \n " );
183
+
184
184
}
185
185
186
186
if (r == null_theory_var) {
@@ -191,6 +191,7 @@ namespace smt {
191
191
SELECT_VAR (v);
192
192
}
193
193
}
194
+ CTRACE (" find_infeasible_int_base_var" , r != null_theory_var, tout << " found quasi base v" << r << " \n " );
194
195
}
195
196
CASSERT (" arith" , wf_rows ());
196
197
CASSERT (" arith" , wf_columns ());
@@ -438,15 +439,13 @@ namespace smt {
438
439
bool theory_arith<Ext>::is_gomory_cut_target(row const & r) {
439
440
TRACE (" gomory_cut" , r.display (tout););
440
441
theory_var b = r.get_base_var ();
441
- typename vector<row_entry>::const_iterator it = r.begin_entries ();
442
- typename vector<row_entry>::const_iterator end = r.end_entries ();
443
- for (; it != end; ++it) {
442
+ for (auto & e : r) {
444
443
// All non base variables must be at their bounds and assigned to rationals (that is, infinitesimals are not allowed).
445
- if (!it-> is_dead () && it-> m_var != b && (!at_bound (it-> m_var ) || !get_value (it-> m_var ).is_rational ())) {
444
+ if (!e. is_dead () && e. m_var != b && (!at_bound (e. m_var ) || !get_value (e. m_var ).is_rational ())) {
446
445
TRACE (" gomory_cut" , tout << " row is not gomory cut target:\n " ;
447
- display_var (tout, it-> m_var );
448
- tout << " at_bound: " << at_bound (it-> m_var ) << " \n " ;
449
- tout << " infinitesimal: " << !get_value (it-> m_var ).is_rational () << " \n " ;);
446
+ display_var (tout, e. m_var );
447
+ tout << " at_bound: " << at_bound (e. m_var ) << " \n " ;
448
+ tout << " infinitesimal: " << !get_value (e. m_var ).is_rational () << " \n " ;);
450
449
return false ;
451
450
}
452
451
}
@@ -541,12 +540,10 @@ namespace smt {
541
540
numeral lcm_den (1 );
542
541
unsigned num_ints = 0 ;
543
542
544
- typename vector<row_entry>::const_iterator it = r.begin_entries ();
545
- typename vector<row_entry>::const_iterator end = r.end_entries ();
546
- for (; it != end; ++it) {
547
- if (!it->is_dead () && it->m_var != x_i) {
548
- theory_var x_j = it->m_var ;
549
- numeral a_ij = it->m_coeff ;
543
+ for (row_entry const & e : r) {
544
+ if (!e.is_dead () && e.m_var != x_i) {
545
+ theory_var x_j = e.m_var ;
546
+ numeral a_ij = e.m_coeff ;
550
547
a_ij.neg (); // make the used format compatible with the format used in: Integrating Simplex with DPLL(T)
551
548
if (is_real (x_j)) {
552
549
numeral new_a_ij;
@@ -709,38 +706,36 @@ namespace smt {
709
706
numeral gcds (0 );
710
707
numeral least_coeff (0 );
711
708
bool least_coeff_is_bounded = false ;
712
- typename vector<row_entry>::const_iterator it = r.begin_entries ();
713
- typename vector<row_entry>::const_iterator end = r.end_entries ();
714
- for (; it != end; ++it) {
715
- if (!it->is_dead ()) {
716
- if (is_fixed (it->m_var )) {
717
- // WARNING: it is not safe to use get_value(it->m_var) here, since
718
- // get_value(it->m_var) may not satisfy it->m_var bounds at this point.
719
- numeral aux = lcm_den * it->m_coeff ;
720
- consts += aux * lower_bound (it->m_var ).get_rational ();
709
+ for (row_entry const & e : r) {
710
+ if (!e.is_dead ()) {
711
+ if (is_fixed (e.m_var )) {
712
+ // WARNING: it is not safe to use get_value(e.m_var) here, since
713
+ // get_value(e.m_var) may not satisfy e.m_var bounds at this point.
714
+ numeral aux = lcm_den * e.m_coeff ;
715
+ consts += aux * lower_bound (e.m_var ).get_rational ();
721
716
}
722
- else if (is_real (it-> m_var )) {
717
+ else if (is_real (e. m_var )) {
723
718
return true ;
724
719
}
725
720
else if (gcds.is_zero ()) {
726
- gcds = abs (lcm_den * it-> m_coeff );
721
+ gcds = abs (lcm_den * e. m_coeff );
727
722
least_coeff = gcds;
728
- least_coeff_is_bounded = is_bounded (it-> m_var );
723
+ least_coeff_is_bounded = is_bounded (e. m_var );
729
724
}
730
725
else {
731
- numeral aux = abs (lcm_den * it-> m_coeff );
726
+ numeral aux = abs (lcm_den * e. m_coeff );
732
727
gcds = gcd (gcds, aux);
733
728
if (aux < least_coeff) {
734
729
least_coeff = aux;
735
- least_coeff_is_bounded = is_bounded (it-> m_var );
730
+ least_coeff_is_bounded = is_bounded (e. m_var );
736
731
}
737
732
else if (least_coeff_is_bounded && aux == least_coeff) {
738
- least_coeff_is_bounded = is_bounded (it-> m_var );
733
+ least_coeff_is_bounded = is_bounded (e. m_var );
739
734
}
740
735
}
741
736
SASSERT (gcds.is_int ());
742
737
SASSERT (least_coeff.is_int ());
743
- TRACE (" gcd_test_bug" , tout << " coeff: " << it-> m_coeff << " , gcds: " << gcds
738
+ TRACE (" gcd_test_bug" , tout << " coeff: " << e. m_coeff << " , gcds: " << gcds
744
739
<< " least_coeff: " << least_coeff << " consts: " << consts << " \n " ;);
745
740
}
746
741
}
@@ -790,14 +785,11 @@ namespace smt {
790
785
791
786
antecedents ante (*this );
792
787
793
-
794
- typename vector<row_entry>::const_iterator it = r.begin_entries ();
795
- typename vector<row_entry>::const_iterator end = r.end_entries ();
796
- for (; it != end; ++it) {
797
- if (!it->is_dead () && !is_fixed (it->m_var )) {
798
- theory_var v = it->m_var ;
788
+ for (auto const & e : r) {
789
+ if (!e.is_dead () && !is_fixed (e.m_var )) {
790
+ theory_var v = e.m_var ;
799
791
SASSERT (!is_real (v));
800
- numeral ncoeff = lcm_den * it-> m_coeff ;
792
+ numeral ncoeff = lcm_den * e. m_coeff ;
801
793
SASSERT (ncoeff.is_int ());
802
794
numeral abs_ncoeff = abs (ncoeff);
803
795
if (abs_ncoeff == least_coeff) {
@@ -814,8 +806,8 @@ namespace smt {
814
806
// u += ncoeff * lower_bound(v).get_rational();
815
807
u.addmul (ncoeff, lower_bound (v).get_rational ());
816
808
}
817
- lower (v)->push_justification (ante, it-> m_coeff , coeffs_enabled ());
818
- upper (v)->push_justification (ante, it-> m_coeff , coeffs_enabled ());
809
+ lower (v)->push_justification (ante, e. m_coeff , coeffs_enabled ());
810
+ upper (v)->push_justification (ante, e. m_coeff , coeffs_enabled ());
819
811
}
820
812
else if (gcds.is_zero ()) {
821
813
gcds = abs_ncoeff;
0 commit comments