Skip to content

Commit 7376609

Browse files
authored
Merge pull request #2982 from ERGO-Code/iis_fix
Bug fixes for getIis
2 parents b748328 + 4183bd9 commit 7376609

2 files changed

Lines changed: 27 additions & 31 deletions

File tree

highs/lp_data/HighsIis.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -641,13 +641,6 @@ HighsStatus HighsIis::compute(const HighsLp& lp, const HighsOptions& options,
641641
HighsStatus run_status = highs.passModel(lp);
642642
assert(run_status == HighsStatus::kOk);
643643
if (basis) highs.setBasis(*basis);
644-
645-
// Initial logging
646-
this->clearLogInfo();
647-
HighsInt iter = 0;
648-
highsLogUser(log_options, HighsLogType::kInfo,
649-
"\nRunning deletion filter to identify an IIS\n");
650-
this->reportIteration(options, iter, num_rows, true);
651644
// Zero the objective
652645
std::vector<double> cost;
653646
cost.assign(lp.num_col_, 0);
@@ -781,6 +774,13 @@ HighsStatus HighsIis::compute(const HighsLp& lp, const HighsOptions& options,
781774
IisModelStatus iis_status = kIisModelStatusIrreducible;
782775
HighsStatus search_return_status = HighsStatus::kOk;
783776

777+
// Initial logging
778+
this->clearLogInfo();
779+
HighsInt iter = 0;
780+
highsLogUser(log_options, HighsLogType::kInfo,
781+
"\nRunning deletion filter to identify an IIS\n");
782+
this->reportIteration(options, iter, num_rows, true);
783+
784784
// Pass twice: rows before columns, or columns before rows, according to
785785
// row_priority
786786
for (HighsInt k = 0; k < 2; k++) {

highs/lp_data/HighsInterface.cpp

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,16 +2101,13 @@ HighsStatus Highs::getIisInterface() {
21012101
return_status = this->elasticityFilter(-1.0, -1.0, 1.0, nullptr, nullptr,
21022102
nullptr, true);
21032103
}
2104-
// Do not continue if not using kIisStrategyIrreducible or if time limit is
2105-
// reached
2106-
if (!(kIisStrategyIrreducible & this->options_.iis_strategy) ||
2107-
(this->iis_.status_ == kIisModelStatusTimeLimit))
2104+
// Do not continue if not using kIisStrategyIrreducible
2105+
if (!(kIisStrategyIrreducible & this->options_.iis_strategy))
21082106
return this->getIisInterfaceReturn(return_status, original_options,
21092107
original_callback_active);
2110-
21112108
// If neither ray and lp options were requested or if they fail to produce a
21122109
// valid IS, make one consisting of all constraints
2113-
if (!this->iis_.valid_) {
2110+
if (!this->iis_.valid_ || iis_.status_ != kIisModelStatusReducible) {
21142111
this->iis_.valid_ = true;
21152112
this->iis_.status_ = kIisModelStatusReducible;
21162113
for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++)
@@ -2531,11 +2528,12 @@ HighsStatus Highs::elasticityFilter(const double global_lower_penalty,
25312528

25322529
if (write_model) this->writeModel("elastic.mps");
25332530
// Initial logging
2534-
if (get_iis)
2531+
if (get_iis) {
25352532
highsLogUser(
25362533
options_.log_options, HighsLogType::kInfo,
25372534
"Running elasticity filter to identify an infeasible subset of rows\n");
2538-
2535+
iis.reportIteration(options_, HighsInt(0), HighsInt(0), true);
2536+
}
25392537
// Working with a copy of the IIS so clear this->iis_
25402538
this->iis_.clear();
25412539
// Lambda for gathering data when solving an LP
@@ -2605,6 +2603,7 @@ HighsStatus Highs::elasticityFilter(const double global_lower_penalty,
26052603
std::unordered_set<HighsInt> row_set;
26062604

26072605
for (;;) {
2606+
loop_k++;
26082607
if (kIisDevReport)
26092608
printf("\nElasticity filter pass %d\n==============\n", int(loop_k));
26102609
HighsInt num_fixed = 0;
@@ -2651,19 +2650,18 @@ HighsStatus Highs::elasticityFilter(const double global_lower_penalty,
26512650
}
26522651
}
26532652
}
2654-
// Report on iteration
2655-
bool force = loop_k == 0;
2656-
iis.reportIteration(options_, loop_k + 1, HighsInt(row_set.size()), force);
26572653

26582654
if (num_fixed == 0) {
26592655
// No elastic variables were positive, so problem is feasible
26602656
iis.status_ = kIisModelStatusFeasible;
2657+
iis.reportIteration(options_, loop_k, HighsInt(row_set.size()), true);
26612658
break;
26622659
}
26632660
HighsStatus run_status = solveLp();
2661+
HighsModelStatus model_status = this->getModelStatus();
26642662
if (run_status != HighsStatus::kOk) {
26652663
// Solve failed
2666-
if (this->model_status_ == HighsModelStatus::kTimeLimit) {
2664+
if (model_status == HighsModelStatus::kTimeLimit) {
26672665
iis.status_ = kIisModelStatusTimeLimit;
26682666

26692667
highsLogUser(
@@ -2684,14 +2682,10 @@ HighsStatus Highs::elasticityFilter(const double global_lower_penalty,
26842682
original_col_lower, original_col_upper, original_integrality);
26852683
}
26862684
if (kIisDevReport) this->writeSolution("", kSolutionStylePretty);
2687-
HighsModelStatus model_status = this->getModelStatus();
2688-
if (model_status == HighsModelStatus::kInfeasible) break;
2689-
loop_k++;
2685+
bool terminate = (model_status == HighsModelStatus::kInfeasible);
2686+
iis.reportIteration(options_, loop_k, HighsInt(row_set.size()), terminate);
2687+
if (terminate) break;
26902688
}
2691-
2692-
// Final report
2693-
iis.reportIteration(options_, loop_k + 1, HighsInt(row_set.size()), true);
2694-
26952689
HighsInt num_enforced_col_ecol = 0;
26962690
HighsInt num_enforced_row_ecol = 0;
26972691
if (has_elastic_columns) {
@@ -2741,13 +2735,15 @@ HighsStatus Highs::elasticityFilter(const double global_lower_penalty,
27412735
if (iis.status_ == kIisModelStatusFeasible) {
27422736
assert(num_enforced_col_ecol == 0 && num_enforced_row_ecol == 0);
27432737
assert(num_iis_row == 0);
2738+
highsLogUser(options_.log_options, HighsLogType::kInfo,
2739+
"Elasticity filter failed to reproduce infeasibility\n");
2740+
} else {
2741+
highsLogUser(options_.log_options, HighsLogType::kInfo,
2742+
"Elasticity filter after %d passes found an infeasible subset "
2743+
"of %d rows\n",
2744+
int(loop_k), row_set.size());
27442745
}
27452746

2746-
highsLogUser(options_.log_options, HighsLogType::kInfo,
2747-
"Elasticity filter after %d passes found an infeasible subset "
2748-
"of %d rows\n",
2749-
int(loop_k + 1), row_set.size());
2750-
27512747
iis.valid_ = true;
27522748
iis.strategy_ = this->options_.iis_strategy;
27532749
if (iis.status_ == kIisModelStatusFeasible) {

0 commit comments

Comments
 (0)