@@ -469,10 +469,28 @@ void HighsIis::setLp(const HighsLp& lp) {
469469 iis_lp.model_name_ = lp.model_name_ + " _IIS" ;
470470}
471471
472- void HighsIis::setStatus (const HighsLp& lp) {
472+ HighsInt HighsIis::nonIsStatus (const HighsModelStatus& model_status) const {
473+ const bool is_feasible =
474+ model_status == HighsModelStatus::kOptimal ||
475+ model_status == HighsModelStatus::kUnbounded ;
476+ const bool has_is = this ->col_index_ .size () || this ->row_index_ .size ();
477+ // If the model is known to be feasible, then there should be no IS,
478+ // and all columns and rows are kIisStatusNotInConflict
479+ if (is_feasible) assert (!has_is);
480+ // If there is an IS, then all columns and rows not in the IS are
481+ // kIisStatusNotInConflict
482+ const HighsInt default_iis_status = is_feasible || has_is ?
483+ kIisStatusNotInConflict :
484+ kIisStatusMaybeInConflict ;
485+ return default_iis_status;
486+ }
487+
488+ void HighsIis::setStatus (const HighsLp& lp,
489+ const HighsModelStatus& model_status) {
473490 if (!this ->valid_ ) return ;
474- this ->col_status_ .assign (lp.num_col_ , kIisStatusNotInConflict );
475- this ->row_status_ .assign (lp.num_row_ , kIisStatusNotInConflict );
491+ const HighsInt non_is_status = nonIsStatus (model_status);
492+ this ->col_status_ .assign (lp.num_col_ , non_is_status);
493+ this ->row_status_ .assign (lp.num_row_ , non_is_status);
476494 HighsInt iis_num_col = this ->col_index_ .size ();
477495 HighsInt iis_num_row = this ->row_index_ .size ();
478496 for (HighsInt iisCol = 0 ; iisCol < iis_num_col; iisCol++)
@@ -809,7 +827,8 @@ HighsStatus HighsIis::compute(const HighsLp& lp, const HighsOptions& options,
809827
810828bool indexStatusOkReturn (const bool return_value) { return return_value; }
811829
812- bool HighsIis::indexStatusOk (const HighsLp& lp) const {
830+ bool HighsIis::indexStatusOk (const HighsLp& lp,
831+ const HighsModelStatus& model_status) const {
813832 HighsInt num_col = lp.num_col_ ;
814833 HighsInt num_row = lp.num_row_ ;
815834 bool col_status_size_ok =
@@ -843,26 +862,30 @@ bool HighsIis::indexStatusOk(const HighsLp& lp) const {
843862 // other cols and rows are kIisStatusNotConflict
844863 std::vector<HighsInt> col_status = col_status_;
845864 std::vector<HighsInt> row_status = row_status_;
865+ const HighsInt illegal_status = -99 ;
846866 for (HighsInt iX = 0 ; iX < num_iis_col; iX++) {
847867 HighsInt iCol = this ->col_index_ [iX];
848868 if (col_status_[iCol] != true_iis ? kIisStatusInConflict
849869 : kIisStatusMaybeInConflict )
850870 return indexStatusOkReturn (false );
851- col_status[iCol] = - 1 ;
871+ col_status[iCol] = illegal_status ;
852872 }
853873 for (HighsInt iX = 0 ; iX < num_iis_row; iX++) {
854874 HighsInt iRow = this ->row_index_ [iX];
855875 if (row_status_[iRow] != true_iis ? kIisStatusInConflict
856876 : kIisStatusMaybeInConflict )
857877 return indexStatusOkReturn (false );
858- row_status[iRow] = - 1 ;
878+ row_status[iRow] = illegal_status ;
859879 }
880+ const HighsInt non_is_status = nonIsStatus (model_status);
860881 for (HighsInt iCol = 0 ; iCol < num_col; iCol++) {
861- if (col_status[iCol] >= 0 && col_status[iCol] != kIisStatusNotInConflict )
882+ if (col_status[iCol] > illegal_status &&
883+ col_status[iCol] != non_is_status)
862884 return indexStatusOkReturn (false );
863885 }
864886 for (HighsInt iRow = 0 ; iRow < num_row; iRow++) {
865- if (row_status[iRow] >= 0 && row_status[iRow] != kIisStatusNotInConflict )
887+ if (row_status[iRow] > illegal_status &&
888+ row_status[iRow] != non_is_status)
866889 return indexStatusOkReturn (false );
867890 }
868891 return indexStatusOkReturn (true );
0 commit comments