| 19 | using free_format_parser::HMpsFF; |
| 20 | |
| 21 | FilereaderRetcode FilereaderMps::readModelFromFile(const HighsOptions& options, |
| 22 | const std::string filename, |
| 23 | HighsModel& model) { |
| 24 | HighsLp& lp = model.lp_; |
| 25 | HighsHessian& hessian = model.hessian_; |
| 26 | // if free format parser |
| 27 | // Parse file and return status. |
| 28 | if (options.mps_parser_type_free) { |
| 29 | HMpsFF parser{}; |
| 30 | if (options.time_limit < kHighsInf && options.time_limit > 0) |
| 31 | parser.time_limit_ = options.time_limit; |
| 32 | |
| 33 | FreeFormatParserReturnCode result = |
| 34 | parser.loadProblem(options.log_options, filename, model); |
| 35 | switch (result) { |
| 36 | case FreeFormatParserReturnCode::kSuccess: |
| 37 | lp.ensureColwise(); |
| 38 | assert(model.lp_.objective_name_ != ""); |
| 39 | return parser.warning_issued_ ? FilereaderRetcode::kWarning |
| 40 | : FilereaderRetcode::kOk; |
| 41 | case FreeFormatParserReturnCode::kParserError: |
| 42 | return FilereaderRetcode::kParserError; |
| 43 | case FreeFormatParserReturnCode::kFileNotFound: |
| 44 | return FilereaderRetcode::kFileNotFound; |
| 45 | case FreeFormatParserReturnCode::kFixedFormat: |
| 46 | highsLogUser(options.log_options, HighsLogType::kWarning, |
| 47 | "Free format reader has detected row/col names with " |
| 48 | "spaces: switching to fixed format parser\n"); |
| 49 | break; |
| 50 | case FreeFormatParserReturnCode::kTimeout: |
| 51 | highsLogUser(options.log_options, HighsLogType::kWarning, |
| 52 | "Free format reader reached time_limit while parsing " |
| 53 | "the input file\n"); |
| 54 | return FilereaderRetcode::kTimeout; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // else use fixed format parser |
| 59 | // |
| 60 | // If the fixed format parser has had to be used, then a warning was |
| 61 | // issued, otherwise no warning has yet been issued |
| 62 | bool warning_issued = options.mps_parser_type_free; |
| 63 | FilereaderRetcode return_code = |
| 64 | readMps(options.log_options, filename, -1, -1, lp.num_row_, lp.num_col_, |
| 65 | lp.sense_, lp.offset_, lp.a_matrix_.start_, lp.a_matrix_.index_, |
| 66 | lp.a_matrix_.value_, lp.col_cost_, lp.col_lower_, lp.col_upper_, |
| 67 | lp.row_lower_, lp.row_upper_, lp.integrality_, lp.objective_name_, |
| 68 | lp.col_names_, lp.row_names_, hessian.dim_, hessian.start_, |
| 69 | hessian.index_, hessian.value_, lp.cost_row_location_, |
| 70 | warning_issued, options.keep_n_rows); |
| 71 | if (return_code == FilereaderRetcode::kOk) lp.ensureColwise(); |
| 72 | // Comment on existence of names with spaces |
| 73 | hasNamesWithSpaces(options.log_options, lp); |
| 74 | assert(model.lp_.objective_name_ != ""); |
| 75 | if (return_code == FilereaderRetcode::kOk && warning_issued) |
| 76 | return_code = FilereaderRetcode::kWarning; |
| 77 | return return_code; |
| 78 | } |
nothing calls this directly
no test coverage detected