| 1588 | } |
| 1589 | |
| 1590 | HighsStatus ipxBasicSolutionToHighsBasicSolution( |
| 1591 | const HighsLogOptions& log_options, const HighsLp& lp, |
| 1592 | const std::vector<double>& rhs, const std::vector<char>& constraint_type, |
| 1593 | const IpxSolution& ipx_solution, HighsBasis& highs_basis, |
| 1594 | HighsSolution& highs_solution) { |
| 1595 | // Resize the HighsSolution and HighsBasis |
| 1596 | highs_solution.col_value.resize(lp.num_col_); |
| 1597 | highs_solution.row_value.resize(lp.num_row_); |
| 1598 | highs_solution.col_dual.resize(lp.num_col_); |
| 1599 | highs_solution.row_dual.resize(lp.num_row_); |
| 1600 | highs_basis.col_status.resize(lp.num_col_); |
| 1601 | highs_basis.row_status.resize(lp.num_row_); |
| 1602 | |
| 1603 | const std::vector<double>& ipx_col_value = ipx_solution.ipx_col_value; |
| 1604 | const std::vector<double>& ipx_row_value = ipx_solution.ipx_row_value; |
| 1605 | const std::vector<double>& ipx_col_dual = ipx_solution.ipx_col_dual; |
| 1606 | const std::vector<double>& ipx_row_dual = ipx_solution.ipx_row_dual; |
| 1607 | const std::vector<ipx::Int>& ipx_col_status = ipx_solution.ipx_col_status; |
| 1608 | const std::vector<ipx::Int>& ipx_row_status = ipx_solution.ipx_row_status; |
| 1609 | |
| 1610 | // Set up meaningful names for values of ipx_col_status and ipx_row_status to |
| 1611 | // be used later in comparisons |
| 1612 | const ipx::Int ipx_basic = 0; |
| 1613 | const ipx::Int ipx_nonbasic_at_lb = -1; |
| 1614 | const ipx::Int ipx_nonbasic_at_ub = -2; |
| 1615 | const ipx::Int ipx_superbasic = -3; |
| 1616 | // Row activities are needed to set activity values of free rows - |
| 1617 | // which are ignored by IPX |
| 1618 | vector<double> row_activity; |
| 1619 | bool get_row_activities = ipx_solution.num_row < lp.num_row_; |
| 1620 | if (get_row_activities) row_activity.assign(lp.num_row_, 0); |
| 1621 | HighsInt num_basic_variables = 0; |
| 1622 | for (HighsInt col = 0; col < lp.num_col_; col++) { |
| 1623 | bool unrecognised = false; |
| 1624 | if (ipx_col_status[col] == ipx_basic) { |
| 1625 | // Column is basic |
| 1626 | highs_basis.col_status[col] = HighsBasisStatus::kBasic; |
| 1627 | highs_solution.col_value[col] = ipx_col_value[col]; |
| 1628 | highs_solution.col_dual[col] = 0; |
| 1629 | } else { |
| 1630 | // Column is nonbasic. Setting of ipx_col_status is consistent |
| 1631 | // with dual value for fixed columns |
| 1632 | if (ipx_col_status[col] == ipx_nonbasic_at_lb) { |
| 1633 | // Column is at lower bound |
| 1634 | highs_basis.col_status[col] = HighsBasisStatus::kLower; |
| 1635 | highs_solution.col_value[col] = ipx_col_value[col]; |
| 1636 | highs_solution.col_dual[col] = ipx_col_dual[col]; |
| 1637 | } else if (ipx_col_status[col] == ipx_nonbasic_at_ub) { |
| 1638 | // Column is at upper bound |
| 1639 | highs_basis.col_status[col] = HighsBasisStatus::kUpper; |
| 1640 | highs_solution.col_value[col] = ipx_col_value[col]; |
| 1641 | highs_solution.col_dual[col] = ipx_col_dual[col]; |
| 1642 | } else if (ipx_col_status[col] == ipx_superbasic) { |
| 1643 | // Column is superbasic |
| 1644 | highs_basis.col_status[col] = HighsBasisStatus::kZero; |
| 1645 | highs_solution.col_value[col] = ipx_col_value[col]; |
| 1646 | highs_solution.col_dual[col] = ipx_col_dual[col]; |
| 1647 | } else { |
no test coverage detected