Skip to content

Commit

Permalink
Added presolve-slacks test case to TestPresolve.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Oct 25, 2024
1 parent cceea9a commit 6e5297e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
38 changes: 38 additions & 0 deletions check/TestPresolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,41 @@ TEST_CASE("write-presolved-model", "[highs_test_presolve]") {
REQUIRE(highs.getInfo().simplex_iteration_count == -1);
std::remove(presolved_model_file.c_str());
}

TEST_CASE("presolve-slacks", "[highs_test_presolve]") {
// This LP reduces to empty, because the equation is a doubleton
HighsLp lp;
lp.num_col_ = 2;
lp.num_row_ = 1;
lp.col_cost_ = {1, 0};
lp.col_lower_ = {0, 0};
lp.col_upper_ = {kHighsInf, kHighsInf};
lp.row_lower_ = {1};
lp.row_upper_ = {1};
lp.a_matrix_.start_ = {0, 1, 2};
lp.a_matrix_.index_ = {0, 0};
lp.a_matrix_.value_ = {1, 1};
Highs h;
h.setOptionValue("output_flag", dev_run);
REQUIRE(h.passModel(lp) == HighsStatus::kOk);
REQUIRE(h.presolve() == HighsStatus::kOk);
REQUIRE(h.getPresolvedLp().num_col_ == 0);
REQUIRE(h.getPresolvedLp().num_row_ == 0);

lp.num_col_ = 4;
lp.num_row_ = 2;
lp.col_cost_ = {-10, -25, 0, 0};
lp.col_lower_ = {0, 0, 0, 0};
lp.col_upper_ = {kHighsInf, kHighsInf, kHighsInf, kHighsInf};
lp.row_lower_ = {80, 120};
lp.row_upper_ = {80, 120};
lp.a_matrix_.start_ = {0, 2, 4, 5, 6};
lp.a_matrix_.index_ = {0, 1, 0, 1, 0, 1};
lp.a_matrix_.value_ = {1, 1, 2, 4, 1, 1};

REQUIRE(h.passModel(lp) == HighsStatus::kOk);
REQUIRE(h.run() == HighsStatus::kOk);
REQUIRE(h.presolve() == HighsStatus::kOk);
// REQUIRE(h.getPresolvedLp().num_col_ == 0);
// REQUIRE(h.getPresolvedLp().num_row_ == 0);
}
3 changes: 2 additions & 1 deletion src/qpsolver/dantzigpricing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class DantzigPricing : public Pricing {

public:
DantzigPricing(Runtime& rt, Basis& bas, ReducedCosts& rc)
// clang-format off
: runtime(rt), basis(bas), redcosts(rc) {};

// clang-format on
HighsInt price(const QpVector& x, const QpVector& gradient) {
HighsInt minidx = chooseconstrainttodrop(redcosts.getReducedCosts());
return minidx;
Expand Down
2 changes: 2 additions & 0 deletions src/qpsolver/devexpricing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class DevexPricing : public Pricing {
: runtime(rt),
basis(bas),
redcosts(rc),
// clang-format off
weights(std::vector<double>(rt.instance.num_var, 1.0)) {};
// clang-format on

// B lambda = g
// lambda = inv(B)g
Expand Down

0 comments on commit 6e5297e

Please sign in to comment.