From 6e5297e714ec9708c9a538e78966ef94333abe08 Mon Sep 17 00:00:00 2001 From: JAJHall Date: Fri, 25 Oct 2024 13:32:41 +0100 Subject: [PATCH] Added presolve-slacks test case to TestPresolve.cpp --- check/TestPresolve.cpp | 38 +++++++++++++++++++++++++++++++++ src/qpsolver/dantzigpricing.hpp | 3 ++- src/qpsolver/devexpricing.hpp | 2 ++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/check/TestPresolve.cpp b/check/TestPresolve.cpp index 86c5dfc469..b0a4dbc95b 100644 --- a/check/TestPresolve.cpp +++ b/check/TestPresolve.cpp @@ -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); +} diff --git a/src/qpsolver/dantzigpricing.hpp b/src/qpsolver/dantzigpricing.hpp index 89b109e5c1..5a62dce7fb 100644 --- a/src/qpsolver/dantzigpricing.hpp +++ b/src/qpsolver/dantzigpricing.hpp @@ -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; diff --git a/src/qpsolver/devexpricing.hpp b/src/qpsolver/devexpricing.hpp index a88f3ecea5..014d8ce283 100644 --- a/src/qpsolver/devexpricing.hpp +++ b/src/qpsolver/devexpricing.hpp @@ -58,7 +58,9 @@ class DevexPricing : public Pricing { : runtime(rt), basis(bas), redcosts(rc), + // clang-format off weights(std::vector(rt.instance.num_var, 1.0)) {}; + // clang-format on // B lambda = g // lambda = inv(B)g