| 126 | } |
| 127 | |
| 128 | HighsStatus Highs::formStandardFormLp() { |
| 129 | this->clearStandardFormLp(); |
| 130 | HighsLp& lp = this->model_.lp_; |
| 131 | HighsSparseMatrix& matrix = lp.a_matrix_; |
| 132 | // Ensure that the incumbent LP and standard form LP matrices are rowwise |
| 133 | matrix.ensureRowwise(); |
| 134 | // Original rows are processed before columns, so that any original |
| 135 | // boxed rows can be transformed to pairs of one-sided rows, |
| 136 | // requiring the standard form matrix to be row-wise. The original |
| 137 | // columns are assumed to come before any new columns, so their |
| 138 | // costs (as a minimization) must be defined befor costs of new |
| 139 | // columns. |
| 140 | // Determine the objective scaling, and apply it to any offset |
| 141 | HighsInt sense = HighsInt(lp.sense_); |
| 142 | this->standard_form_offset_ = sense * lp.offset_; |
| 143 | for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++) |
| 144 | this->standard_form_cost_.push_back(sense * lp.col_cost_[iCol]); |
| 145 | this->standard_form_matrix_.format_ = MatrixFormat::kRowwise; |
| 146 | this->standard_form_matrix_.num_col_ = lp.num_col_; |
| 147 | // Create a HighsSparseMatrix instance to store rows extracted from |
| 148 | // the original constraint matrix |
| 149 | HighsInt local_row_min_nnz = std::max(lp.num_col_, HighsInt(2)); |
| 150 | HighsSparseMatrix local_row; |
| 151 | local_row.ensureRowwise(); |
| 152 | local_row.num_row_ = 1; |
| 153 | local_row.num_col_ = lp.num_col_; |
| 154 | local_row.index_.resize(local_row_min_nnz); |
| 155 | local_row.value_.resize(local_row_min_nnz); |
| 156 | local_row.start_.resize(2); |
| 157 | HighsInt& num_nz = local_row.start_[1]; |
| 158 | local_row.start_[0] = 0; |
| 159 | HighsInt num_fixed_row = 0; |
| 160 | HighsInt num_boxed_row = 0; |
| 161 | HighsInt num_lower_row = 0; |
| 162 | HighsInt num_upper_row = 0; |
| 163 | HighsInt num_free_row = 0; |
| 164 | HighsInt num_fixed_col = 0; |
| 165 | HighsInt num_boxed_col = 0; |
| 166 | HighsInt num_lower_col = 0; |
| 167 | HighsInt num_upper_col = 0; |
| 168 | HighsInt num_free_col = 0; |
| 169 | std::vector<HighsInt> slack_ix; |
| 170 | for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++) { |
| 171 | double lower = lp.row_lower_[iRow]; |
| 172 | double upper = lp.row_upper_[iRow]; |
| 173 | if (lower <= -kHighsInf && upper >= kHighsInf) { |
| 174 | assert(0 == 1); |
| 175 | // Free row |
| 176 | num_free_row++; |
| 177 | continue; |
| 178 | } |
| 179 | if (lower == upper) { |
| 180 | // Equality row |
| 181 | num_fixed_row++; |
| 182 | matrix.getRow(iRow, num_nz, local_row.index_.data(), |
| 183 | local_row.value_.data()); |
| 184 | this->standard_form_matrix_.addRows(local_row); |
| 185 | this->standard_form_rhs_.push_back(upper); |
nothing calls this directly
no test coverage detected