Skip to content

Commit 8cb8ea8

Browse files
committed
Now testing that the solution with rgn from an MPS file is feasible with rgn from its .lp file; formatted
1 parent 2aa8cf5 commit 8cb8ea8

File tree

2 files changed

+64
-13
lines changed

2 files changed

+64
-13
lines changed

check/TestCheckSolution.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ TEST_CASE("read-lp-file-solution", "[highs_check_solution]") {
480480
lp.integrality_ = {HighsVarType::kContinuous, HighsVarType::kContinuous,
481481
HighsVarType::kInteger};
482482
Highs h;
483-
// h.setOptionValue("output_flag", dev_run);
483+
h.setOptionValue("output_flag", dev_run);
484484
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
485485
h.run();
486486
h.writeModel(model_file_name);
@@ -529,9 +529,9 @@ TEST_CASE("read-lp-file-basis", "[highs_check_solution]") {
529529
// Variables now ordered y; z; x
530530
h.writeModel("");
531531
h.readBasis(basis_file_name);
532-
// Initial basis: y - basic; z - lower; x - lower, using basis for
533-
// original ordering with new ordering. Not optimal - in fact basis
534-
// matrix B = [0] is singular!
532+
// Old read basis yields initial basis: y - basic; z - lower; x -
533+
// lower, using basis for original ordering with new ordering. Not
534+
// optimal - in fact basis matrix B = [0] is singular!
535535
h.run();
536536
REQUIRE(h.getInfo().simplex_iteration_count == 0);
537537

@@ -541,6 +541,36 @@ TEST_CASE("read-lp-file-basis", "[highs_check_solution]") {
541541
h.resetGlobalScheduler(true);
542542
}
543543

544+
TEST_CASE("read-lp-file-rgn", "[highs_check_solution]") {
545+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
546+
const std::string filename =
547+
std::string(HIGHS_DIR) + "/check/instances/rgn.mps";
548+
const std::string model_file_name = test_name + ".lp";
549+
const std::string solution_file_name = test_name + ".sol";
550+
Highs h;
551+
h.setOptionValue("output_flag", dev_run);
552+
REQUIRE(h.readModel(filename) == HighsStatus::kOk);
553+
REQUIRE(h.run() == HighsStatus::kOk);
554+
REQUIRE(h.writeSolution(solution_file_name) == HighsStatus::kOk);
555+
REQUIRE(h.writeModel(model_file_name) == HighsStatus::kOk);
556+
557+
REQUIRE(h.readModel(model_file_name) == HighsStatus::kOk);
558+
REQUIRE(h.readSolution(solution_file_name) == HighsStatus::kOk);
559+
bool valid;
560+
bool integral;
561+
bool feasible;
562+
REQUIRE(h.assessPrimalSolution(valid, integral, feasible) ==
563+
HighsStatus::kOk);
564+
REQUIRE(valid);
565+
REQUIRE(integral);
566+
REQUIRE(feasible);
567+
568+
std::remove(model_file_name.c_str());
569+
std::remove(solution_file_name.c_str());
570+
571+
h.resetGlobalScheduler(true);
572+
}
573+
544574
void runWriteReadCheckSolution(Highs& highs, const std::string& test_name,
545575
const std::string& model,
546576
const HighsModelStatus require_model_status,

check/TestFilereader.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,12 @@ TEST_CASE("handle-blank-space-names", "[highs_filereader]") {
525525
h.resetGlobalScheduler(true);
526526
}
527527

528-
TEST_CASE("read-highs-lp-file", "[highs_filereader]") {
528+
TEST_CASE("read-highs-lp-file0", "[highs_filereader]") {
529+
// Identified when fixing #2463 that LP file reader cannot handle
530+
// case where row names are numeric constants
529531
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
530-
const std::string model_name0 = test_name + "-0.lp";
531-
const std::string model_name1 = test_name + "-1.lp";
532+
const std::string model_file_name0 = test_name + "-0.lp";
533+
const std::string model_file_name1 = test_name + "-1.lp";
532534
HighsLp lp;
533535
lp.num_col_ = 1;
534536
lp.num_row_ = 3;
@@ -543,14 +545,33 @@ TEST_CASE("read-highs-lp-file", "[highs_filereader]") {
543545
lp.col_names_ = {"col"};
544546
lp.row_names_ = {"row", "55", "9.9"};
545547
Highs h;
546-
// h.setOptionValue("output_flag", dev_run);
548+
h.setOptionValue("output_flag", dev_run);
547549
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
548-
REQUIRE(h.writeModel(model_name0) == HighsStatus::kOk);
549-
REQUIRE(h.readModel(model_name0) == HighsStatus::kOk);
550-
REQUIRE(h.writeModel(model_name1) == HighsStatus::kOk);
550+
// Create a .lp file for this model - that has numeric constants as
551+
// row names
552+
REQUIRE(h.writeModel(model_file_name0) == HighsStatus::kOk);
553+
// Make sure that the .lp file for this model can be read OK
554+
REQUIRE(h.readModel(model_file_name0) == HighsStatus::kOk);
555+
REQUIRE(h.writeModel(model_file_name1) == HighsStatus::kOk);
556+
557+
std::remove(model_file_name0.c_str());
558+
std::remove(model_file_name1.c_str());
559+
560+
h.resetGlobalScheduler(true);
561+
}
562+
563+
TEST_CASE("read-highs-lp-file1", "[highs_filereader]") {
564+
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
565+
std::string filename;
566+
filename = std::string(HIGHS_DIR) + "/check/instances/rgn.mps";
567+
std::string model_file_name = test_name + ".lp";
568+
Highs h;
569+
h.setOptionValue("output_flag", dev_run);
570+
REQUIRE(h.readModel(filename) == HighsStatus::kOk);
571+
REQUIRE(h.writeModel(model_file_name) == HighsStatus::kOk);
572+
REQUIRE(h.readModel(model_file_name) == HighsStatus::kOk);
551573

552-
// std::remove(model_name0.c_str());
553-
// std::remove(model_name1.c_str());
574+
std::remove(model_file_name.c_str());
554575

555576
h.resetGlobalScheduler(true);
556577
}

0 commit comments

Comments
 (0)