| 2858 | } |
| 2859 | |
| 2860 | HighsStatus readBasisStream(const HighsLogOptions& log_options, HighsLp& lp, |
| 2861 | HighsBasis& basis, std::ifstream& in_file) { |
| 2862 | // Reads a basis as an ifstream, returning an error if what's read is |
| 2863 | // inconsistent with the sizes of the HighsBasis passed in |
| 2864 | HighsStatus return_status = HighsStatus::kOk; |
| 2865 | HighsStatus call_status = HighsStatus::kOk; |
| 2866 | std::string from_method = "readBasisStream"; |
| 2867 | std::string string_highs, string_version; |
| 2868 | in_file >> string_highs >> string_version; |
| 2869 | const bool v1 = string_version == kHighsBasisFileV1; |
| 2870 | const bool v2 = string_version == kHighsBasisFileV2; |
| 2871 | const bool have_col_names = |
| 2872 | lp.col_names_.size() == static_cast<size_t>(lp.num_col_); |
| 2873 | const bool have_row_names = |
| 2874 | lp.row_names_.size() == static_cast<size_t>(lp.num_row_); |
| 2875 | if (have_col_names) { |
| 2876 | // Ensure that the col name hash table has been formed |
| 2877 | if (!lp.col_hash_.name2index.size()) lp.col_hash_.form(lp.col_names_); |
| 2878 | } |
| 2879 | if (have_row_names) { |
| 2880 | // Ensure that the row name hash table has been formed |
| 2881 | if (!lp.row_hash_.name2index.size()) lp.row_hash_.form(lp.row_names_); |
| 2882 | } |
| 2883 | if (v1 || v2) { |
| 2884 | if (v1) { |
| 2885 | // Ability to read v1 basis files is deprecated |
| 2886 | highsLogUser(log_options, HighsLogType::kWarning, |
| 2887 | "readBasisFile: Basis file format %s is deprecated\n", |
| 2888 | kHighsBasisFileV1.c_str()); |
| 2889 | return_status = HighsStatus::kWarning; |
| 2890 | } |
| 2891 | std::string keyword; |
| 2892 | in_file >> keyword; |
| 2893 | if (keyword == "None") { |
| 2894 | basis.valid = false; |
| 2895 | return return_status; |
| 2896 | } |
| 2897 | const HighsInt basis_num_col = (HighsInt)basis.col_status.size(); |
| 2898 | const HighsInt basis_num_row = (HighsInt)basis.row_status.size(); |
| 2899 | HighsInt int_status; |
| 2900 | std::string name; |
| 2901 | assert(keyword == "Valid"); |
| 2902 | HighsInt num_col, num_row; |
| 2903 | // Read in the columns section |
| 2904 | in_file >> keyword >> keyword; |
| 2905 | assert(keyword == "Columns"); |
| 2906 | in_file >> num_col; |
| 2907 | if (num_col != basis_num_col) { |
| 2908 | highsLogUser(log_options, HighsLogType::kError, |
| 2909 | "readBasisFile: Basis file is for %" HIGHSINT_FORMAT |
| 2910 | " columns, not %" HIGHSINT_FORMAT "\n", |
| 2911 | num_col, basis_num_col); |
| 2912 | return HighsStatus::kError; |
| 2913 | } |
| 2914 | bool is_column = true; |
| 2915 | if (v1) { |
| 2916 | for (HighsInt iCol = 0; iCol < num_col; iCol++) { |
| 2917 | in_file >> int_status; |
no test coverage detected