Skip to content

Commit 0743bca

Browse files
committed
Fixed bug in Highs::getColOrRowName
1 parent e1027f7 commit 0743bca

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

check/TestCAPI.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ void testNames() {
662662
printf("Row %" HIGHSINT_FORMAT " has name %s\n", iRow, name_p);
663663
}
664664

665-
// Check extraction of names for the presolved LP
665+
// Check extraction of names for the presolved LP, in which the
666+
// first row is removed
666667
Highs_presolve(highs);
667668
if (dev_run) Highs_writePresolvedModel(highs, "");
668669

@@ -671,25 +672,23 @@ void testNames() {
671672
assert(presolved_num_col == num_col);
672673
assert(presolved_num_row == num_row-1);
673674
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);
675+
char presolved_name[5];
676+
char* presolved_name_p = presolved_name;
677+
return_status = Highs_getPresolvedColName(highs, iCol, presolved_name_p);
677678
assert(return_status == kHighsStatusOk);
678679
if (dev_run)
679-
printf("Presolved column %" HIGHSINT_FORMAT " has name %s\n", iCol, name_p);
680+
printf("Presolved column %" HIGHSINT_FORMAT " has name %s\n", iCol, presolved_name_p);
680681
}
681682

682683
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);
684+
char presolved_name[5];
685+
char* presolved_name_p = presolved_name;
686+
return_status = Highs_getPresolvedRowName(highs, iRow, presolved_name_p);
686687
assert(return_status == kHighsStatusOk);
687688
if (dev_run)
688-
printf("Presolved row %" HIGHSINT_FORMAT " has name %s\n", iRow, name_p);
689+
printf("Presolved row %" HIGHSINT_FORMAT " has name %s\n", iRow, presolved_name_p);
689690
}
690691

691-
692-
693692
Highs_destroy(highs);
694693
}
695694

highs/lp_data/Highs.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,8 +2415,8 @@ HighsStatus Highs::getColOrRowName(const HighsLp& lp, const bool is_col,
24152415
int(num_index));
24162416
return HighsStatus::kError;
24172417
}
2418-
const HighsInt num_index_name = is_col ? this->model_.lp_.col_names_.size()
2419-
: this->model_.lp_.row_names_.size();
2418+
const HighsInt num_index_name =
2419+
is_col ? lp.col_names_.size() : lp.row_names_.size();
24202420
if (index >= num_index_name) {
24212421
highsLogUser(options_.log_options, HighsLogType::kError,
24222422
"Index %d for %s name is outside the range [0, "
@@ -2425,8 +2425,7 @@ HighsStatus Highs::getColOrRowName(const HighsLp& lp, const bool is_col,
24252425
int(num_index_name));
24262426
return HighsStatus::kError;
24272427
}
2428-
name = is_col ? this->model_.lp_.col_names_[index]
2429-
: this->model_.lp_.row_names_[index];
2428+
name = is_col ? lp.col_names_[index] : lp.row_names_[index];
24302429
return HighsStatus::kOk;
24312430
}
24322431

0 commit comments

Comments
 (0)