Skip to content

Commit e1027f7

Browse files
committed
Now getting coll/row names of presolved LP, but row names are wrong...
1 parent b22e523 commit e1027f7

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

check/TestCAPI.c

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

241-
void createTestLp(void* highs) {
241+
void createBlendingLp(void* highs) {
242+
// Special variant of the blending LP, with redundant constraint so
243+
// that LP is reduced by presolve - but not to empty!
244+
const double inf = Highs_getInfinity(highs);
245+
242246
HighsInt num_col = 2;
243-
HighsInt num_row = 2;
244-
HighsInt num_nz = 4;
245-
HighsInt a_format = kHighsMatrixFormatRowwise;
246-
HighsInt sense = kHighsObjSenseMinimize;
247-
double offset = 0;
248-
double cc[2] = {1.0, -2.0};
249-
double cl[2] = {0.0, 0.0};
250-
double cu[2] = {10.0, 10.0};
251-
double rl[2] = {0.0, 0.0};
252-
double ru[2] = {2.0, 1.0};
247+
HighsInt num_row = 3;
248+
HighsInt num_nz = 6;
249+
HighsInt sense = -1;
250+
double col_cost[2] = {8, 10};
251+
double col_lower[2] = {0, 0};
252+
double col_upper[2] = {inf, inf};
253+
double row_lower[3] = {-inf, -inf, -inf};
254+
double row_upper[3] = {500, 120, 210};
255+
HighsInt a_index[6] = {0, 1, 0, 1, 0, 1};
256+
double a_value[6] = {0.5, 0.5, 0.3, 0.5, 0.7, 0.5};
253257
HighsInt a_start[3] = {0, 2, 4};
254-
HighsInt a_index[4] = {0, 1, 0, 1};
255-
double a_value[4] = {1.0, 2.0, 1.0, 3.0};
256-
257-
assert(Highs_addCols(highs, 2, cc, cl, cu, 0, NULL, NULL, NULL) == 0);
258-
assert(Highs_addRows(highs, 2, rl, ru, 4, a_start, a_index, a_value) == 0);
258+
Highs_addVars(highs, num_col, col_lower, col_upper);
259+
Highs_changeColsCostByRange(highs, 0, num_col - 1, col_cost);
260+
Highs_addRows(highs, num_row, row_lower, row_upper, num_nz, a_start, a_index,
261+
a_value);
262+
Highs_changeObjectiveSense(highs, sense);
259263
}
260264

261265
// Test methods
@@ -556,7 +560,7 @@ void testNames() {
556560

557561
if (!dev_run) Highs_setBoolOptionValue(highs, "output_flag", 0);
558562

559-
createTestLp(highs);
563+
createBlendingLp(highs);
560564

561565
HighsInt return_status;
562566

@@ -658,6 +662,34 @@ void testNames() {
658662
printf("Row %" HIGHSINT_FORMAT " has name %s\n", iRow, name_p);
659663
}
660664

665+
// Check extraction of names for the presolved LP
666+
Highs_presolve(highs);
667+
if (dev_run) Highs_writePresolvedModel(highs, "");
668+
669+
HighsInt presolved_num_col = Highs_getPresolvedNumCol(highs);
670+
HighsInt presolved_num_row = Highs_getPresolvedNumRow(highs);
671+
assert(presolved_num_col == num_col);
672+
assert(presolved_num_row == num_row-1);
673+
for (HighsInt iCol = 0; iCol < presolved_num_col; iCol++) {
674+
char name[5];
675+
char* name_p = name;
676+
return_status = Highs_getPresolvedColName(highs, iCol, name_p);
677+
assert(return_status == kHighsStatusOk);
678+
if (dev_run)
679+
printf("Presolved column %" HIGHSINT_FORMAT " has name %s\n", iCol, name_p);
680+
}
681+
682+
for (HighsInt iRow = 0; iRow < presolved_num_row; iRow++) {
683+
char name[5];
684+
char* name_p = name;
685+
return_status = Highs_getPresolvedRowName(highs, iRow, name_p);
686+
assert(return_status == kHighsStatusOk);
687+
if (dev_run)
688+
printf("Presolved row %" HIGHSINT_FORMAT " has name %s\n", iRow, name_p);
689+
}
690+
691+
692+
661693
Highs_destroy(highs);
662694
}
663695

0 commit comments

Comments
 (0)