Skip to content

Commit bbaec0b

Browse files
committed
trying randomly shuffle the indices in the slack utilization
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent 52241b6 commit bbaec0b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/math/lp/lar_solver.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,26 +1476,33 @@ namespace lp {
14761476
const vector<std::pair<mpq, unsigned>>& inf_row,
14771477
int inf_sign) const {
14781478

1479-
#if 1
14801479
impq slack(0);
14811480

1481+
std_vector<unsigned> indices;
14821482
for (auto& [coeff, j] : inf_row) {
14831483
int adj_sign = coeff.is_pos() ? inf_sign : -inf_sign;
14841484
slack += coeff * (adj_sign < 0 ? get_upper_bound(j) : get_lower_bound(j));
1485+
indices.push_back(indices.size());
14851486
}
14861487

14871488
#define get_sign(_x_) (_x_.is_pos() ? 1 : (_x_.is_neg() ? -1 : 0))
14881489
int sign = get_sign(slack);
14891490

1490-
#endif
1491+
for (unsigned j = indices.size(); j-- > 0; ) {
1492+
unsigned k = m_imp->m_settings.random_next(j+1);
1493+
if (k != j)
1494+
std::swap(indices[j], indices[k]);
1495+
}
14911496

1492-
for (auto& [coeff, j] : inf_row) {
1497+
for (unsigned k : indices) {
1498+
const auto& p = inf_row[k];
1499+
unsigned j = p.second;
1500+
const mpq& coeff = p.first;
14931501
int adj_sign = coeff.is_pos() ? inf_sign : -inf_sign;
14941502
bool is_upper = adj_sign < 0;
14951503
const column& ul = m_imp->m_columns[j];
14961504
u_dependency* bound_constr_i = is_upper ? ul.upper_bound_witness() : ul.lower_bound_witness();
14971505

1498-
#if 1
14991506
if(is_upper) {
15001507
if (ul.previous_upper() != UINT_MAX) {
15011508
auto const& [_is_upper, _j, _bound, _column] = m_imp->m_column_updates[ul.previous_upper()];
@@ -1518,8 +1525,7 @@ namespace lp {
15181525
}
15191526
}
15201527
}
1521-
#endif
1522-
1528+
15231529
svector<constraint_index> deps;
15241530
dep_manager().linearize(bound_constr_i, deps);
15251531
for (auto d : deps) {

0 commit comments

Comments
 (0)