From 2bdcb1e0366008f04b7539c725c58ecc6caf22e1 Mon Sep 17 00:00:00 2001 From: JAJHall Date: Thu, 19 Dec 2024 10:22:38 +0000 Subject: [PATCH] Cleaned up and silenced --- check/TestLpSolvers.cpp | 2 +- check/TestModelProperties.cpp | 29 ++++++----------------------- check/TestPresolve.cpp | 2 +- src/lp_data/Highs.cpp | 2 +- src/lp_data/HighsInterface.cpp | 1 - src/lp_data/HighsLp.cpp | 6 +++--- src/util/HighsUtils.cpp | 11 +++++------ 7 files changed, 17 insertions(+), 36 deletions(-) diff --git a/check/TestLpSolvers.cpp b/check/TestLpSolvers.cpp index 2a59938efe..e3c5e9895b 100644 --- a/check/TestLpSolvers.cpp +++ b/check/TestLpSolvers.cpp @@ -2,7 +2,7 @@ #include "Highs.h" #include "catch.hpp" -const bool dev_run = true; +const bool dev_run = false; struct IterationCount { HighsInt simplex; diff --git a/check/TestModelProperties.cpp b/check/TestModelProperties.cpp index d96815b975..765c4b7e3e 100644 --- a/check/TestModelProperties.cpp +++ b/check/TestModelProperties.cpp @@ -196,19 +196,19 @@ TEST_CASE("value-count", "[highs_model_properties]") { REQUIRE(sumCount() == HighsInt(data.size())); data = {1, 5, 3, 1, 0, -1, 2.3, 2.6, 2.9, 2.5, 3.0}; - reportData(data); + if (dev_run) reportData(data); value_count = valueCountReport(data, 0.6); REQUIRE(value_count.size() == 6); REQUIRE(value_count[0].second == 1); REQUIRE(value_count[1].second == 1); REQUIRE(value_count[2].second == 2); - REQUIRE(value_count[3].second == 1); - REQUIRE(value_count[4].second == 5); + REQUIRE(value_count[3].second == 3); + REQUIRE(value_count[4].second == 3); REQUIRE(value_count[5].second == 1); REQUIRE(sumCount() == HighsInt(data.size())); data = {1, -1, 2.5, 0, 2.8, 5, 2.3, 2.4, 3, 1, 3.0}; - reportData(data); + if (dev_run) reportData(data); value_count = valueCountReport(data, 0.6); REQUIRE(value_count.size() == 6); REQUIRE(value_count[0].second == 1); @@ -220,7 +220,7 @@ TEST_CASE("value-count", "[highs_model_properties]") { REQUIRE(sumCount() == HighsInt(data.size())); data = {1, 2, 5, 3, 2, 1, 0, -1, 2, 2.999, 3.001}; - reportData(data); + if (dev_run) reportData(data); value_count = valueCountReport(data, 0.01); REQUIRE(value_count.size() == 6); REQUIRE(value_count[0].second == 1); @@ -232,28 +232,11 @@ TEST_CASE("value-count", "[highs_model_properties]") { REQUIRE(sumCount() == HighsInt(data.size())); } -/* - void reportValueCount( - const std::vector> value_count, - const double tolerance) { - if (!dev_run) return; - printf("Index Value Count"); - if (tolerance > 0) - printf(": %s %g\n", ": tolerance = ", tolerance); - else - printf("\n"); - - for (HighsInt iX = 0; iX < HighsInt(value_count.size()); iX++) - printf(" %2d %18.12g %2d\n", int(iX), value_count[iX].first, - int(value_count[iX].second)); -} -*/ - std::vector> valueCountReport( const std::vector data, const double tolerance) { std::vector> value_count = valueCountSorted(data, true, tolerance); - if (tolerance > 0) reportValueCount(value_count, "", tolerance); + if (dev_run && tolerance > 0) reportValueCount(value_count, "", tolerance); return value_count; } diff --git a/check/TestPresolve.cpp b/check/TestPresolve.cpp index e4263c010e..7d2e5d9604 100644 --- a/check/TestPresolve.cpp +++ b/check/TestPresolve.cpp @@ -616,7 +616,7 @@ TEST_CASE("presolve-slacks", "[highs_test_presolve]") { lp.a_matrix_.index_ = {0, 0}; lp.a_matrix_.value_ = {1, 1}; Highs h; - // h.setOptionValue("output_flag", dev_run); + h.setOptionValue("output_flag", dev_run); REQUIRE(h.passModel(lp) == HighsStatus::kOk); REQUIRE(h.presolve() == HighsStatus::kOk); REQUIRE(h.getPresolvedLp().num_col_ == 0); diff --git a/src/lp_data/Highs.cpp b/src/lp_data/Highs.cpp index a6bcb754a7..f26e89c0f3 100644 --- a/src/lp_data/Highs.cpp +++ b/src/lp_data/Highs.cpp @@ -1030,7 +1030,7 @@ HighsStatus Highs::solve() { exactResizeModel(); model_.lp_.stats(); - model_.lp_.stats_.report(stdout); + // model_.lp_.stats_.report(stdout); if (model_.isMip() && solution_.value_valid) { // Determine whether the current (partial) solution of a MIP is diff --git a/src/lp_data/HighsInterface.cpp b/src/lp_data/HighsInterface.cpp index 126dbe02f9..8df3a6e616 100644 --- a/src/lp_data/HighsInterface.cpp +++ b/src/lp_data/HighsInterface.cpp @@ -1871,7 +1871,6 @@ HighsStatus Highs::getPrimalRayInterface(bool& has_primal_ray, this->setOptionValue("presolve", kHighsOffString); this->setOptionValue("solve_relaxation", true); this->setOptionValue("allow_unbounded_or_infeasible", false); - this->writeModel("primal_ray_lp.mps"); HighsStatus call_status = this->run(); if (call_status != HighsStatus::kOk) return_status = call_status; has_primal_ray = ekk_instance_.status_.has_primal_ray; diff --git a/src/lp_data/HighsLp.cpp b/src/lp_data/HighsLp.cpp index 32f27bf6c0..bf6fe0859b 100644 --- a/src/lp_data/HighsLp.cpp +++ b/src/lp_data/HighsLp.cpp @@ -618,7 +618,7 @@ void HighsLp::stats() { double max_cost = 0; double min_cost = kHighsInf; value_count = valueCountSorted(this->col_cost_); - reportValueCount(value_count, "Column cost"); + // reportValueCount(value_count, "Column cost"); for (HighsInt iX = 0; iX < HighsInt(value_count.size()); iX++) { double cost = value_count[iX].first; if (cost == 0) continue; @@ -695,7 +695,7 @@ void HighsLp::stats() { } value_count = valueCountSorted(rhs); HighsInt num_rhs = rhs.size(); - reportValueCount(value_count, "RHS"); + // reportValueCount(value_count, "RHS"); // If there is a nonzero rhs then min_rhs and max_rhs will both // be positive and finite assert(max_rhs == 0 || (0 < min_rhs && min_rhs < kHighsInf)); @@ -717,7 +717,7 @@ void HighsLp::stats() { const double value_cluster_size = 1e-4; value_count = valueCountSorted(this->a_matrix_.value_, true, value_cluster_size); - reportValueCount(value_count, "Matrix", value_cluster_size); + // reportValueCount(value_count, "Matrix", value_cluster_size); this->stats_.relative_num_equal_a_matrix_nz = numRelativeIdentical(num_nz); } double max_value = 0; diff --git a/src/util/HighsUtils.cpp b/src/util/HighsUtils.cpp index be4c82422e..ad41b32139 100644 --- a/src/util/HighsUtils.cpp +++ b/src/util/HighsUtils.cpp @@ -1335,7 +1335,6 @@ std::vector> valueCountSorted( // Sorting by count with a positive tolerance requires analysis with // the entries sorted by value std::sort(value_count.begin(), value_count.end(), increasingValue); - reportValueCount(value_count); const HighsInt num_distinct_value = value_count.size(); @@ -1394,11 +1393,11 @@ std::vector> valueCountSorted( } } newCluster(num_distinct_value); - if (num_cluster < num_distinct_value) { - printf( - "grep valueCountSorted: num clusters = %d < %d = num distinct values\n", - int(num_cluster), int(num_distinct_value)); - } + // if (num_cluster < num_distinct_value) { + // printf( + // "grep valueCountSorted: num clusters = %d < %d = num distinct + // values\n", int(num_cluster), int(num_distinct_value)); + // } value_count.resize(num_cluster); if (!by_value) std::sort(value_count.begin(), value_count.end(), decreasingCount);