@@ -172,7 +172,23 @@ namespace lp {
172
172
" , external = " << equal_to_j << " \n " ;);
173
173
}
174
174
}
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
+ }
176
192
}; // imp
177
193
unsigned_vector& lar_solver::row_bounds_to_replay () { return m_imp->m_row_bounds_to_replay ; }
178
194
@@ -1467,75 +1483,10 @@ namespace lp {
1467
1483
// the infeasibility sign
1468
1484
int inf_sign;
1469
1485
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);
1471
1487
SASSERT (explanation_is_correct (exp ));
1472
1488
}
1473
1489
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
-
1539
1490
// (x, y) != (x', y') => (x + delta*y) != (x' + delta*y')
1540
1491
void lar_solver::get_model (std::unordered_map<lpvar, mpq>& variable_values) const {
1541
1492
variable_values.clear ();
0 commit comments