undo presolve steps for primal dual solution and basis
| 609 | |
| 610 | /// undo presolve steps for primal dual solution and basis |
| 611 | void undo(const HighsOptions& options, HighsSolution& solution, |
| 612 | HighsBasis& basis, const HighsInt report_col = -1, |
| 613 | const bool thread_safe = false) { |
| 614 | HighsDataStack reductionValuesCopy; |
| 615 | std::vector<Nonzero> colValuesCopy; |
| 616 | std::vector<Nonzero> rowValuesCopy; |
| 617 | if (!thread_safe) { |
| 618 | reductionValues.resetPosition(); |
| 619 | } else { |
| 620 | reductionValuesCopy = reductionValues; |
| 621 | reductionValuesCopy.resetPosition(); |
| 622 | colValuesCopy = colValues; |
| 623 | rowValuesCopy = rowValues; |
| 624 | } |
| 625 | HighsDataStack& reductionValues_ = |
| 626 | thread_safe ? reductionValuesCopy : reductionValues; |
| 627 | std::vector<Nonzero>& colValues_ = thread_safe ? colValuesCopy : colValues; |
| 628 | std::vector<Nonzero>& rowValues_ = thread_safe ? rowValuesCopy : rowValues; |
| 629 | |
| 630 | // Verify that undo can be performed |
| 631 | assert(solution.value_valid); |
| 632 | bool perform_dual_postsolve = solution.dual_valid; |
| 633 | bool perform_basis_postsolve = basis.valid; |
| 634 | |
| 635 | // expand solution to original index space |
| 636 | assert(origNumCol > 0); |
| 637 | undoIterateBackwards(solution.col_value, origColIndex, origNumCol); |
| 638 | |
| 639 | assert(origNumRow >= 0); |
| 640 | undoIterateBackwards(solution.row_value, origRowIndex, origNumRow); |
| 641 | |
| 642 | if (perform_dual_postsolve) { |
| 643 | // if dual solution is given, expand dual solution and basis to original |
| 644 | // index space |
| 645 | undoIterateBackwards(solution.col_dual, origColIndex, origNumCol); |
| 646 | |
| 647 | undoIterateBackwards(solution.row_dual, origRowIndex, origNumRow); |
| 648 | } |
| 649 | |
| 650 | if (perform_basis_postsolve) { |
| 651 | // if basis is given, expand basis status values to original index space |
| 652 | undoIterateBackwards(basis.col_status, origColIndex, origNumCol); |
| 653 | |
| 654 | undoIterateBackwards(basis.row_status, origRowIndex, origNumRow); |
| 655 | } |
| 656 | |
| 657 | // now undo the changes |
| 658 | for (size_t i = reductions.size(); i > 0; --i) { |
| 659 | if (report_col >= 0) |
| 660 | printf("Before reduction %2d (type %2d): col_value[%2d] = %g\n", |
| 661 | int(i - 1), int(reductions[i - 1].first), int(report_col), |
| 662 | solution.col_value[report_col]); |
| 663 | switch (reductions[i - 1].first) { |
| 664 | case ReductionType::kLinearTransform: { |
| 665 | LinearTransform reduction; |
| 666 | reductionValues_.pop(reduction); |
| 667 | reduction.undo(options, solution); |
| 668 | break; |
no test coverage detected