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

Method loadProblem

highs/io/HMpsFF.cpp:21–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19const bool kNoClockCalls = false;
20
21FreeFormatParserReturnCode HMpsFF::loadProblem(
22 const HighsLogOptions& log_options, const std::string filename,
23 HighsModel& model) {
24 // Keep track of any warnings that are issued so that
25 // Highs::readModel can return HighsStatus::kWarning
26 warning_issued_ = false;
27 HighsLp& lp = model.lp_;
28 HighsHessian& hessian = model.hessian_;
29 FreeFormatParserReturnCode result = parse(log_options, filename);
30 if (result != FreeFormatParserReturnCode::kSuccess) return result;
31
32 if (!qrows_entries.empty()) {
33 highsLogUser(log_options, HighsLogType::kError,
34 "Quadratic rows not supported by HiGHS\n");
35 return FreeFormatParserReturnCode::kParserError;
36 }
37 if (!sos_entries.empty()) {
38 highsLogUser(log_options, HighsLogType::kError,
39 "SOS not supported by HiGHS\n");
40 return FreeFormatParserReturnCode::kParserError;
41 }
42 if (!cone_entries.empty()) {
43 highsLogUser(log_options, HighsLogType::kError,
44 "Cones not supported by HiGHS\n");
45 return FreeFormatParserReturnCode::kParserError;
46 }
47 // Duplicate row and column names in MPS files occur if the same row
48 // name appears twice in the ROWS section, or if a column name
49 // reoccurs in the COLUMNS section after another column has been
50 // defined. They are anomalies, but are only handled by a warning in
51 // some solvers. Hence, rather than fail, HiGHS does the same.
52 //
53 // If there are duplicate row (column) names, then they are treated
54 // as distinct rows (columns), so the row (column) names array is
55 // not valid. Report this for the first instance, and clear the row
56 // (column) names array.
57 //
58 // Note that rowname2idx and colname2idx will return the index
59 // corresponding to the first occurrence of the name, so values for
60 // rows in the COLUMNS, RHS and RANGES sections, and columns in the
61 // BOUNDS and other sections can only be defined for the first
62 // occurrence
63 if (has_duplicate_row_name_) {
64 warning_issued_ = true;
65 highsLogUser(log_options, HighsLogType::kWarning,
66 "Linear constraints %d and %d have the same name \"%s\"\n",
67 (int)duplicate_row_name_index0_,
68 (int)duplicate_row_name_index1_, duplicate_row_name_.c_str());
69 row_names.clear();
70 }
71 if (has_duplicate_col_name_) {
72 warning_issued_ = true;
73 highsLogUser(log_options, HighsLogType::kWarning,
74 "Variables %d and %d have the same name \"%s\"\n",
75 (int)duplicate_col_name_index0_,
76 (int)duplicate_col_name_index1_, duplicate_col_name_.c_str());
77 col_names.clear();
78 }

Callers 1

readModelFromFileMethod · 0.80

Calls 6

highsLogUserFunction · 0.85
findModelObjectiveNameFunction · 0.85
c_strMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected