Skip to content

Commit c7aa40e

Browse files
committed
Find out why set_to_ix < ix_dim fail
1 parent cd1e016 commit c7aa40e

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

highs/Highs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,10 @@ class Highs {
16361636
const HighsVarType* usr_inegrality);
16371637
HighsStatus changeCostsInterface(HighsIndexCollection& index_collection,
16381638
const double* usr_col_cost);
1639+
1640+
bool feasibleWrtBounds(const bool columns,
1641+
const HighsIndexCollection& index_collection,
1642+
const double* lower, const double* upper) const;
16391643
HighsStatus changeColBoundsInterface(HighsIndexCollection& index_collection,
16401644
const double* usr_col_lower,
16411645
const double* usr_col_upper);

highs/lp_data/HighsInterface.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,47 @@ HighsStatus Highs::changeCostsInterface(HighsIndexCollection& index_collection,
985985
return HighsStatus::kOk;
986986
}
987987

988+
bool Highs::feasibleWrtBounds(const bool columns,
989+
const HighsIndexCollection& index_collection,
990+
const double* lower, const double* upper) const {
991+
if (this->info_.primal_solution_status != kSolutionStatusFeasible)
992+
return false;
993+
const HighsLp& lp = model_.lp_;
994+
const double primal_feasibility_tolerance =
995+
this->options_.primal_feasibility_tolerance;
996+
assert(ok(index_collection));
997+
HighsInt from_k;
998+
HighsInt to_k;
999+
limits(index_collection, from_k, to_k);
1000+
HighsInt ix_dim;
1001+
if (columns) {
1002+
ix_dim = lp.num_col_;
1003+
} else {
1004+
ix_dim = lp.num_row_;
1005+
}
1006+
// Surely this is checked elsewhere
1007+
assert(0 <= from_k && to_k < ix_dim);
1008+
assert(from_k <= to_k);
1009+
HighsInt set_from_ix;
1010+
HighsInt set_to_ix;
1011+
HighsInt ignore_from_ix;
1012+
HighsInt ignore_to_ix = -1;
1013+
HighsInt current_set_entry = 0;
1014+
for (HighsInt k = from_k; k <= to_k; k++) {
1015+
updateOutInIndex(index_collection, set_from_ix, set_to_ix, ignore_from_ix,
1016+
ignore_to_ix, current_set_entry);
1017+
assert(set_to_ix < ix_dim);
1018+
assert(ignore_to_ix < ix_dim);
1019+
for (HighsInt iX = set_from_ix; iX <= set_to_ix; iX++) {
1020+
double value = columns ? this->solution_.col_value[iX]
1021+
: this->solution_.row_value[iX];
1022+
if (value < lower[iX] - primal_feasibility_tolerance) return false;
1023+
if (value > upper[iX] + primal_feasibility_tolerance) return false;
1024+
}
1025+
}
1026+
return true;
1027+
}
1028+
9881029
HighsStatus Highs::changeColBoundsInterface(
9891030
HighsIndexCollection& index_collection, const double* col_lower,
9901031
const double* col_upper) {
@@ -1037,6 +1078,13 @@ HighsStatus Highs::changeColBoundsInterface(
10371078
// nonbasic variables whose bounds have changed
10381079
setNonbasicStatusInterface(index_collection, true);
10391080
// Deduce the consequences of new col bounds
1081+
/*
1082+
const bool columns = true;
1083+
const bool feasible = feasibleWrtBounds(columns, index_collection,
1084+
local_colLower.data(), local_colUpper.data());
1085+
highsLogUser(options_.log_options, HighsLogType::kInfo,
1086+
"feasibleWrtBounds is %s\n", feasible ? "True" : "False");
1087+
*/
10401088
invalidateModelStatusSolutionAndInfo();
10411089
// Determine any implications for simplex data
10421090
ekk_instance_.updateStatus(LpAction::kNewBounds);

0 commit comments

Comments
 (0)