@@ -1878,12 +1878,10 @@ namespace lp {
1878
1878
}
1879
1879
1880
1880
lia_move add_var_bound_for_branch (const branch& b) {
1881
- if (b.m_left ) {
1881
+ if (b.m_left )
1882
1882
lra.add_var_bound (b.m_j , lconstraint_kind::LE, b.m_rs );
1883
- }
1884
- else {
1883
+ else
1885
1884
lra.add_var_bound (b.m_j , lconstraint_kind::GE, b.m_rs + mpq (1 ));
1886
- }
1887
1885
TRACE (" dio_br" , lra.print_column_info (b.m_j , tout) << " add bound" << std::endl;);
1888
1886
if (lra.column_is_fixed (b.m_j )) {
1889
1887
unsigned local_bj;
@@ -1951,7 +1949,9 @@ namespace lp {
1951
1949
}
1952
1950
auto st = lra.find_feasible_solution ();
1953
1951
TRACE (" dio_br" , tout << " st:" << lp_status_to_string (st) << std::endl;);
1954
- if ((int )st >= (int )(lp_status::FEASIBLE)) {
1952
+ if (st == lp_status::CANCELLED)
1953
+ return lia_move::undef;
1954
+ else if ((int )st >= (int )(lp_status::FEASIBLE)) {
1955
1955
// have a feasible solution
1956
1956
unsigned n_of_ii = get_number_of_int_inf ();
1957
1957
TRACE (" dio_br" , tout << " n_of_ii:" << n_of_ii << " \n " ;);
@@ -1965,7 +1965,6 @@ namespace lp {
1965
1965
need_create_branch = true ;
1966
1966
}
1967
1967
else {
1968
- if (st == lp_status::CANCELLED) return lia_move::undef;
1969
1968
collect_evidence ();
1970
1969
undo_explored_branches ();
1971
1970
if (m_branch_stack.size () == 0 ) {
@@ -2002,16 +2001,13 @@ namespace lp {
2002
2001
2003
2002
void update_branch_stats (const branch& b, unsigned n_of_ii) {
2004
2003
// Ensure the branch stats vector is large enough
2005
- if (b.m_j >= m_branch_stats.size ()) {
2004
+ if (b.m_j >= m_branch_stats.size ())
2006
2005
m_branch_stats.resize (b.m_j + 1 );
2007
- }
2008
2006
2009
- if (b.m_left ) {
2007
+ if (b.m_left )
2010
2008
m_branch_stats[b.m_j ].m_ii_after_left .push_back (n_of_ii);
2011
- }
2012
- else {
2009
+ else
2013
2010
m_branch_stats[b.m_j ].m_ii_after_right .push_back (n_of_ii);
2014
- }
2015
2011
}
2016
2012
2017
2013
branch create_branch () {
@@ -2208,13 +2204,10 @@ namespace lp {
2208
2204
pivot_col_cell_index;
2209
2205
}
2210
2206
2211
- unsigned cell_to_process = static_cast <unsigned >(column.size () - 1 );
2212
- while (cell_to_process > 0 ) {
2207
+ for (auto cell_to_process = column.size (); cell_to_process-- > 0 ; ) {
2213
2208
auto & c = column[cell_to_process];
2214
- if (belongs_to_s (c.var ())) {
2215
- cell_to_process--;
2209
+ if (belongs_to_s (c.var ()))
2216
2210
continue ;
2217
- }
2218
2211
2219
2212
SASSERT (c.var () != ei && entry_invariant (c.var ()));
2220
2213
mpq coeff = m_e_matrix.get_val (c);
@@ -2235,7 +2228,6 @@ namespace lp {
2235
2228
<< std::endl;
2236
2229
});
2237
2230
SASSERT (entry_invariant (i));
2238
- cell_to_process--;
2239
2231
}
2240
2232
SASSERT (is_eliminated_from_f (j));
2241
2233
}
@@ -2248,31 +2240,29 @@ namespace lp {
2248
2240
print_lar_term_L (t, tout) << std::endl;);
2249
2241
auto & column = m_e_matrix.m_columns [j];
2250
2242
2251
- int cell_to_process = static_cast <int >(column.size () - 1 );
2252
- while (cell_to_process >= 0 ) {
2243
+ for (auto cell_to_process = column.size (); cell_to_process-- > 0 ; ) {
2253
2244
auto & c = column[cell_to_process];
2254
- if (belongs_to_s (c.var ())) {
2255
- cell_to_process--;
2245
+ if (belongs_to_s (c.var ()))
2256
2246
continue ;
2257
- }
2258
2247
2259
2248
mpq coeff = m_e_matrix.get_val (c);
2260
2249
TRACE (" dio" , tout << " before pivot entry :" ; print_entry (c.var (), tout) << std::endl;);
2261
2250
m_e_matrix.pivot_term_to_row_given_cell (t, c, j, j_sign);
2262
2251
TRACE (" dio" , tout << " after pivoting c_row:" ;
2263
2252
print_entry (c.var (), tout););
2264
2253
SASSERT (entry_invariant (c.var ()));
2265
- cell_to_process--;
2266
2254
}
2267
2255
SASSERT (is_eliminated_from_f (j));
2268
2256
}
2269
2257
2270
2258
bool is_eliminated_from_f (unsigned j) const {
2271
2259
for (unsigned ei = 0 ; ei < m_e_matrix.row_count (); ei++) {
2272
- if (!belongs_to_f (ei)) continue ;
2260
+ if (!belongs_to_f (ei))
2261
+ continue ;
2273
2262
const auto & row = m_e_matrix.m_rows [ei];
2274
2263
bool eliminated_in_row = all_of (row, [j](auto & p) { return p.var () != j; });
2275
- if (!eliminated_in_row) return false ;
2264
+ if (!eliminated_in_row)
2265
+ return false ;
2276
2266
}
2277
2267
return true ;
2278
2268
}
0 commit comments