| 150 | } |
| 151 | |
| 152 | void testBasisSolve(Highs& highs) { |
| 153 | HighsStatus highs_status; |
| 154 | |
| 155 | vector<HighsInt> basic_variables, solution_row_indices, solution_col_indices; |
| 156 | vector<double> rhs, known_solution, solution_row, solution_col; |
| 157 | |
| 158 | HighsLp lp = highs.getLp(); |
| 159 | HighsInt numRow = lp.num_row_; |
| 160 | HighsInt numCol = lp.num_col_; |
| 161 | basic_variables.resize(numRow); |
| 162 | known_solution.resize(numRow); |
| 163 | rhs.resize(numRow); |
| 164 | solution_row.resize(numCol); |
| 165 | solution_col.resize(numRow); |
| 166 | solution_row_indices.resize(numCol); |
| 167 | solution_col_indices.resize(numRow); |
| 168 | |
| 169 | HighsInt solution_num_nz; |
| 170 | |
| 171 | HighsInt check_row = 0; |
| 172 | HighsInt check_col = 0; |
| 173 | |
| 174 | double residual_norm; |
| 175 | const double residual_norm_tolerance = 1e-8; |
| 176 | const double solution_error_tolerance = 1e-8; |
| 177 | HighsRandom random; |
| 178 | |
| 179 | HighsInt basic_col; |
| 180 | |
| 181 | highs_status = highs.getBasicVariables(basic_variables.data()); |
| 182 | REQUIRE(highs_status == HighsStatus::kOk); |
| 183 | |
| 184 | for (HighsInt ix = 0; ix < numRow; ix++) known_solution[ix] = 0; |
| 185 | bool transpose = true; |
| 186 | HighsInt num_ix = 3; |
| 187 | HighsInt col; |
| 188 | col = 6; |
| 189 | basic_col = basic_variables[col]; |
| 190 | known_solution[col] = random.fraction(); |
| 191 | |
| 192 | if (num_ix > 1) { |
| 193 | col = 15; |
| 194 | basic_col = basic_variables[col]; |
| 195 | known_solution[col] = random.fraction(); |
| 196 | } |
| 197 | |
| 198 | if (num_ix > 2) { |
| 199 | col = 12; |
| 200 | basic_col = basic_variables[col]; |
| 201 | known_solution[col] = random.fraction(); |
| 202 | } |
| 203 | |
| 204 | GetBasisSolvesFormRHS(lp, basic_variables, known_solution, rhs, transpose); |
| 205 | if (transpose) { |
| 206 | highs_status = |
| 207 | highs.getBasisTransposeSolve(rhs.data(), solution_col.data()); |
| 208 | } else { |
| 209 | highs_status = highs.getBasisSolve(rhs.data(), solution_col.data()); |
no test coverage detected