| 1614 | } |
| 1615 | |
| 1616 | HighsDebugStatus HEkk::debugComputeDual(const bool initialise) const { |
| 1617 | static vector<double> previous_dual; |
| 1618 | const HighsSimplexInfo& info = this->info_; |
| 1619 | if (initialise) { |
| 1620 | previous_dual = info.workDual_; |
| 1621 | return HighsDebugStatus::kOk; |
| 1622 | } |
| 1623 | const HighsOptions& options = *(this->options_); |
| 1624 | // if (options.highs_debug_level < kHighsDebugLevelCheap) return |
| 1625 | // HighsDebugStatus::kNotChecked; |
| 1626 | const HighsLp& lp = this->lp_; |
| 1627 | const SimplexBasis& basis = this->basis_; |
| 1628 | |
| 1629 | double norm_basic_costs = 0; |
| 1630 | for (HighsInt iRow = 0; iRow < lp_.num_row_; iRow++) { |
| 1631 | const double value = info.workCost_[basis.basicIndex_[iRow]] + |
| 1632 | info.workShift_[basis.basicIndex_[iRow]]; |
| 1633 | norm_basic_costs = max(fabs(value), norm_basic_costs); |
| 1634 | } |
| 1635 | |
| 1636 | vector<double> new_dual = info.workDual_; |
| 1637 | vector<double> delta_dual; |
| 1638 | HighsInt num_tot = lp.num_col_ + lp.num_row_; |
| 1639 | delta_dual.assign(num_tot, 0); |
| 1640 | HighsInt num_dual_sign_change = 0; |
| 1641 | HighsInt num_delta_dual_values = 0; |
| 1642 | double norm_nonbasic_costs = 0; |
| 1643 | for (HighsInt iVar = 0; iVar < num_tot; iVar++) { |
| 1644 | if (!basis.nonbasicFlag_[iVar]) continue; |
| 1645 | double value = info.workCost_[iVar] + info.workShift_[iVar]; |
| 1646 | norm_nonbasic_costs = max(fabs(value), norm_nonbasic_costs); |
| 1647 | } |
| 1648 | |
| 1649 | const double zero_delta_dual = |
| 1650 | max(0.5 * (norm_basic_costs + norm_nonbasic_costs) * 1e-16, 1e-16); |
| 1651 | for (HighsInt iVar = 0; iVar < num_tot; iVar++) { |
| 1652 | if (!basis.nonbasicFlag_[iVar]) { |
| 1653 | previous_dual[iVar] = 0; |
| 1654 | new_dual[iVar] = 0; |
| 1655 | continue; |
| 1656 | } |
| 1657 | double delta = new_dual[iVar] - previous_dual[iVar]; |
| 1658 | if (fabs(delta) < zero_delta_dual) continue; |
| 1659 | delta_dual[iVar] = delta; |
| 1660 | const bool sign_change = |
| 1661 | fabs(previous_dual[iVar]) > options.dual_feasibility_tolerance && |
| 1662 | fabs(new_dual[iVar]) > options.dual_feasibility_tolerance && |
| 1663 | previous_dual[iVar] * new_dual[iVar] < 0; |
| 1664 | if (sign_change) num_dual_sign_change++; |
| 1665 | num_delta_dual_values++; |
| 1666 | } |
| 1667 | if (num_delta_dual_values) { |
| 1668 | printf( |
| 1669 | "\nHEkk::debugComputeDual Iteration %d: Number of dual sign changes = " |
| 1670 | "%d\n", |
| 1671 | (int)iteration_count_, (int)num_dual_sign_change); |
| 1672 | printf(" |cB| = %g; |cN| = %g; zero delta dual = %g\n", norm_basic_costs, |
| 1673 | norm_nonbasic_costs, zero_delta_dual); |
nothing calls this directly
no test coverage detected