Skip to content

Commit ee4dfdb

Browse files
committed
Now to fix 2463!
1 parent d03fa6a commit ee4dfdb

File tree

14 files changed

+271
-210
lines changed

14 files changed

+271
-210
lines changed

check/TestCheckSolution.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,17 @@ TEST_CASE("read-lp-file-solution", "[highs_check_solution]") {
463463
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
464464
const std::string model_file_name = test_name + ".lp";
465465
const std::string solution_file_name = test_name + ".sol";
466+
const bool with_names = false;
466467
HighsLp lp;
467468
lp.num_col_ = 3;
468469
lp.num_row_ = 1;
469470
lp.col_cost_ = {0, 1, 1};
470471
lp.col_lower_ = {0, 10, 0};
471472
lp.col_upper_ = {kHighsInf, kHighsInf, kHighsInf};
472-
lp.col_names_ = {"x", "y", "z"};
473+
if (with_names) lp.col_names_ = {"x", "y", "z"};
473474
lp.row_lower_ = {1};
474475
lp.row_upper_ = {2};
475-
lp.row_names_ = {"r"};
476+
if (with_names) lp.row_names_ = {"r"};
476477
lp.a_matrix_.start_ = {0, 1, 1, 2};
477478
lp.a_matrix_.index_ = {0, 0};
478479
lp.a_matrix_.value_ = {1, 1};
@@ -485,11 +486,13 @@ TEST_CASE("read-lp-file-solution", "[highs_check_solution]") {
485486
h.writeSolution(solution_file_name);
486487

487488
h.readModel(model_file_name);
489+
h.writeModel("");
488490
h.readSolution(solution_file_name);
489491
h.run();
490492

491-
// std::remove(model_file_name.c_str());
492-
// std::remove(solution_file_name.c_str());
493+
std::remove(model_file_name.c_str());
494+
std::remove(solution_file_name.c_str());
495+
493496
h.resetGlobalScheduler(true);
494497
}
495498

check/TestFilereader.cpp

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ TEST_CASE("writeLocalModel", "[highs_filereader]") {
382382
h.setOptionValue("output_flag", dev_run);
383383
HighsModel model;
384384
HighsLp& lp = model.lp_;
385-
;
385+
386386
lp.num_col_ = 2;
387387
lp.num_row_ = 3;
388388
lp.col_cost_ = {8, 10};
@@ -403,7 +403,7 @@ TEST_CASE("writeLocalModel", "[highs_filereader]") {
403403
// Model has no dimensions for a_matrix_, but these are set in
404404
// writeLocalModel.
405405
if (dev_run) printf("\nModel with no column or row names\n");
406-
REQUIRE(h.writeLocalModel(model, write_model_file) == HighsStatus::kWarning);
406+
REQUIRE(h.writeLocalModel(model, write_model_file) == HighsStatus::kOk);
407407
lp.col_names_ = {"C0", "C1"};
408408
lp.row_names_ = {"R0", "R1", "R2"};
409409

@@ -477,3 +477,44 @@ TEST_CASE("mps-silly-names", "[highs_filereader]") {
477477
HighsStatus return_status = h.readModel(model_file);
478478
REQUIRE(return_status == HighsStatus::kOk);
479479
}
480+
481+
TEST_CASE("handle-blank-space-names", "[highs_filereader]") {
482+
HighsLp lp;
483+
lp.num_col_ = 2;
484+
lp.num_row_ = 2;
485+
lp.col_cost_ = {8, 10};
486+
lp.col_lower_ = {0, 0};
487+
lp.col_upper_ = {inf, inf};
488+
lp.row_lower_ = {7, 12};
489+
lp.row_upper_ = {inf, inf};
490+
lp.a_matrix_.start_ = {0, 2, 4};
491+
lp.a_matrix_.index_ = {0, 1, 0, 1};
492+
lp.a_matrix_.value_ = {1, 2, 2, 4};
493+
Highs h;
494+
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
495+
h.run();
496+
REQUIRE(h.writeSolution("", 1) == HighsStatus::kOk);
497+
REQUIRE(h.writeModel("") == HighsStatus::kOk);
498+
499+
lp.col_names_ = {"Column0", ""};
500+
lp.row_names_ = {"Row0", "Row1"};
501+
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
502+
h.run();
503+
REQUIRE(h.writeSolution("") == HighsStatus::kOk);
504+
REQUIRE(h.writeModel("") == HighsStatus::kOk);
505+
506+
std::vector<HighsInt> index = {0, 1};
507+
std::vector<double> value = {2, 3};
508+
REQUIRE(h.addRow(5, inf, 2, index.data(), value.data()) == HighsStatus::kOk);
509+
h.run();
510+
REQUIRE(h.writeSolution("", 1) == HighsStatus::kOk);
511+
REQUIRE(h.writeModel("") == HighsStatus::kOk);
512+
513+
lp.row_names_[1] = "Row 1";
514+
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
515+
h.run();
516+
REQUIRE(h.writeSolution("", 1) == HighsStatus::kError);
517+
REQUIRE(h.writeModel("") == HighsStatus::kError);
518+
519+
h.resetGlobalScheduler(true);
520+
}

check/TestRays.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "catch.hpp"
55
#include "lp_data/HConst.h"
66

7-
const bool dev_run = true; // false;
7+
const bool dev_run = false;//true; //
88
const double zero_ray_value_tolerance = 1e-14;
99

1010
void reportRay(std::string message, HighsInt dim, double* computed,

0 commit comments

Comments
 (0)