Skip to content

Commit 7ced541

Browse files
committed
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into liftingForProbingNew
2 parents 2ef25d0 + acf5151 commit 7ced541

21 files changed

+528
-201
lines changed

check/TestCAPI.c

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void assertLogical(const char* name, const HighsInt is) {
238238
}
239239
}
240240

241-
void version_api() {
241+
void versionApi() {
242242
if (dev_run) {
243243
printf("HiGHS version %s\n", Highs_version());
244244
printf("HiGHS version major %" HIGHSINT_FORMAT "\n", Highs_versionMajor());
@@ -250,7 +250,7 @@ void version_api() {
250250
}
251251
}
252252

253-
void minimal_api_lp() {
253+
void minimalApiLp() {
254254
// This illustrates the use of Highs_call, the simple C interface to
255255
// HiGHS. It's designed to solve the general LP problem
256256
//
@@ -375,7 +375,7 @@ void minimal_api_lp() {
375375
free(row_basis_status);
376376
}
377377

378-
void minimal_api_mip() {
378+
void minimalApiMip() {
379379
// The use of Highs_mipCall is illustrated for the MIP
380380
//
381381
// Min f = -3x_0 - 2x_1 - x_2
@@ -455,7 +455,7 @@ void minimal_api_mip() {
455455
free(row_value);
456456
}
457457

458-
void minimal_api_qp() {
458+
void minimalApiQp() {
459459
// Test solving the problem qjh
460460
//
461461
// minimize -x_2 - 3x_3 + (1/2)(2x_1^2 - 2x_1x_3 + 0.2x_2^2 + 2x_3^2)
@@ -503,7 +503,7 @@ void minimal_api_qp() {
503503
free(col_value);
504504
}
505505

506-
void minimal_api_illegal_lp() {
506+
void minimalApiIllegalLp() {
507507
const double inf = 1e30;
508508
HighsInt num_col = 2;
509509
HighsInt num_row = 1;
@@ -530,7 +530,7 @@ void minimal_api_illegal_lp() {
530530
assert(model_status == kHighsModelStatusNotset);
531531
}
532532

533-
void full_api() {
533+
void fullApi() {
534534
void* highs = Highs_create();
535535

536536
if (!dev_run) Highs_setBoolOptionValue(highs, "output_flag", 0);
@@ -698,7 +698,7 @@ void full_api() {
698698
Highs_destroy(highs);
699699
}
700700

701-
void full_api_options() {
701+
void fullApiOptions() {
702702
void* highs;
703703

704704
highs = Highs_create();
@@ -841,7 +841,7 @@ void full_api_options() {
841841
Highs_destroy(highs);
842842
}
843843

844-
void full_api_lp() {
844+
void fullApiLp() {
845845
// Form and solve the LP
846846
// Min f = 2x_0 + 3x_1
847847
// s.t. x_1 <= 6
@@ -1059,7 +1059,7 @@ void full_api_lp() {
10591059
Highs_destroy(highs);
10601060
}
10611061

1062-
void full_api_mip() {
1062+
void fullApiMip() {
10631063
// The use of the full HiGHS API is illustrated for the MIP
10641064
//
10651065
// Min f = -3x_0 - 2x_1 - x_2
@@ -1138,7 +1138,7 @@ void full_api_mip() {
11381138
free(row_value);
11391139
}
11401140

1141-
void full_api_qp() {
1141+
void fullApiQp() {
11421142
double required_objective_function_value;
11431143
double required_x0;
11441144
double required_x1;
@@ -1324,7 +1324,7 @@ void full_api_qp() {
13241324
free(col_solution);
13251325
}
13261326

1327-
void pass_presolve_get_lp() {
1327+
void passPresolveGetLp() {
13281328
// Form and solve the LP
13291329
// Min f = 2x_0 + 3x_1
13301330
// s.t. x_1 <= 6
@@ -1474,7 +1474,7 @@ void options() {
14741474
Highs_destroy(highs);
14751475
}
14761476

1477-
void test_getColsByRange() {
1477+
void testGetColsByRange() {
14781478
void* highs = Highs_create();
14791479
if (!dev_run) Highs_setBoolOptionValue(highs, "output_flag", 0);
14801480
HighsInt return_status;
@@ -1510,7 +1510,7 @@ void test_getColsByRange() {
15101510
Highs_destroy(highs);
15111511
}
15121512

1513-
void test_passHessian() {
1513+
void testPassHessian() {
15141514
void* highs = Highs_create();
15151515
if (!dev_run) Highs_setBoolOptionValue(highs, "output_flag", 0);
15161516
Highs_addCol(highs, 2.0, 0.0, 2.0, 0, NULL, NULL);
@@ -1540,7 +1540,7 @@ void test_passHessian() {
15401540
Highs_destroy(highs);
15411541
}
15421542

1543-
void test_ranging() {
1543+
void testRanging() {
15441544
void* highs = Highs_create();
15451545
if (!dev_run) Highs_setBoolOptionValue(highs, "output_flag", 0);
15461546
//
@@ -1678,7 +1678,7 @@ void test_ranging() {
16781678
Highs_destroy(highs);
16791679
}
16801680

1681-
void test_feasibilityRelaxation() {
1681+
void testFeasibilityRelaxation() {
16821682
void* highs;
16831683
highs = Highs_create();
16841684
const double kHighsInf = Highs_getInfinity(highs);
@@ -1728,7 +1728,7 @@ void test_feasibilityRelaxation() {
17281728
Highs_destroy(highs);
17291729
}
17301730

1731-
void test_callback() {
1731+
void testCallback() {
17321732
HighsInt num_col = 7;
17331733
HighsInt num_row = 1;
17341734
HighsInt num_nz = num_col;
@@ -1783,7 +1783,7 @@ void test_callback() {
17831783
Highs_destroy(highs);
17841784
}
17851785

1786-
void test_getModel() {
1786+
void testGetModel() {
17871787
void* highs;
17881788
highs = Highs_create();
17891789
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
@@ -1855,7 +1855,7 @@ void test_getModel() {
18551855
Highs_destroy(highs);
18561856
}
18571857

1858-
void test_multiObjective() {
1858+
void testMultiObjective() {
18591859
void* highs;
18601860
highs = Highs_create();
18611861
const double inf = Highs_getInfinity(highs);
@@ -1967,11 +1967,31 @@ void test_multiObjective() {
19671967
free(col_value);
19681968
}
19691969

1970+
void testQpIndefiniteFailure() {
1971+
void* highs = Highs_create();
1972+
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
1973+
HighsInt ret;
1974+
const double inf = Highs_getInfinity(highs);
1975+
ret = Highs_addCol(highs, 0.0, 1.0, inf, 0, NULL, NULL);
1976+
assert(ret == 0);
1977+
ret = Highs_addCol(highs, 0.0, 1.0, 1.0, 0, NULL, NULL);
1978+
HighsInt start[2] = {0, 1};
1979+
HighsInt index[1] = {1};
1980+
double value[1] = {1.0};
1981+
ret = Highs_passHessian(highs, 2, 1, kHighsHessianFormatTriangular, start, index, value);
1982+
assert(ret == 0);
1983+
HighsInt run_status = Highs_run(highs);
1984+
HighsInt model_status = Highs_getModelStatus(highs);
1985+
assert(run_status == kHighsStatusError);
1986+
assert(model_status == kHighsModelStatusSolveError);
1987+
Highs_destroy(highs);
1988+
}
1989+
19701990
/*
19711991
The horrible C in this causes problems in some of the CI tests,
19721992
so suppress thius test until the C has been improved
19731993
1974-
void test_setSolution() {
1994+
void testSetSolution() {
19751995
void* highs = Highs_create();
19761996
// Perform in C the equivalent of std::string model_file =
19771997
// std::string(HIGHS_DIR) + "/check/instances/shell.mps";
@@ -2013,25 +2033,26 @@ iteration_count1); assertLogical("Dual", logic);
20132033
}
20142034
*/
20152035
int main() {
2016-
minimal_api_illegal_lp();
2017-
test_callback();
2018-
version_api();
2019-
full_api();
2020-
minimal_api_lp();
2021-
minimal_api_mip();
2022-
minimal_api_qp();
2023-
full_api_options();
2024-
full_api_lp();
2025-
full_api_mip();
2026-
full_api_qp();
2027-
pass_presolve_get_lp();
2036+
minimalApiIllegalLp();
2037+
testCallback();
2038+
versionApi();
2039+
fullApi();
2040+
minimalApiLp();
2041+
minimalApiMip();
2042+
minimalApiQp();
2043+
fullApiOptions();
2044+
fullApiLp();
2045+
fullApiMip();
2046+
fullApiQp();
2047+
passPresolveGetLp();
20282048
options();
2029-
test_getColsByRange();
2030-
test_passHessian();
2031-
test_ranging();
2032-
test_feasibilityRelaxation();
2033-
test_getModel();
2034-
test_multiObjective();
2049+
testGetColsByRange();
2050+
testPassHessian();
2051+
testRanging();
2052+
testFeasibilityRelaxation();
2053+
testGetModel();
2054+
testMultiObjective();
2055+
testQpIndefiniteFailure();
20352056
return 0;
20362057
}
2037-
// test_setSolution();
2058+
// testSetSolution();

check/TestFilereader.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,17 @@ TEST_CASE("filereader-edge-cases", "[highs_filereader]") {
146146
void freeFixedModelTest(const std::string model_name) {
147147
std::string filename;
148148
filename = std::string(HIGHS_DIR) + "/check/instances/" + model_name + ".mps";
149-
HighsStatus status;
150149

151150
Highs highs;
152151
highs.setOptionValue("output_flag", dev_run);
153-
status = highs.readModel(filename);
154-
REQUIRE(status == HighsStatus::kOk);
152+
REQUIRE(highs.readModel(filename) == HighsStatus::kOk);
155153

156154
HighsModel model_free = highs.getModel();
157155

158-
status = highs.setOptionValue("mps_parser_type_free", false);
159-
REQUIRE(status == HighsStatus::kOk);
156+
REQUIRE(highs.setOptionValue("mps_parser_type_free", false) ==
157+
HighsStatus::kOk);
160158

161-
status = highs.readModel(filename);
162-
REQUIRE(status == HighsStatus::kOk);
159+
REQUIRE(highs.readModel(filename) == HighsStatus::kWarning);
163160

164161
HighsModel model_fixed = highs.getModel();
165162

@@ -439,3 +436,21 @@ TEST_CASE("write-MI-bound-model", "[highs_filereader]") {
439436
REQUIRE(required_objective_value == h.getInfo().objective_function_value);
440437
std::remove(write_model_file.c_str());
441438
}
439+
440+
TEST_CASE("mps-warnings", "[highs_filereader]") {
441+
std::string model_file =
442+
std::string(HIGHS_DIR) + "/check/instances/warnings.mps";
443+
Highs h;
444+
h.setOptionValue("output_flag", dev_run);
445+
HighsStatus return_status = h.readModel(model_file);
446+
REQUIRE(return_status == HighsStatus::kWarning);
447+
}
448+
449+
TEST_CASE("mps-silly-names", "[highs_filereader]") {
450+
std::string model_file =
451+
std::string(HIGHS_DIR) + "/check/instances/silly-names.mps";
452+
Highs h;
453+
h.setOptionValue("output_flag", dev_run);
454+
HighsStatus return_status = h.readModel(model_file);
455+
REQUIRE(return_status == HighsStatus::kOk);
456+
}

check/TestMipSolver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ TEST_CASE("issue-2122", "[highs_test_mip_solver]") {
812812
TEST_CASE("issue-2171", "[highs_test_mip_solver]") {
813813
std::string filename = std::string(HIGHS_DIR) + "/check/instances/2171.mps";
814814
Highs highs;
815+
highs.setOptionValue("output_flag", dev_run);
815816
highs.setOptionValue("mip_rel_gap", 0);
816817
highs.setOptionValue("mip_abs_gap", 0);
817818
highs.readModel(filename);

check/instances/silly-names.mps

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
NAME SILLY-NAMES
2+
OBJSENSE MIN
3+
ROWS
4+
G R0
5+
N COST
6+
COLUMNS
7+
C0 R0 -1.0 COST -1.0
8+
OBJSENSE R0 -1.0 COST -1.0
9+
RANGES R0 -1.0 COST -1.0
10+
RHS R0 -1.0 COST -1.0
11+
C1 R0 -1.0 COST -1.0
12+
RHS
13+
DEMANDS R0 -1.0
14+
ENDATA

check/instances/warnings.mps

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
NAME WARNINGS
2+
ROWS
3+
G R0
4+
G R1
5+
G R2
6+
G R3
7+
G R4
8+
G R5
9+
N COST
10+
COLUMNS
11+
C0 R0 -1.0 COST -1.0
12+
C0 R11 1.0 R12 1.0
13+
C0 R13 1.0 R14 1.0
14+
C0 R15 1.0 COST 1.0
15+
C0 COST 2.0 COST 3.0
16+
C0 COST 4.0 COST 5.0
17+
C0 R0 1.0 R0 2.0
18+
C0 R0 3.0 R0 4.0
19+
C0 R0 5.0 R0 6.0
20+
MARK0000 'MARKER' 'INTORG'
21+
C1 R0 -1.0 COST -1.0
22+
C2 R0 -1.0 COST -1.0
23+
C3 R0 -1.0 COST -1.0
24+
C4 R0 -1.0 COST -1.0
25+
C5 R0 -1.0 COST -1.0
26+
MARK0001 'MARKER' 'INTEND'
27+
C6 R0 -1.0 COST -1.0
28+
C7 R0 -1.0 COST -1.0
29+
C8 R0 -1.0 COST -1.0
30+
RHS
31+
DEMANDS R0 -1.0 R11 -1.0
32+
DEMANDS R12 -1.0 R13 -1.0
33+
DEMANDS R14 -1.0 R15 -1.0
34+
DEMANDS R0 1.0 R0 2.0
35+
DEMANDS R0 3.0 R0 4.0
36+
DEMANDS R0 5.0
37+
BOUNDS
38+
UP SERVINGS C0 -1.0
39+
UP SERVINGS C0 1.0
40+
UP SERVINGS C0 2.0
41+
UP SERVINGS C0 3.0
42+
UP SERVINGS C0 4.0
43+
UP SERVINGS C0 5.0
44+
UP SERVINGS C10 1.0
45+
LI SERVINGS C1 1.1
46+
UI SERVINGS C2 2.1
47+
SI SERVINGS C3 3.1
48+
LI SERVINGS C4 4.1
49+
UI SERVINGS C5 5.1
50+
LO SERVINGS C4 1.0
51+
LO SERVINGS C6 1.0
52+
LO SERVINGS C7 1.0
53+
LO SERVINGS C8 1.0
54+
UP SERVINGS C4 -1.0
55+
UP SERVINGS C6 -1.0
56+
UP SERVINGS C7 -1.0
57+
UP SERVINGS C8 -1.0
58+
RANGES
59+
RNG R0 0.1 R0 1.0
60+
RNG R0 2.0 R0 3.0
61+
RNG R0 4.0 R0 5.0
62+
RNG R11 0.1 R12 1.0
63+
RNG R13 2.0 R14 3.0
64+
RNG R15 4.0 COST 5.0
65+
RNG COST 6.0 COST 7.0
66+
RNG COST 8.0 COST 9.0
67+
68+
ENDATA

src/Highs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,7 @@ class Highs {
16611661
bool aFormatOk(const HighsInt num_nz, const HighsInt format);
16621662
bool qFormatOk(const HighsInt num_nz, const HighsInt format);
16631663
void clearZeroHessian();
1664-
HighsStatus checkOptimality(const std::string& solver_type,
1665-
HighsStatus return_status);
1664+
HighsStatus checkOptimality(const std::string& solver_type);
16661665
HighsStatus invertRequirementError(std::string method_name) const;
16671666

16681667
HighsStatus handleInfCost();

src/io/Filereader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void interpretFilereaderRetcode(const HighsLogOptions& log_options,
7575
const FilereaderRetcode code) {
7676
switch (code) {
7777
case FilereaderRetcode::kOk:
78+
case FilereaderRetcode::kWarning:
7879
break;
7980
case FilereaderRetcode::kFileNotFound:
8081
highsLogUser(log_options, HighsLogType::kError, "File %s not found\n",

0 commit comments

Comments
 (0)