Skip to content

Commit bb09f23

Browse files
authored
Merge pull request #2156 from ERGO-Code/fix-2152
Fix 2152
2 parents 5d41154 + 4a2849a commit bb09f23

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

check/TestFilereader.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,26 @@ TEST_CASE("writeLocalModel", "[highs_filereader]") {
416416

417417
std::remove(write_model_file.c_str());
418418
}
419+
420+
TEST_CASE("write-MI-bound-model", "[highs_filereader]") {
421+
std::string write_model_file = "temp.mps";
422+
Highs h;
423+
h.setOptionValue("output_flag", dev_run);
424+
h.addCol(1, -kHighsInf, 1, 0, nullptr, nullptr);
425+
h.changeColIntegrality(0, HighsVarType::kInteger);
426+
h.passColName(0, "x");
427+
std::vector<HighsInt> index = {0};
428+
std::vector<double> value = {1};
429+
h.addRow(-10, kHighsInf, 1, index.data(), value.data());
430+
h.passRowName(0, "r");
431+
h.run();
432+
double required_objective_value = h.getInfo().objective_function_value;
433+
// writeModel must ensure that there is a line
434+
//
435+
// MI BOUND x
436+
h.writeModel(write_model_file);
437+
h.readModel(write_model_file);
438+
h.run();
439+
REQUIRE(required_objective_value == h.getInfo().objective_function_value);
440+
std::remove(write_model_file.c_str());
441+
}

src/io/HMPSIO.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ HighsStatus writeMps(
913913
if (lb || highs_isInfinity(ub))
914914
fprintf(file, " LI BOUND %-8s %.10g\n",
915915
col_names[c_n].c_str(), lb);
916+
} else {
917+
// Infinite lower bound
918+
fprintf(file, " MI BOUND %-8s\n", col_names[c_n].c_str());
916919
}
917920
if (!highs_isInfinity(ub)) {
918921
// Finite upper bound

0 commit comments

Comments
 (0)