Skip to content

Commit 9cf6af2

Browse files
committed
Merge branch 'latest' into metis-workflow
2 parents c4ec892 + 2fb5d47 commit 9cf6af2

26 files changed

+10410
-394
lines changed

FEATURES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Forcing column reduction now checks the bound on the column dual rather than whe
66

77
Now handling correctly the case where an infeasible MIP has a feasible relaxation, so no ray is computed fixing [#2415](https://github.com/ERGO-Code/HiGHS/issues/2415)
88

9-
Fixed minor bug exposed by [#2441](https://github.com/ERGO-Code/HiGHS/issues/2441) in Highs::setSolution() for a sparse user solution when the moidel is empty, and only clearing the dual data before solving with modified objective in Highs::multiobjectiveSolve() so that user-supplied solution is not cleared.
9+
Fixed minor bug exposed by [#2441](https://github.com/ERGO-Code/HiGHS/issues/2441) in `Highs::setSolution()` for a sparse user solution when the moidel is empty, and only clearing the dual data before solving with modified objective in `Highs::multiobjectiveSolve()` so that user-supplied solution is not cleared.
10+
11+
The irreducible infeasibility system (IIS) facility now detects infeasibility due to bounds on constraint activity values (implied by variable bounds) being incompatible with constraint bounds. A `kIisStrategyLight mode` for the `iis_strategy` option has been introduced so that only infeasibility due to incompatible variable/constraint bounds and constraint activity values is checked for. The LP corresponding to any known IIS is now formed and held as a data member of the `HighsIis` class. It can be obtained as a const reference using `Highs::getIisLp()`, and written to a file using `Highs::writeIisModel(const std::string& filename = "")`
1012

1113
Prompted by [#2463](https://github.com/ERGO-Code/HiGHS/issues/2463), the HiGHS solution and basis files now match data to any column and row names in the model, only assuming that the data are aligned with column and row indices if there are no names in the model. This requires a new version (v2) of the HiGHS basis file. Basis files from v1 are still read, but deprecated. Now, when writing out a model, basis or solution, column and row names are added to the model - previously they were created temporarily and inconsistentyly on the fly. If the model has existing names, then distinctive names are created to replace any blank names, but names with spaces or duplicate names yield an error status return.
1214

check/TestCAPI.c

Lines changed: 148 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ void testDualRayTwice() {
19891989
void* highs = Highs_create();
19901990
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
19911991
int ret;
1992-
double INF = Highs_getInfinity(highs);
1992+
double inf = Highs_getInfinity(highs);
19931993
ret = Highs_changeObjectiveOffset(highs, 0.0);
19941994
assert(ret == 0);
19951995
ret = Highs_setStringOptionValue(highs, "presolve", "off");
@@ -1998,9 +1998,9 @@ void testDualRayTwice() {
19981998
assert(ret == 0);
19991999
ret = Highs_addCol(highs, 0.0, 0.0, 0.0, 0, NULL, NULL);
20002000
assert(ret == 0);
2001-
ret = Highs_addCol(highs, -1.0, 0.0, INF, 0, NULL, NULL);
2001+
ret = Highs_addCol(highs, -1.0, 0.0, inf, 0, NULL, NULL);
20022002
assert(ret == 0);
2003-
ret = Highs_addCol(highs, -1.0, 0.0, INF, 0, NULL, NULL);
2003+
ret = Highs_addCol(highs, -1.0, 0.0, inf, 0, NULL, NULL);
20042004
assert(ret == 0);
20052005
HighsInt index[2] = {2, 3};
20062006
double value[2] = {1.0, -1.0};
@@ -2010,19 +2010,19 @@ void testDualRayTwice() {
20102010
index[1] = 3;
20112011
value[0] = 1.0;
20122012
value[1] = 1.0;
2013-
ret = Highs_addRow(highs, 1.0, INF, 2, index, value);
2013+
ret = Highs_addRow(highs, 1.0, inf, 2, index, value);
20142014
assert(ret == 0);
20152015
index[0] = 0;
20162016
index[1] = 2;
20172017
value[0] = -2.0;
20182018
value[1] = 1.0;
2019-
ret = Highs_addRow(highs, -INF, 0.0, 2, index, value);
2019+
ret = Highs_addRow(highs, -inf, 0.0, 2, index, value);
20202020
assert(ret == 0);
20212021
index[0] = 1;
20222022
index[1] = 3;
20232023
value[0] = -3.0;
20242024
value[1] = 1.0;
2025-
ret = Highs_addRow(highs, -INF, 0.0, 2, index, value);
2025+
ret = Highs_addRow(highs, -inf, 0.0, 2, index, value);
20262026
assert(ret == 0);
20272027
ret = Highs_run(highs);
20282028
assert(ret == 0);
@@ -2103,16 +2103,16 @@ void testDeleteRowResolveWithBasis() {
21032103
void* highs = Highs_create();
21042104
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
21052105
HighsInt ret;
2106-
double INF = Highs_getInfinity(highs);
2106+
double inf = Highs_getInfinity(highs);
21072107
ret = Highs_addCol(highs, 0.0, 2.0, 2.0, 0, NULL, NULL);
2108-
ret = Highs_addCol(highs, 0.0, -INF, INF, 0, NULL, NULL);
2109-
ret = Highs_addCol(highs, 0.0, -INF, INF, 0, NULL, NULL);
2108+
ret = Highs_addCol(highs, 0.0, -inf, inf, 0, NULL, NULL);
2109+
ret = Highs_addCol(highs, 0.0, -inf, inf, 0, NULL, NULL);
21102110
HighsInt index_1[2] = {0, 2};
21112111
double value_1[2] = {2.0, -1.0};
21122112
ret = Highs_addRow(highs, 0.0, 0.0, 2, index_1, value_1);
21132113
HighsInt index_2[1] = {1};
21142114
double value_2[1] = {6.0};
2115-
ret = Highs_addRow(highs, 10.0, INF, 1, index_2, value_2);
2115+
ret = Highs_addRow(highs, 10.0, inf, 1, index_2, value_2);
21162116
Highs_run(highs);
21172117
double col_value[3] = {0.0, 0.0, 0.0};
21182118
Highs_getSolution(highs, col_value, NULL, NULL, NULL);
@@ -2127,30 +2127,145 @@ void testDeleteRowResolveWithBasis() {
21272127
Highs_destroy(highs);
21282128
}
21292129

2130+
void testIis() {
2131+
void* highs = Highs_create();
2132+
Highs_setBoolOptionValue(highs, "output_flag", dev_run);
2133+
HighsInt ret;
2134+
double inf = Highs_getInfinity(highs);
2135+
// For the constraints
2136+
//
2137+
// x + y - z = 2
2138+
//
2139+
// x + y + z <= 5
2140+
//
2141+
// x + 2y + z <= 1
2142+
//
2143+
// with variables in [0, 1], constraints 0 and 2 form an IIS with
2144+
//
2145+
// x free (so should be removed?); 0 <= y; 0 <= z
2146+
//
2147+
// x + y - z >= 2; x + 2y + z <= 1
2148+
//
2149+
ret = Highs_addCol(highs, 0.0, 0.0, 1.0, 0, NULL, NULL);
2150+
assert(ret == 0);
2151+
ret = Highs_addCol(highs, 0.0, 0.0, 1.0, 0, NULL, NULL);
2152+
assert(ret == 0);
2153+
ret = Highs_addCol(highs, 0.0, 0.0, 1.0, 0, NULL, NULL);
2154+
assert(ret == 0);
2155+
HighsInt index[3] = {0, 1, 2};
2156+
double value_1[3] = {1, 1, -1};
2157+
double value_2[3] = {1, 1, 1};
2158+
double value_3[3] = {1, 2, 1};
2159+
ret = Highs_addRow(highs, 2.0, 2.0, 3, index, value_1);
2160+
assert(ret == 0);
2161+
ret = Highs_addRow(highs, -inf, 5.0, 3, index, value_2);
2162+
assert(ret == 0);
2163+
ret = Highs_addRow(highs, -inf, 1.0, 3, index, value_3);
2164+
assert(ret == 0);
2165+
2166+
HighsInt num_col;
2167+
HighsInt num_row;
2168+
HighsInt num_nz;
2169+
HighsInt sense;
2170+
double offset;
2171+
ret = Highs_getLp(highs, kHighsMatrixFormatRowwise,
2172+
&num_col, &num_row, &num_nz,
2173+
&sense, &offset,
2174+
NULL, NULL, NULL,
2175+
NULL, NULL,
2176+
NULL, NULL, NULL,
2177+
NULL);
2178+
2179+
for (int k = 0 ; k < 2; k++) {
2180+
HighsInt iis_num_col;
2181+
HighsInt iis_num_row;
2182+
ret = Highs_getIis(highs,
2183+
&iis_num_col, &iis_num_row,
2184+
NULL, NULL,
2185+
NULL, NULL,
2186+
NULL, NULL);
2187+
assert(ret == 0);
2188+
2189+
if (k == 0) {
2190+
// No IIS from kHighsIisStrategyLight
2191+
assert(iis_num_col == 0);
2192+
assert(iis_num_row == 0);
2193+
Highs_setIntOptionValue(highs, "iis_strategy",
2194+
kHighsIisStrategyFromLpRowPriority);
2195+
} else {
2196+
assert(iis_num_col == 3);
2197+
assert(iis_num_row == 2);
2198+
HighsInt* col_index = (HighsInt*)malloc(sizeof(HighsInt) * iis_num_col);
2199+
HighsInt* row_index = (HighsInt*)malloc(sizeof(HighsInt) * iis_num_row);
2200+
HighsInt* col_bound = (HighsInt*)malloc(sizeof(HighsInt) * iis_num_col);
2201+
HighsInt* row_bound = (HighsInt*)malloc(sizeof(HighsInt) * iis_num_row);
2202+
HighsInt* col_status = (HighsInt*)malloc(sizeof(HighsInt) * num_col);
2203+
HighsInt* row_status = (HighsInt*)malloc(sizeof(HighsInt) * num_row);
2204+
ret = Highs_getIis(highs,
2205+
&iis_num_col, &iis_num_row,
2206+
col_index, row_index,
2207+
col_bound, row_bound,
2208+
col_status, row_status);
2209+
assert(ret == 0);
2210+
2211+
assert(col_index[0] == 0);
2212+
assert(col_index[1] == 1);
2213+
assert(col_index[2] == 2);
2214+
2215+
assert(row_index[0] == 0);
2216+
assert(row_index[1] == 2);
2217+
2218+
assert(col_bound[0] == kHighsIisBoundFree);
2219+
assert(col_bound[1] == kHighsIisBoundLower);
2220+
assert(col_bound[2] == kHighsIisBoundLower);
2221+
2222+
assert(row_bound[0] == kHighsIisBoundLower);
2223+
assert(row_bound[1] == kHighsIisBoundUpper);
2224+
2225+
assert(col_status[0] == kHighsIisStatusInConflict);
2226+
assert(col_status[1] == kHighsIisStatusInConflict);
2227+
assert(col_status[2] == kHighsIisStatusInConflict);
2228+
2229+
assert(row_status[0] == kHighsIisStatusInConflict);
2230+
assert(row_status[1] == kHighsIisStatusNotInConflict);
2231+
assert(row_status[2] == kHighsIisStatusInConflict);
2232+
2233+
free(col_index);
2234+
free(row_index);
2235+
free(col_bound);
2236+
free(row_bound);
2237+
free(col_status);
2238+
free(row_status);
2239+
}
2240+
}
2241+
2242+
Highs_destroy(highs);
2243+
}
2244+
21302245
int main() {
2131-
minimalApiIllegalLp();
2132-
testCallback();
2133-
versionApi();
2134-
fullApi();
2135-
minimalApiLp();
2136-
minimalApiMip();
2137-
minimalApiQp();
2138-
fullApiOptions();
2139-
fullApiLp();
2140-
fullApiMip();
2141-
fullApiQp();
2142-
passPresolveGetLp();
2143-
options();
2144-
testGetColsByRange();
2145-
testPassHessian();
2146-
testRanging();
2147-
testFeasibilityRelaxation();
2148-
testGetModel();
2149-
testMultiObjective();
2150-
testQpIndefiniteFailure();
2151-
testDualRayTwice();
2152-
2153-
testDeleteRowResolveWithBasis();
2246+
minimalApiIllegalLp();
2247+
testCallback();
2248+
versionApi();
2249+
fullApi();
2250+
minimalApiLp();
2251+
minimalApiMip();
2252+
minimalApiQp();
2253+
fullApiOptions();
2254+
fullApiLp();
2255+
fullApiMip();
2256+
fullApiQp();
2257+
passPresolveGetLp();
2258+
options();
2259+
testGetColsByRange();
2260+
testPassHessian();
2261+
testRanging();
2262+
testFeasibilityRelaxation();
2263+
testGetModel();
2264+
testMultiObjective();
2265+
testQpIndefiniteFailure();
2266+
testDualRayTwice();
2267+
testDeleteRowResolveWithBasis();
2268+
testIis();
21542269
return 0;
21552270
}
21562271
// testSetSolution();

0 commit comments

Comments
 (0)