Skip to content

Commit e24ee5f

Browse files
committed
Added highsVarTypeToString methods to HighsLpUtils for HighsVarType and HighsInt
1 parent cd202e8 commit e24ee5f

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

highs/lp_data/Highs.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,16 @@ HighsStatus Highs::passModel(
464464
for (HighsInt iCol = 0; iCol < num_col; iCol++) {
465465
HighsInt integrality_status = integrality[iCol];
466466
const bool legal_integrality_status =
467-
integrality_status == (HighsInt)HighsVarType::kContinuous ||
468-
integrality_status == (HighsInt)HighsVarType::kInteger ||
469-
integrality_status == (HighsInt)HighsVarType::kSemiContinuous ||
470-
integrality_status == (HighsInt)HighsVarType::kSemiInteger;
467+
integrality_status == HighsInt(HighsVarType::kContinuous) ||
468+
integrality_status == HighsInt(HighsVarType::kInteger) ||
469+
integrality_status == HighsInt(HighsVarType::kSemiContinuous) ||
470+
integrality_status == HighsInt(HighsVarType::kSemiInteger) ;
471471
if (!legal_integrality_status) {
472-
highsLogDev(
472+
highsLogUser(
473473
options_.log_options, HighsLogType::kError,
474-
"Model has illegal integer value of %d for integrality[%d]\n",
475-
(int)integrality_status, iCol);
474+
"Model has illegal integer value of %d (type %s) for integrality[%d]\n",
475+
int(integrality_status), highsIntVarTypeToString(integrality_status).c_str(),
476+
iCol);
476477
return HighsStatus::kError;
477478
}
478479
lp.integrality_[iCol] = (HighsVarType)integrality_status;

highs/lp_data/HighsLpUtils.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3658,6 +3658,41 @@ void getSubVectorsTranspose(const HighsIndexCollection& index_collection,
36583658
}
36593659
}
36603660

3661+
std::string highsVarTypeToString(const HighsVarType type) {
3662+
switch (type) {
3663+
case HighsVarType::kContinuous: {
3664+
return "continuous";
3665+
break;
3666+
}
3667+
case HighsVarType::kInteger: {
3668+
return "integer";
3669+
break;
3670+
}
3671+
case HighsVarType::kSemiContinuous: {
3672+
return "semi continuous";
3673+
break;
3674+
}
3675+
case HighsVarType::kSemiInteger: {
3676+
return "semi integer";
3677+
break;
3678+
}
3679+
case HighsVarType::kImplicitInteger: {
3680+
return "implicit integer";
3681+
break;
3682+
}
3683+
default:
3684+
return "unknown";
3685+
}
3686+
}
3687+
3688+
std::string highsVarTypeToString(const HighsInt type) {
3689+
if (type < HighsInt(HighsVarType::kContinuous) ||
3690+
type > HighsInt(HighsVarType::kImplicitInteger)) return "Unknown";
3691+
HighsVarType type_ = HighsVarType(uint8_t(type));
3692+
return highsVarTypeToString(type_);
3693+
}
3694+
3695+
36613696
void initialiseUserScaleData(const HighsOptions& options,
36623697
HighsUserScaleData& user_scale_data) {
36633698
user_scale_data.initialise(options.user_objective_scale,

highs/lp_data/HighsLpUtils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ void getSubVectorsTranspose(const HighsIndexCollection& index_collection,
321321
HighsInt* sub_matrix_index,
322322
double* sub_matrix_value);
323323

324+
std::string highsVarTypeToString(const HighsVarType type);
325+
std::string highsVarTypeToString(const HighsInt type);
326+
324327
void initialiseUserScaleData(const HighsOptions& options,
325328
HighsUserScaleData& user_scale_data);
329+
326330
#endif // LP_DATA_HIGHSLPUTILS_H_

0 commit comments

Comments
 (0)