Skip to content

Commit df6321b

Browse files
committed
Added HighsLp member to HighsIis as IIS LP, and eliminated Highs::getIisLp(); computing IIS LP after defining IIS
1 parent eab8b22 commit df6321b

File tree

6 files changed

+24
-45
lines changed

6 files changed

+24
-45
lines changed

check/TestIis.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void testFeasibilityRelaxation(
1919
const double rhs_penalty,
2020
const double require_feasibility_objective_function_value);
2121

22-
void checkIisLp(HighsLp& lp, const HighsIis& iis, const HighsLp& iis_lp);
22+
void checkIisLp(HighsLp& lp, const HighsIis& iis);
2323

2424
TEST_CASE("lp-incompatible-bounds", "[iis]") {
2525
// LP has row0 and col2 with inconsistent bounds.
@@ -46,11 +46,9 @@ TEST_CASE("lp-incompatible-bounds", "[iis]") {
4646
highs.passModel(lp);
4747
// Perform the light IIS check
4848
highs.setOptionValue("iis_strategy", kIisStrategyLight);
49-
HighsLp iis_lp;
50-
REQUIRE(highs.getIisLp(iis_lp) == HighsStatus::kOk);
5149
HighsIis iis;
5250
REQUIRE(highs.getIis(iis) == HighsStatus::kOk);
53-
checkIisLp(lp, iis, iis_lp);
51+
checkIisLp(lp, iis);
5452

5553
highs.passModel(lp);
5654
highs.getIis(iis);
@@ -117,10 +115,7 @@ TEST_CASE("lp-empty-infeasible-row", "[iis]") {
117115
REQUIRE(iis.row_index_[0] == empty_row);
118116
REQUIRE(iis.row_bound_[0] == kIisBoundStatusUpper);
119117

120-
HighsLp iis_lp;
121-
REQUIRE(highs.getIisLp(iis_lp) == HighsStatus::kOk);
122-
123-
checkIisLp(lp, iis, iis_lp);
118+
checkIisLp(lp, iis);
124119

125120
highs.passModel(lp);
126121
highs.getIis(iis);
@@ -157,21 +152,19 @@ TEST_CASE("lp-get-iis-light", "[iis]") {
157152
highs.passModel(lp);
158153
highs.setOptionValue("iis_strategy", kIisStrategyLight);
159154
HighsIis iis;
160-
HighsLp iis_lp;
161155

162156
for (int l = 0; l < 3; l++) {
163157
for (int k = 0; k < 2; k++) {
164158
REQUIRE(highs.getIis(iis) == HighsStatus::kOk);
165159
REQUIRE(highs.getModelStatus() == HighsModelStatus::kInfeasible);
166-
REQUIRE(highs.getIisLp(iis_lp) == HighsStatus::kOk);
167160
const bool write_model = true;
168161
if (dev_run && write_model) {
169162
highs.writeModel("");
170163
printf("\nNow pass IIS LP to write it out\n");
171-
highs.passModel(iis_lp);
164+
highs.passModel(iis.lp_);
172165
highs.writeModel("");
173166
}
174-
checkIisLp(lp, iis, iis_lp);
167+
checkIisLp(lp, iis);
175168

176169
highs.passModel(lp);
177170
highs.getIis(iis);
@@ -235,9 +228,7 @@ TEST_CASE("lp-get-iis", "[iis]") {
235228
REQUIRE(iis.col_index_[1] == 1);
236229
REQUIRE(iis.row_index_[0] == 2);
237230

238-
HighsLp iis_lp;
239-
REQUIRE(highs.getIisLp(iis_lp) == HighsStatus::kOk);
240-
checkIisLp(lp, iis, iis_lp);
231+
checkIisLp(lp, iis);
241232

242233
highs.passModel(lp);
243234
highs.getIis(iis);
@@ -570,20 +561,17 @@ void testMps(std::string& model, const HighsInt iis_strategy,
570561
int(num_iis_col), int(num_iis_row));
571562
testIis(model, iis);
572563

573-
HighsLp iis_lp;
574-
REQUIRE(highs.getIisLp(iis_lp) == HighsStatus::kOk);
575-
576564
const bool write_model = true;
577565
if (dev_run && write_model) highs.writeModel("");
578566
HighsLp lp = highs.getLp();
579567

580568
if (dev_run && write_model) {
581569
printf("\nNow pass IIS LP to write it out\n");
582-
highs.passModel(iis_lp);
570+
highs.passModel(iis.lp_);
583571
highs.writeModel("");
584572
}
585573

586-
checkIisLp(lp, iis, iis_lp);
574+
checkIisLp(lp, iis);
587575

588576
highs.passModel(lp);
589577
highs.getIis(iis);
@@ -610,7 +598,8 @@ void testFeasibilityRelaxation(
610598
require_feasibility_objective_function_value);
611599
}
612600

613-
void checkIisLp(HighsLp& lp, const HighsIis& iis, const HighsLp& iis_lp) {
601+
void checkIisLp(HighsLp& lp, const HighsIis& iis) {
602+
const HighsLp& iis_lp = iis.lp_;
614603
HighsInt iis_num_col = iis.col_index_.size();
615604
HighsInt iis_num_row = iis.row_index_.size();
616605
REQUIRE(iis_lp.num_col_ == iis_num_col);

highs/Highs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,6 @@ class Highs {
578578
*/
579579
HighsStatus checkIis() const;
580580

581-
/**
582-
* @brief Get an LP corresponding to (any) irreducible infeasible subsystem
583-
* (IIS) information for the incumbent model
584-
*/
585-
HighsStatus getIisLp(HighsLp& lp);
586-
587581
/**
588582
* @brief Get the current model objective function value
589583
*/

highs/lp_data/Highs.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,20 +1953,6 @@ HighsStatus Highs::checkIis() const {
19531953
return HighsStatus::kOk;
19541954
}
19551955

1956-
HighsStatus Highs::getIisLp(HighsLp& iis_lp) {
1957-
HighsStatus return_status = HighsStatus::kOk;
1958-
1959-
if (!this->iis_.valid_) {
1960-
return_status =
1961-
interpretCallStatus(options_.log_options, this->getIisInterface(),
1962-
return_status, "getIisInterface");
1963-
if (return_status == HighsStatus::kError) return return_status;
1964-
}
1965-
this->model_.lp_.a_matrix_.ensureColwise();
1966-
this->iis_.getLp(this->model_.lp_, iis_lp);
1967-
return HighsStatus::kOk;
1968-
}
1969-
19701956
HighsStatus Highs::getDualObjectiveValue(
19711957
double& dual_objective_function_value) const {
19721958
bool have_dual_objective_value = computeDualObjectiveValue(

highs/lp_data/HighsIis.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void HighsIis::invalidate() {
2020
this->col_bound_.clear();
2121
this->row_bound_.clear();
2222
this->info_.clear();
23+
this->lp_.clear();
2324
}
2425

2526
std::string HighsIis::iisBoundStatusToString(HighsInt bound_status) const {
@@ -118,6 +119,8 @@ bool HighsIis::trivial(const HighsLp& lp, const HighsOptions& options) {
118119
num_iis_col + num_iis_row < 2);
119120
this->valid_ = true;
120121
this->strategy_ = options.iis_strategy;
122+
// Construct the ISS LP
123+
this->getLp(lp);
121124
return true;
122125
}
123126
// Now look for empty rows that cannot have zero activity
@@ -139,6 +142,8 @@ bool HighsIis::trivial(const HighsLp& lp, const HighsOptions& options) {
139142
if (this->row_index_.size() > 0) {
140143
this->valid_ = true;
141144
this->strategy_ = options.iis_strategy;
145+
// Construct the ISS LP
146+
this->getLp(lp);
142147
return true;
143148
}
144149
}
@@ -211,7 +216,8 @@ HighsStatus HighsIis::getData(const HighsLp& lp, const HighsOptions& options,
211216
return HighsStatus::kOk;
212217
}
213218

214-
void HighsIis::getLp(const HighsLp& lp, HighsLp& iis_lp) const {
219+
void HighsIis::getLp(const HighsLp& lp) {
220+
HighsLp& iis_lp = this->lp_;
215221
iis_lp.clear();
216222
HighsInt iis_num_col = this->col_index_.size();
217223
HighsInt iis_num_row = this->row_index_.size();
@@ -711,6 +717,8 @@ bool HighsIis::rowValueBounds(const HighsLp& lp, const HighsOptions& options) {
711717
assert(this->col_index_.size() == this->col_bound_.size());
712718
assert(this->row_index_.size() == this->row_bound_.size());
713719
this->valid_ = true;
720+
// Construct the ISS LP
721+
this->getLp(lp);
714722
return this->valid_;
715723
}
716724

@@ -723,8 +731,7 @@ bool HighsIis::ok(const HighsLp& lp, const HighsOptions& options) const {
723731
// infeasible, but the IIS contains no columns
724732
if (num_iis_col == 0) return true;
725733
const HighsLogOptions& log_options = options.log_options;
726-
HighsLp iis_lp;
727-
this->getLp(lp, iis_lp);
734+
const HighsLp& iis_lp = this->lp_;
728735
Highs h;
729736
h.passOptions(options);
730737
h.setOptionValue("output_flag", false);

highs/lp_data/HighsIis.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class HighsIis {
4343
HighsStatus getData(const HighsLp& lp, const HighsOptions& options,
4444
const HighsBasis& basis,
4545
const std::vector<HighsInt>& infeasible_row);
46-
void getLp(const HighsLp& lp, HighsLp& iis_lp) const;
46+
void getLp(const HighsLp& lp);
4747

4848
HighsStatus compute(const HighsLp& lp, const HighsOptions& options,
4949
const HighsBasis* basis = nullptr);
@@ -60,6 +60,7 @@ class HighsIis {
6060
std::vector<HighsInt> col_bound_;
6161
std::vector<HighsInt> row_bound_;
6262
std::vector<HighsIisInfo> info_;
63+
HighsLp lp_;
6364
};
6465

6566
#endif // LP_DATA_HIGHSIIS_H_

highs/lp_data/HighsInterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,8 @@ HighsStatus Highs::getIisInterface() {
20152015
int(max_iterations), min_time,
20162016
num_lp_solved > 0 ? sum_time / num_lp_solved : 0, max_time);
20172017
}
2018+
// Construct the ISS LP
2019+
this->iis_.getLp(lp);
20182020
return return_status;
20192021
}
20202022

0 commit comments

Comments
 (0)