Skip to content

Commit 346a7a8

Browse files
committed
Written feasibleWrtBounds
1 parent c7aa40e commit 346a7a8

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

highs/Highs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,8 @@ class Highs {
16391639

16401640
bool feasibleWrtBounds(const bool columns,
16411641
const HighsIndexCollection& index_collection,
1642-
const double* lower, const double* upper) const;
1642+
const std::vector<double>& lower,
1643+
const std::vector<double>& upper) const;
16431644
HighsStatus changeColBoundsInterface(HighsIndexCollection& index_collection,
16441645
const double* usr_col_lower,
16451646
const double* usr_col_upper);

highs/lp_data/HighsInterface.cpp

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,8 @@ HighsStatus Highs::changeCostsInterface(HighsIndexCollection& index_collection,
987987

988988
bool Highs::feasibleWrtBounds(const bool columns,
989989
const HighsIndexCollection& index_collection,
990-
const double* lower, const double* upper) const {
990+
const std::vector<double>& lower,
991+
const std::vector<double>& upper) const {
991992
if (this->info_.primal_solution_status != kSolutionStatusFeasible)
992993
return false;
993994
const HighsLp& lp = model_.lp_;
@@ -997,31 +998,38 @@ bool Highs::feasibleWrtBounds(const bool columns,
997998
HighsInt from_k;
998999
HighsInt to_k;
9991000
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-
}
1001+
if (from_k > to_k) return true;
1002+
1003+
const bool& interval = index_collection.is_interval_;
1004+
const bool& mask = index_collection.is_mask_;
1005+
const vector<HighsInt>& ix_set = index_collection.set_;
1006+
const vector<HighsInt>& ix_mask = index_collection.mask_;
1007+
1008+
std::vector<double> value = columns ?
1009+
this->solution_.col_value :
1010+
this->solution_.row_value;
1011+
1012+
HighsInt lp_ix;
1013+
HighsInt usr_ix = -1;
1014+
HighsInt ix_dim = value.size();
10061015
// Surely this is checked elsewhere
10071016
assert(0 <= from_k && to_k < ix_dim);
10081017
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;
1018+
for (HighsInt k = from_k; k < to_k + 1; k++) {
1019+
if (interval || mask) {
1020+
lp_ix = k;
1021+
} else {
1022+
lp_ix = ix_set[k];
1023+
}
1024+
HighsInt ix = lp_ix;
1025+
if (interval) {
1026+
usr_ix++;
1027+
} else {
1028+
usr_ix = k;
10241029
}
1030+
if (mask && !ix_mask[ix]) continue;
1031+
if (value[ix] < lower[usr_ix] - primal_feasibility_tolerance) return false;
1032+
if (value[ix] > upper[usr_ix] + primal_feasibility_tolerance) return false;
10251033
}
10261034
return true;
10271035
}
@@ -1078,13 +1086,18 @@ HighsStatus Highs::changeColBoundsInterface(
10781086
// nonbasic variables whose bounds have changed
10791087
setNonbasicStatusInterface(index_collection, true);
10801088
// 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-
*/
1089+
if (!this->basis_.useful) {
1090+
const bool columns = true;
1091+
const bool feasible = feasibleWrtBounds(columns, index_collection,
1092+
local_colLower, local_colUpper);
1093+
// highsLogUser(options_.log_options, HighsLogType::kInfo,
1094+
printf(
1095+
"feasibleWrtBounds is %s\n", feasible ? "True" : "False");
1096+
if (feasible) {
1097+
feasibleWrtBounds(columns, index_collection,
1098+
local_colLower, local_colUpper);
1099+
}
1100+
}
10881101
invalidateModelStatusSolutionAndInfo();
10891102
// Determine any implications for simplex data
10901103
ekk_instance_.updateStatus(LpAction::kNewBounds);

0 commit comments

Comments
 (0)