@@ -923,6 +923,7 @@ namespace lp {
923
923
const auto & row = m_e_matrix.m_rows [ei];
924
924
for (const auto & p : row) {
925
925
if (m_k2s.has_key (p.var ())) {
926
+ /*
926
927
std::cout << "entry:" << ei << " belongs to f but depends on column " << p.var() << std::endl;
927
928
std::cout << "m_var_register.local_to_external(p.var()):" << m_var_register.local_to_external(p.var()) << std::endl;
928
929
print_entry(ei, std::cout);
@@ -933,7 +934,8 @@ namespace lp {
933
934
934
935
std::cout << std::endl;
935
936
std::cout << "column " << p.var() << " is subst by entry:";
936
- print_entry (m_k2s[p.var ()],std::cout) << std::endl;
937
+ print_entry(m_k2s[p.var()],std::cout) << std::endl;
938
+ */
937
939
return false ;
938
940
}
939
941
}
@@ -2190,6 +2192,9 @@ namespace lp {
2190
2192
// returns true if an equlity was rewritten and false otherwise
2191
2193
bool rewrite_eqs () {
2192
2194
unsigned h = -1 ;
2195
+ unsigned n = 0 ; // number of choices for a fresh variable
2196
+ mpq the_smallest_ahk;
2197
+ unsigned kh, kh_sign;
2193
2198
for (unsigned ei=0 ; ei < m_e_matrix.row_count (); ei++) {
2194
2199
if (belongs_to_s (ei)) continue ;
2195
2200
if (m_e_matrix.m_rows [ei].size () == 0 ) {
@@ -2200,23 +2205,31 @@ namespace lp {
2200
2205
return false ;
2201
2206
}
2202
2207
}
2203
- h = ei;
2204
- break ;
2205
- }
2206
- if (h == UINT_MAX)
2207
- return false ;
2208
- auto [ahk, k, k_sign] = find_minimal_abs_coeff (h);
2209
- TRACE (" dioph_eq" , tout << " eh:" ; print_entry (h, tout);
2210
- tout << " ahk:" << ahk << " , k:" << k << " , k_sign:" << k_sign
2211
- << std::endl;);
2208
+ auto [ahk, k, k_sign] = find_minimal_abs_coeff (ei);
2209
+ if (ahk.is_one ()) {
2210
+ TRACE (" dioph_eq" , tout << " push to S:\n " ; print_entry (ei, tout););
2211
+ move_entry_from_f_to_s (k, ei);
2212
+ eliminate_var_in_f (ei, k, k_sign);
2213
+ return true ;
2214
+ }
2212
2215
2213
- if (ahk.is_one ()) {
2214
- TRACE (" dioph_eq" , tout << " push to S:\n " ; print_entry (h, tout););
2215
- move_entry_from_f_to_s (k, h);
2216
- eliminate_var_in_f (h, k, k_sign);
2217
- } else {
2218
- fresh_var_step (h, k, ahk * mpq (k_sign));
2216
+ if (n == 0 || the_smallest_ahk > ahk) {
2217
+ n = 1 ;
2218
+ the_smallest_ahk = ahk;
2219
+ h = ei;
2220
+ kh = k;
2221
+ kh_sign = k_sign;
2222
+ continue ;
2223
+ }
2224
+ if (the_smallest_ahk == ahk && lra.settings ().random_next () % (++n) == 0 ) {
2225
+ h = ei;
2226
+ kh = k;
2227
+ kh_sign = k_sign;
2228
+ }
2219
2229
}
2230
+ if (h == UINT_MAX) return false ;
2231
+ SASSERT (!the_smallest_ahk.is_one ());
2232
+ fresh_var_step (h, kh, the_smallest_ahk * mpq (kh_sign));
2220
2233
return true ;
2221
2234
}
2222
2235
0 commit comments