Skip to content

Commit b1ffe17

Browse files
committed
Close of play
1 parent d0f8fec commit b1ffe17

File tree

5 files changed

+50
-29
lines changed

5 files changed

+50
-29
lines changed

highs/Highs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,8 +1741,7 @@ class Highs {
17411741
const double* local_lower_penalty,
17421742
const double* local_upper_penalty,
17431743
const double* local_rhs_penalty,
1744-
const bool get_infeasible_row,
1745-
std::vector<HighsInt>& infeasible_row_subset);
1744+
const bool get_iis = false);
17461745
HighsStatus extractIis(HighsInt& num_iis_col, HighsInt& num_iis_row,
17471746
HighsInt* iis_col_index, HighsInt* iis_row_index,
17481747
HighsInt* iis_col_bound, HighsInt* iis_row_bound);

highs/lp_data/Highs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,8 +2068,7 @@ HighsStatus Highs::feasibilityRelaxation(const double global_lower_penalty,
20682068
std::vector<HighsInt> infeasible_row_subset;
20692069
return elasticityFilter(global_lower_penalty, global_upper_penalty,
20702070
global_rhs_penalty, local_lower_penalty,
2071-
local_upper_penalty, local_rhs_penalty, false,
2072-
infeasible_row_subset);
2071+
local_upper_penalty, local_rhs_penalty);
20732072
}
20742073

20752074
HighsStatus Highs::getIllConditioning(HighsIllConditioning& ill_conditioning,

highs/lp_data/HighsIis.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,23 +295,24 @@ bool HighsIis::rowValueBounds(const HighsLp& lp, const HighsOptions& options) {
295295
}
296296

297297
HighsStatus HighsIis::deduce(const HighsLp& lp, const HighsOptions& options,
298-
const HighsBasis& basis,
299-
const std::vector<HighsInt>& infeasible_row) {
300-
// Check for trivial IIS should have been done earlier
301-
assert(!this->trivial(lp, options));
298+
const HighsBasis& basis) {
302299
// The number of infeasible rows must be positive
303-
assert(infeasible_row.size() > 0);
300+
assert(this->row_index_.size() > 0);
304301
// Identify the LP corresponding to the set of infeasible rows
305-
std::vector<HighsInt> from_row = infeasible_row;
302+
std::vector<HighsInt> from_row = this->row_index_;
306303
std::vector<HighsInt> from_col;
307304
std::vector<HighsInt> to_row;
308305
to_row.assign(lp.num_row_, -1);
306+
// Check for trivial IIS should have been done earlier
307+
assert(!this->trivial(lp, options));
308+
// Only uses this->row_index_ to initialise from_row, so can clear
309+
this->clear();
309310
// To get the IIS data needs the matrix to be column-wise
310311
assert(lp.a_matrix_.isColwise());
311-
// Determine how to detect whether a row is in infeasible_row and
312-
// (then) gather information about it
313-
for (HighsInt iX = 0; iX < HighsInt(infeasible_row.size()); iX++)
314-
to_row[infeasible_row[iX]] = iX;
312+
// Determine how to detect whether a row is in from_row and (then)
313+
// gather information about it
314+
for (HighsInt iX = 0; iX < HighsInt(from_row.size()); iX++)
315+
to_row[from_row[iX]] = iX;
315316
// Identify the columns (from_col) with nonzeros in the infeasible
316317
// rows
317318
for (HighsInt iCol = 0; iCol < lp.num_col_; iCol++) {

highs/lp_data/HighsIis.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class HighsIis {
4242
void removeCol(const HighsInt col);
4343
void removeRow(const HighsInt row);
4444
HighsStatus deduce(const HighsLp& lp, const HighsOptions& options,
45-
const HighsBasis& basis,
46-
const std::vector<HighsInt>& infeasible_row);
45+
const HighsBasis& basis);
4746
void setLp(const HighsLp& lp);
4847
void setStatus(const HighsLp& lp);
4948

highs/lp_data/HighsInterface.cpp

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,10 @@ HighsStatus Highs::getIisInterfaceReturn(const HighsStatus return_status) {
18481848
// is any bound is relaxed)
18491849
bool lp_ok = this->iis_.lpOk(this->options_);
18501850
if (!lp_ok) return HighsStatus::kError;
1851+
} else {
1852+
assert(!this->iis_.irreducible_);
1853+
assert(!this->iis_.col_bound_.size());
1854+
assert(!this->iis_.row_bound_.size());
18511855
}
18521856
// Construct the ISS status vectors for cols and rows of original
18531857
// model
@@ -1942,7 +1946,6 @@ HighsStatus Highs::getIisInterface() {
19421946
highsLogUser(
19431947
options_.log_options, HighsLogType::kWarning,
19441948
"No known dual ray from which to compute IIS: using whole model\n");
1945-
std::vector<HighsInt> infeasible_row_subset;
19461949
if (ray_option && has_dual_ray) {
19471950
// Compute the dual ray to identify an infeasible subset of rows
19481951
assert(ekk_instance_.status_.has_invert);
@@ -1956,7 +1959,7 @@ HighsStatus Highs::getIisInterface() {
19561959
basisSolveInterface(rhs, dual_ray_value.data(), dual_ray_num_nz, NULL,
19571960
true);
19581961
for (HighsInt iRow = 0; iRow < lp.num_row_; iRow++)
1959-
if (dual_ray_value[iRow]) infeasible_row_subset.push_back(iRow);
1962+
if (dual_ray_value[iRow]) this->iis_.row_index_.push_back(iRow);
19601963
} else {
19611964
// Full LP option chosen or no dual ray to use
19621965
//
@@ -1967,15 +1970,14 @@ HighsStatus Highs::getIisInterface() {
19671970
// Apply the elasticity filter to the whole model in order to
19681971
// determine an infeasible subset of rows
19691972
HighsStatus return_status =
1970-
this->elasticityFilter(-1.0, -1.0, 1.0, nullptr, nullptr, nullptr, true,
1971-
infeasible_row_subset);
1973+
this->elasticityFilter(-1.0, -1.0, 1.0, nullptr, nullptr, nullptr, true);
19721974
HighsLp check_lp_after = this->model_.lp_;
19731975
assert(check_lp_before.equalVectors(check_lp_after));
19741976
assert(check_lp_before.a_matrix_.equivalent(check_lp_after.a_matrix_));
19751977
if (return_status != HighsStatus::kOk) return return_status;
19761978
}
19771979
return_status = HighsStatus::kOk;
1978-
if (infeasible_row_subset.size() == 0) {
1980+
if (this->iis_.row_index_.size() == 0) {
19791981
// No subset of infeasible rows, so model is feasible
19801982
this->iis_.valid_ = true;
19811983
assert(!this->iis_.irreducible_);
@@ -1991,7 +1993,7 @@ HighsStatus Highs::getIisInterface() {
19911993
// To get the IIS data needs the matrix to be column-wise
19921994
model_.lp_.a_matrix_.ensureColwise();
19931995
return_status =
1994-
this->iis_.deduce(lp, options_, basis_, infeasible_row_subset);
1996+
this->iis_.deduce(lp, options_, basis_);
19951997
if (return_status == HighsStatus::kOk) {
19961998
// Existence of non-empty IIS => infeasibility
19971999
if (this->iis_.col_index_.size() > 0 || this->iis_.row_index_.size() > 0)
@@ -2096,12 +2098,11 @@ HighsStatus Highs::elasticityFilter(
20962098
const double global_lower_penalty, const double global_upper_penalty,
20972099
const double global_rhs_penalty, const double* local_lower_penalty,
20982100
const double* local_upper_penalty, const double* local_rhs_penalty,
2099-
const bool get_infeasible_row,
2100-
std::vector<HighsInt>& infeasible_row_subset) {
2101+
const bool get_iis) {
21012102
// this->writeModel("infeasible.mps");
21022103
//
21032104
// Solve the feasibility relaxation problem for the given penalties,
2104-
// continuing to act as the elasticity filter if get_infeasible_row
2105+
// continuing to act as the elasticity filter if get_iis
21052106
// is true, resulting in an infeasibility subset for further
21062107
// refinement as an IIS
21072108
//
@@ -2164,7 +2165,7 @@ HighsStatus Highs::elasticityFilter(
21642165
run_status = this->changeColsCost(0, lp.num_col_ - 1, zero_costs.data());
21652166
assert(run_status == HighsStatus::kOk);
21662167

2167-
const bool mip_relaxation_iis = get_infeasible_row && lp.isMip() &&
2168+
const bool mip_relaxation_iis = get_iis && lp.isMip() &&
21682169
kIisStrategyRelaxation & this->options_.iis_strategy;
21692170
if (mip_relaxation_iis) {
21702171
// Set any integrality to continuous
@@ -2419,7 +2420,7 @@ HighsStatus Highs::elasticityFilter(
24192420
assert(this->model_status_ == HighsModelStatus::kOptimal ||
24202421
this->model_status_ == HighsModelStatus::kUnbounded);
24212422

2422-
if (!get_infeasible_row)
2423+
if (!get_iis)
24232424
return elasticityFilterReturn(HighsStatus::kOk, false, original_model_name,
24242425
original_num_col, original_num_row,
24252426
original_col_cost, original_col_lower,
@@ -2485,7 +2486,7 @@ HighsStatus Highs::elasticityFilter(
24852486
loop_k++;
24862487
}
24872488

2488-
infeasible_row_subset.clear();
2489+
this->iis_.clear();
24892490
HighsInt num_enforced_col_ecol = 0;
24902491
HighsInt num_enforced_row_ecol = 0;
24912492
if (has_elastic_columns) {
@@ -2507,7 +2508,12 @@ HighsStatus Highs::elasticityFilter(
25072508
HighsInt iRow = row_of_ecol[eCol];
25082509
if (lp.col_upper_[row_ecol_offset + eCol] == 0) {
25092510
num_enforced_row_ecol++;
2510-
infeasible_row_subset.push_back(iRow);
2511+
this->iis_.row_index_.push_back(iRow);
2512+
/*
2513+
this->iis_.row_bound_.push_back(erow_value[eRow] > 0 ?
2514+
kIisBoundStatusUpper :
2515+
kIisBoundStatusLower);
2516+
*/
25112517
if (kIisDevReport)
25122518
printf(
25132519
"Row e-col %2d (column %2d) corresponds to row %2d with bound "
@@ -2517,8 +2523,25 @@ HighsStatus Highs::elasticityFilter(
25172523
}
25182524
}
25192525
}
2526+
HighsInt num_iis_row = this->iis_.row_index_.size();
2527+
/*
2528+
assert(row_of_ecol.size() == num_iis_row);
2529+
std::vector<HighsInt> erow_of_row.assign(lp.num_row_, -1);
2530+
for (HighsInt iX = 0; iX < num_iis_row; iX++) {
2531+
HighsInt iRow =
2532+
if (lp.a_matrix_.isColwise()) {
2533+
for (HighsInt iCol =
2534+
}
2535+
*/
25202536
if (feasible_model)
25212537
assert(num_enforced_col_ecol == 0 && num_enforced_row_ecol == 0);
2538+
HighsIis& iis = this->iis_;
2539+
printf("After elasticity filter num_enforced_col_ecol = %d; num_enforced_row_ecol = %d\n",
2540+
int(num_enforced_col_ecol),
2541+
int(num_enforced_row_ecol));
2542+
if (!feasible_model) this->model_status_ = HighsModelStatus::kInfeasible;
2543+
iis.valid_ = true;
2544+
iis.irreducible_ = false;
25222545

25232546
highsLogUser(
25242547
options_.log_options, HighsLogType::kInfo,

0 commit comments

Comments
 (0)