@@ -2403,37 +2403,30 @@ HighsStatus Highs::setSolution(const HighsSolution& solution) {
24032403 return returnFromHighs (return_status);
24042404}
24052405
2406- HighsStatus Highs::getColOrRowName (const HighsLp& lp,
2407- const bool is_col,
2408- const HighsInt index,
2409- std::string& name) const {
2406+ HighsStatus Highs::getColOrRowName (const HighsLp& lp, const bool is_col,
2407+ const HighsInt index,
2408+ std::string& name) const {
24102409 HighsInt num_index = is_col ? lp.num_col_ : lp.num_row_ ;
24112410 if (index < 0 || index >= num_index) {
24122411 highsLogUser (this ->options_ .log_options , HighsLogType::kError ,
2413- " Index %d for %s name is outside the range [0, "
2414- " num_%s = %d)\n " ,
2415- int (index),
2416- is_col ? " column" : " row" ,
2417- is_col ? " col" : " row" ,
2418- int (num_index));
2412+ " Index %d for %s name is outside the range [0, "
2413+ " num_%s = %d)\n " ,
2414+ int (index), is_col ? " column" : " row" , is_col ? " col" : " row" ,
2415+ int (num_index));
24192416 return HighsStatus::kError ;
24202417 }
2421- const HighsInt num_index_name = is_col ?
2422- this ->model_ .lp_ .col_names_ .size () :
2423- this ->model_ .lp_ .row_names_ .size ();
2418+ const HighsInt num_index_name = is_col ? this ->model_ .lp_ .col_names_ .size ()
2419+ : this ->model_ .lp_ .row_names_ .size ();
24242420 if (index >= num_index_name) {
24252421 highsLogUser (options_.log_options , HighsLogType::kError ,
24262422 " Index %d for %s name is outside the range [0, "
24272423 " num_%s_name = %d)\n " ,
2428- int (index),
2429- is_col ? " column" : " row" ,
2430- is_col ? " col" : " row" ,
2431- int (num_index_name));
2424+ int (index), is_col ? " column" : " row" , is_col ? " col" : " row" ,
2425+ int (num_index_name));
24322426 return HighsStatus::kError ;
24332427 }
2434- name = is_col ?
2435- this ->model_ .lp_ .col_names_ [index] :
2436- this ->model_ .lp_ .row_names_ [index];
2428+ name = is_col ? this ->model_ .lp_ .col_names_ [index]
2429+ : this ->model_ .lp_ .row_names_ [index];
24372430 return HighsStatus::kOk ;
24382431}
24392432
@@ -3220,24 +3213,7 @@ HighsStatus Highs::getCols(const HighsInt* mask, HighsInt& num_col,
32203213}
32213214
32223215HighsStatus Highs::getColName (const HighsInt col, std::string& name) const {
3223- const HighsInt num_col = this ->model_ .lp_ .num_col_ ;
3224- if (col < 0 || col >= num_col) {
3225- highsLogUser (
3226- options_.log_options , HighsLogType::kError ,
3227- " Index %d for column name is outside the range [0, num_col = %d)\n " ,
3228- int (col), int (num_col));
3229- return HighsStatus::kError ;
3230- }
3231- const HighsInt num_col_name = this ->model_ .lp_ .col_names_ .size ();
3232- if (col >= num_col_name) {
3233- highsLogUser (options_.log_options , HighsLogType::kError ,
3234- " Index %d for column name is outside the range [0, "
3235- " num_col_name = %d)\n " ,
3236- int (col), int (num_col_name));
3237- return HighsStatus::kError ;
3238- }
3239- name = this ->model_ .lp_ .col_names_ [col];
3240- return HighsStatus::kOk ;
3216+ return getColOrRowName (this ->model_ .lp_ , true , col, name);
32413217}
32423218
32433219HighsStatus Highs::getColByName (const std::string& name, HighsInt& col) {
@@ -3325,24 +3301,7 @@ HighsStatus Highs::getRows(const HighsInt* mask, HighsInt& num_row,
33253301}
33263302
33273303HighsStatus Highs::getRowName (const HighsInt row, std::string& name) const {
3328- const HighsInt num_row = this ->model_ .lp_ .num_row_ ;
3329- if (row < 0 || row >= num_row) {
3330- highsLogUser (
3331- options_.log_options , HighsLogType::kError ,
3332- " Index %d for row name is outside the range [0, num_row = %d)\n " ,
3333- int (row), int (num_row));
3334- return HighsStatus::kError ;
3335- }
3336- const HighsInt num_row_name = this ->model_ .lp_ .row_names_ .size ();
3337- if (row >= num_row_name) {
3338- highsLogUser (
3339- options_.log_options , HighsLogType::kError ,
3340- " Index %d for row name is outside the range [0, num_row_name = %d)\n " ,
3341- int (row), int (num_row_name));
3342- return HighsStatus::kError ;
3343- }
3344- name = this ->model_ .lp_ .row_names_ [row];
3345- return HighsStatus::kOk ;
3304+ return getColOrRowName (this ->model_ .lp_ , false , row, name);
33463305}
33473306
33483307HighsStatus Highs::getRowByName (const std::string& name, HighsInt& row) {
0 commit comments