MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / basisSolveInterface

Method basisSolveInterface

highs/lp_data/HighsInterface.cpp:1480–1561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1478// Solve (transposed) system involving the basis matrix
1479
1480HighsStatus Highs::basisSolveInterface(const vector<double>& rhs,
1481 double* solution_vector,
1482 HighsInt* solution_num_nz,
1483 HighsInt* solution_indices,
1484 bool transpose) {
1485 HighsStatus return_status = HighsStatus::kOk;
1486 HighsLp& lp = model_.lp_;
1487 HighsInt num_row = lp.num_row_;
1488 // For an LP with no rows the solution is vacuous
1489 if (num_row == 0) return return_status;
1490 // EKK must have an INVERT, but simplex NLA may need the pointer to
1491 // its LP to be refreshed so that it can use its scale factors
1492 assert(ekk_instance_.status_.has_invert);
1493 // Reset the simplex NLA LP and scale pointers for the unscaled LP
1494 ekk_instance_.setNlaPointersForLpAndScale(lp);
1495 assert(!lp.is_moved_);
1496 // Set up solve vector with suitably scaled RHS
1497 HVector solve_vector;
1498 solve_vector.setup(num_row);
1499 solve_vector.clear();
1500 HighsInt rhs_num_nz = 0;
1501 for (HighsInt iRow = 0; iRow < num_row; iRow++) {
1502 if (rhs[iRow]) {
1503 solve_vector.index[rhs_num_nz++] = iRow;
1504 solve_vector.array[iRow] = rhs[iRow];
1505 }
1506 }
1507 solve_vector.count = rhs_num_nz;
1508 //
1509 // Note that solve_vector.count is just used to determine whether
1510 // hyper-sparse solves should be used. The indices of the nonzeros
1511 // in the solution are always accumulated. There's no switch (such
1512 // as setting solve_vector.count = num_row+1) to not do this.
1513 //
1514 // Get expected_density from analysis during simplex solve.
1515 const double expected_density = 1;
1516 if (transpose) {
1517 ekk_instance_.btran(solve_vector, expected_density);
1518 } else {
1519 ekk_instance_.ftran(solve_vector, expected_density);
1520 }
1521 // Extract the solution
1522 if (solution_indices == NULL) {
1523 // Nonzeros in the solution not required
1524 if (solve_vector.count > num_row) {
1525 // Solution nonzeros not known
1526 for (HighsInt iRow = 0; iRow < num_row; iRow++) {
1527 solution_vector[iRow] = solve_vector.array[iRow];
1528 }
1529 } else {
1530 // Solution nonzeros are known
1531 for (HighsInt iRow = 0; iRow < num_row; iRow++) solution_vector[iRow] = 0;
1532 for (HighsInt iX = 0; iX < solve_vector.count; iX++) {
1533 HighsInt iRow = solve_vector.index[iX];
1534 solution_vector[iRow] = solve_vector.array[iRow];
1535 }
1536 }
1537 } else {

Callers

nothing calls this directly

Calls 5

setupMethod · 0.45
clearMethod · 0.45
btranMethod · 0.45
ftranMethod · 0.45

Tested by

no test coverage detected