| 2769 | } |
| 2770 | |
| 2771 | void writeBasisFile(FILE*& file, const HighsOptions& options, const HighsLp& lp, |
| 2772 | const HighsBasis& basis) { |
| 2773 | const HighsLogOptions& log_options = options.log_options; |
| 2774 | std::stringstream ss; |
| 2775 | // Basis version line |
| 2776 | ss.str(std::string()); |
| 2777 | ss << highsFormatToString("HiGHS_basis_file %s\n", kHighsBasisFileV2.c_str()); |
| 2778 | highsFprintfString(file, log_options, ss.str()); |
| 2779 | // Basis validity line |
| 2780 | ss.str(std::string()); |
| 2781 | if (basis.valid == false) { |
| 2782 | ss << highsFormatToString("None\n"); |
| 2783 | highsFprintfString(file, log_options, ss.str()); |
| 2784 | return; |
| 2785 | } |
| 2786 | assert(basis.col_status.size() == static_cast<size_t>(lp.num_col_)); |
| 2787 | assert(basis.row_status.size() == static_cast<size_t>(lp.num_row_)); |
| 2788 | assert(lp.col_names_.size() == static_cast<size_t>(lp.num_col_)); |
| 2789 | assert(lp.row_names_.size() == static_cast<size_t>(lp.num_row_)); |
| 2790 | ss << highsFormatToString("Valid\n"); |
| 2791 | highsFprintfString(file, log_options, ss.str()); |
| 2792 | // Column count line |
| 2793 | ss.str(std::string()); |
| 2794 | ss << highsFormatToString("# Columns %d\n", int(lp.num_col_)); |
| 2795 | highsFprintfString(file, log_options, ss.str()); |
| 2796 | for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++) { |
| 2797 | const std::string& name = lp.col_names_[iCol]; |
| 2798 | assert(name.length() != 0); |
| 2799 | ss.str(std::string()); |
| 2800 | ss << highsFormatToString("%s %d\n", name.c_str(), |
| 2801 | int(basis.col_status[iCol])); |
| 2802 | highsFprintfString(file, log_options, ss.str()); |
| 2803 | } |
| 2804 | // Row count line |
| 2805 | ss.str(std::string()); |
| 2806 | ss << highsFormatToString("# Rows %d\n", int(lp.num_row_)); |
| 2807 | highsFprintfString(file, log_options, ss.str()); |
| 2808 | for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++) { |
| 2809 | const std::string& name = lp.row_names_[iRow]; |
| 2810 | assert(name.length() != 0); |
| 2811 | ss.str(std::string()); |
| 2812 | ss << highsFormatToString("%s %d\n", name.c_str(), |
| 2813 | int(basis.row_status[iRow])); |
| 2814 | highsFprintfString(file, log_options, ss.str()); |
| 2815 | } |
| 2816 | } |
| 2817 | |
| 2818 | HighsStatus getIndexFromName( |
| 2819 | const HighsLogOptions& log_options, std::string& from_method, |
no test coverage detected