Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions check/TestPresolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2333,3 +2333,46 @@ TEST_CASE("presolve-mode", "[highs_test_presolve]") {
}
h.resetThreadScheduler(true);
}
TEST_CASE("issue-3545", "[highs_test_presolve]") {
HighsLp lp;
lp.num_col_ = 3;
lp.num_row_ = 2;
lp.col_cost_ = {1, 1, 3};
lp.col_lower_ = {0, 0, 2};
lp.col_upper_ = {kHighsInf, kHighsInf, 5};
lp.row_lower_ = {1, -kHighsInf};
lp.row_upper_ = {kHighsInf, 0.5};
lp.a_matrix_.start_ = {0, 2, 4, 4};
lp.a_matrix_.index_ = {0, 1, 0, 1};
lp.a_matrix_.value_ = {1, 1, 1, -1};
HighsInt z = 2;
Highs h;
h.setOptionValue("output_flag", dev_run);
REQUIRE(h.passModel(lp) == HighsStatus::kOk);

// Get the optimal objective value
REQUIRE(h.run() == HighsStatus::kOk);
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);
double optimal_objective_value = h.getObjectiveValue();
REQUIRE(h.clearSolver() == HighsStatus::kOk);

REQUIRE(h.setOptionValue("presolve_mode", kPresolveModeInitialSweep) ==
HighsStatus::kOk);

REQUIRE(h.presolve() == HighsStatus::kOk);
// Presolve with just initial sweep fixes the empty column (z) at
// its lower bound, so the presolved LP should have an offset of 6 =
// cost(z)*lower(z)
HighsLp presolved_lp = h.getPresolvedLp();
REQUIRE(presolved_lp.offset_ == lp.col_cost_[z] * lp.col_lower_[z]);
REQUIRE(h.passModel(presolved_lp) == HighsStatus::kOk);
// The absence of the offset leads to an incorrect optimal objective
// if the presolved LP is solved
REQUIRE(h.setOptionValue(kPresolveString, kHighsOffString) ==
HighsStatus::kOk);
REQUIRE(h.run() == HighsStatus::kOk);
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);
REQUIRE(h.getObjectiveValue() == optimal_objective_value);

h.resetThreadScheduler(true);
}
1 change: 1 addition & 0 deletions highs/presolve/HPresolveInitialSweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ HPresolveInitialSweep::Result HPresolveInitialSweep::emptyCol(
assert(fixval != kHighsInf);
postsolve_stack.removedModelFixedCol(col, fixval, cost, col_nnz, nullptr,
nullptr);
lp_.offset_ += cost * fixval;
if (col == lp_.fme_obj_col_) lp_.fme_obj_col_ = -1;
return Result::kOk;
}
Expand Down
Loading