Skip to content

Commit

Permalink
Cleaned up and silenced
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Dec 19, 2024
1 parent 93f664e commit 2bdcb1e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 36 deletions.
2 changes: 1 addition & 1 deletion check/TestLpSolvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Highs.h"
#include "catch.hpp"

const bool dev_run = true;
const bool dev_run = false;

struct IterationCount {
HighsInt simplex;
Expand Down
29 changes: 6 additions & 23 deletions check/TestModelProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -232,28 +232,11 @@ TEST_CASE("value-count", "[highs_model_properties]") {
REQUIRE(sumCount() == HighsInt(data.size()));
}

/*
void reportValueCount(
const std::vector<std::pair<double, HighsInt>> 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<std::pair<double, HighsInt>> valueCountReport(
const std::vector<double> data, const double tolerance) {
std::vector<std::pair<double, HighsInt>> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion check/TestPresolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lp_data/Highs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/lp_data/HighsInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/lp_data/HighsLp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions src/util/HighsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,6 @@ std::vector<std::pair<double, HighsInt>> 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();

Expand Down Expand Up @@ -1394,11 +1393,11 @@ std::vector<std::pair<double, HighsInt>> 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);
Expand Down

0 comments on commit 2bdcb1e

Please sign in to comment.