Skip to content

Unexpected error when calling getColIntegrality while all columns are continuous #2261

@rschwarz

Description

@rschwarz

Observation: In a purely continuous model, a call to getColIntegrality results in an error message: ERROR: Model integrality does not exist for index 0 as well as HighsStatus::kError.

Expectation: Even though no integrality was ever set, I'd simply expect a result of HighsVarType::kContinuous and no error.

Motivation: In some situations, a MIP model is built, but then some variables are relaxed. This way, we can end up with a problem where all variables are continuous. This need not result in an error for otherwise reasonable queries.


Some explanation: When the integrality_ vector is empty, any call to getColIntegrality (with valid column index) will fail. See:

HiGHS/src/lp_data/Highs.cpp

Lines 2980 to 2996 in fd86653

HighsStatus Highs::getColIntegrality(const HighsInt col,
HighsVarType& integrality) const {
const HighsInt num_col = this->model_.lp_.num_col_;
if (col < 0 || col >= num_col) {
highsLogUser(options_.log_options, HighsLogType::kError,
"Index %d for column integrality is outside the range [0, "
"num_col = %d)\n",
int(col), int(num_col));
return HighsStatus::kError;
}
if (static_cast<size_t>(col) < this->model_.lp_.integrality_.size()) {
integrality = this->model_.lp_.integrality_[col];
return HighsStatus::kOk;
} else {
highsLogUser(options_.log_options, HighsLogType::kError,
"Model integrality does not exist for index %d\n", int(col));
return HighsStatus::kError;

The integrality_ vector is initially empty, and only filled when the user calls changeColIntegrality the first time. Further, the integrality_ vector may also be cleared (to save memory?) after all variables are changed back to continuous, see:

// If integrality_ contains only HighsVarType::kContinuous then
// clear it
if (!lp.isMip()) lp.integrality_.clear();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions