Skip to content

Commit 6b32aae

Browse files
committed
remove slack heuristic
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent a5e5d4d commit 6b32aae

File tree

2 files changed

+18
-71
lines changed

2 files changed

+18
-71
lines changed

src/math/lp/lar_solver.cpp

Lines changed: 18 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,23 @@ namespace lp {
172172
", external = " << equal_to_j << "\n";);
173173
}
174174
}
175-
175+
void get_infeasibility_explanation_for_inf_sign(
176+
explanation& exp,
177+
const vector<std::pair<mpq, unsigned>>& inf_row,
178+
int inf_sign) const {
179+
for (auto& [coeff, j]: inf_row) {
180+
int adj_sign = coeff.is_pos() ? inf_sign : -inf_sign;
181+
const column& ul = m_columns[j];
182+
183+
u_dependency* bound_constr_i = adj_sign < 0 ? ul.upper_bound_witness() : ul.lower_bound_witness();
184+
svector<constraint_index> deps;
185+
m_dependencies.linearize(bound_constr_i, deps);
186+
for (auto d : deps) {
187+
SASSERT(m_constraints.valid_index(d));
188+
exp.add_pair(d, coeff);
189+
}
190+
}
191+
}
176192
}; // imp
177193
unsigned_vector& lar_solver::row_bounds_to_replay() { return m_imp->m_row_bounds_to_replay; }
178194

@@ -1467,75 +1483,10 @@ namespace lp {
14671483
// the infeasibility sign
14681484
int inf_sign;
14691485
auto inf_row = get_core_solver().get_infeasibility_info(inf_sign);
1470-
get_infeasibility_explanation_for_inf_sign(exp, inf_row, inf_sign);
1486+
m_imp->get_infeasibility_explanation_for_inf_sign(exp, inf_row, inf_sign);
14711487
SASSERT(explanation_is_correct(exp));
14721488
}
14731489

1474-
void lar_solver::get_infeasibility_explanation_for_inf_sign(
1475-
explanation& exp,
1476-
const vector<std::pair<mpq, unsigned>>& inf_row,
1477-
int inf_sign) const {
1478-
#if 0
1479-
impq slack(0);
1480-
1481-
std_vector<unsigned> indices;
1482-
for (auto& [coeff, j] : inf_row) {
1483-
int adj_sign = coeff.is_pos() ? inf_sign : -inf_sign;
1484-
slack += coeff * (adj_sign < 0 ? get_upper_bound(j) : get_lower_bound(j));
1485-
indices.push_back(indices.size());
1486-
}
1487-
1488-
#define get_sign(_x_) (_x_.is_pos() ? 1 : (_x_.is_neg() ? -1 : 0))
1489-
int sign = get_sign(slack);
1490-
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-
}
1496-
#endif
1497-
for (auto& [coeff, j]: inf_row) {
1498-
// for (unsigned k : indices) {
1499-
// const auto& p = inf_row[k];
1500-
// unsigned j = p.second;
1501-
// const mpq& coeff = p.first;
1502-
int adj_sign = coeff.is_pos() ? inf_sign : -inf_sign;
1503-
bool is_upper = adj_sign < 0;
1504-
const column& ul = m_imp->m_columns[j];
1505-
u_dependency* bound_constr_i = is_upper ? ul.upper_bound_witness() : ul.lower_bound_witness();
1506-
#if 0
1507-
if(is_upper) {
1508-
if (ul.previous_upper() != UINT_MAX) {
1509-
auto const& [_is_upper, _j, _bound, _column] = m_imp->m_column_updates[ul.previous_upper()];
1510-
auto new_slack = slack + coeff * (_bound - get_upper_bound(j));
1511-
if (sign == get_sign(new_slack)) {
1512-
//verbose_stream() << "can weaken upper j" << j << " " << coeff << " " << get_upper_bound(j) << " " << _bound << "\n";
1513-
slack = new_slack;
1514-
bound_constr_i = _column.upper_bound_witness();
1515-
}
1516-
}
1517-
}
1518-
else {
1519-
if (ul.previous_lower() != UINT_MAX) {
1520-
auto const& [_is_upper, _j, _bound, _column] = m_imp->m_column_updates[ul.previous_lower()];
1521-
auto new_slack = slack + coeff * (_bound - get_lower_bound(j));
1522-
if (sign == get_sign(new_slack)) {
1523-
//verbose_stream() << "can weaken lower j" << j << " " << coeff << " " << get_lower_bound(j) << " " << _bound << "\n";
1524-
slack = new_slack;
1525-
bound_constr_i = _column.lower_bound_witness();
1526-
}
1527-
}
1528-
}
1529-
#endif
1530-
svector<constraint_index> deps;
1531-
dep_manager().linearize(bound_constr_i, deps);
1532-
for (auto d : deps) {
1533-
SASSERT(m_imp->m_constraints.valid_index(d));
1534-
exp.add_pair(d, coeff);
1535-
}
1536-
}
1537-
}
1538-
15391490
// (x, y) != (x', y') => (x + delta*y) != (x' + delta*y')
15401491
void lar_solver::get_model(std::unordered_map<lpvar, mpq>& variable_values) const {
15411492
variable_values.clear();

src/math/lp/lar_solver.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ class lar_solver : public column_namer {
155155
bool explanation_is_correct(explanation&) const;
156156
bool inf_explanation_is_correct() const;
157157
mpq sum_of_right_sides_of_explanation(explanation&) const;
158-
void get_infeasibility_explanation_for_inf_sign(
159-
explanation& exp,
160-
const vector<std::pair<mpq, unsigned>>& inf_row,
161-
int inf_sign) const;
162158
mpq get_left_side_val(const lar_base_constraint& cns, const std::unordered_map<lpvar, mpq>& var_map) const;
163159
void fill_var_set_for_random_update(unsigned sz, lpvar const* vars, vector<unsigned>& column_list);
164160
bool column_represents_row_in_tableau(unsigned j);

0 commit comments

Comments
 (0)