Skip to content

Commit 61778d1

Browse files
committed
Applied fix of 2316, but exposed isssue 2318
1 parent 0876f9b commit 61778d1

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

FEATURES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ Added `Highs_changeRowsBoundsByRange` to C API, fixing [#2296](https://github.co
2020

2121
Corrected docstrings for `Highs_getReducedRow`, motivated by [#2312](https://github.com/ERGO-Code/HiGHS/issues/2312))
2222

23+
LP file reader no longer fails when there is no objective section. Fix is [#2316](https://github.com/ERGO-Code/HiGHS/pull/2316)), but this exposes code quality issue [#2318](https://github.com/ERGO-Code/HiGHS/issues/2318))
24+
25+
26+

check/TestFilereader.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,18 @@ TEST_CASE("filereader-edge-cases", "[highs_filereader]") {
9898
}
9999

100100
if (test_garbage_lp) {
101+
// Since #2316, reading an LP file of garbage yields an empty
102+
// model, since the absence of an objecive is (rightly) no
103+
// longer an error. However the LP file reader should fail due
104+
// to the requirement that a LP format file must begin with a
105+
// keyword.
101106
if (dev_run) printf("\ngarbage.lp\n");
102107
model_file = std::string(HIGHS_DIR) + "/check/instances/" + model + ".lp";
103108
read_status = highs.readModel(model_file);
104-
REQUIRE(read_status == HighsStatus::kError);
109+
REQUIRE(read_status == HighsStatus::kOk);
110+
REQUIRE(highs.getLp().num_col_ == 0);
111+
REQUIRE(highs.getLp().num_row_ == 0);
112+
REQUIRE(highs.getLp().a_matrix_.numNz() == 0);
105113
}
106114
}
107115

check/instances/garbage.lp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Maximize
12
\^%(^%(T&*)(lkszdvhfalkmnthry6v54y76m87yq,x,
23
dvhfalkmnthry6v54y76m87yq,x,^%(^%(T&*)(lksz
34
(T&*)(lkszdvhfalkmnthry6v54y76m87yq,x,^%(^%

extern/filereaderlp/reader.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -308,23 +308,6 @@ Model Reader::read() {
308308
splittokens();
309309

310310
// std::clog << "Setting up model..." << std::endl;
311-
//
312-
// Since
313-
//
314-
// "The problem statement must begin with the word MINIMIZE or
315-
// MAXIMIZE, MINIMUM or MAXIMUM, or the abbreviations MIN or MAX, in
316-
// any combination of upper- and lower-case characters. The word
317-
// introduces the objective function section."
318-
//
319-
// Use positivity of sectiontokens.count(LpSectionKeyword::OBJMIN) +
320-
// sectiontokens.count(LpSectionKeyword::OBJMAX) to identify garbage file
321-
//
322-
323-
const int num_objective_section =
324-
sectiontokens.count(LpSectionKeyword::OBJMIN) +
325-
sectiontokens.count(LpSectionKeyword::OBJMAX);
326-
lpassert(num_objective_section>0);
327-
328311
processsections();
329312
processedtokens.clear();
330313
processedtokens.shrink_to_fit();

0 commit comments

Comments
 (0)