Skip to content

Commit 849b1df

Browse files
author
Julian Hall
committed
Merged presolve-logging into this branch and resolved minor conflict
2 parents 591fb8d + f6de02b commit 849b1df

File tree

2 files changed

+55
-31
lines changed

2 files changed

+55
-31
lines changed

check/TestPresolve.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,3 +863,15 @@ TEST_CASE("dual-bound-tightening", "[highs_test_presolve]") {
863863
highs.passModel(lp);
864864
REQUIRE(highs.presolve() == HighsStatus::kOk);
865865
}
866+
867+
TEST_CASE("presolve-rule-off", "[highs_test_presolve]") {
868+
std::string model_file =
869+
std::string(HIGHS_DIR) + "/check/instances/flugpl.mps";
870+
Highs h;
871+
// h.setOptionValue("output_flag", dev_run);
872+
h.readModel(model_file);
873+
h.setOptionValue("log_dev_level", 1);
874+
h.run();
875+
876+
h.resetGlobalScheduler(true);
877+
}

highs/presolve/HPresolveAnalysis.cpp

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ void HPresolveAnalysis::setup(const HighsLp* model_,
2020

2121
this->allow_rule_.assign(kPresolveRuleCount, true);
2222

23-
if (options->presolve_rule_off) {
23+
if (options->presolve_rule_off || options_->log_dev_level) {
2424
// Some presolve rules are off
2525
//
2626
// Transform options->presolve_rule_off into logical settings in
2727
// allow_rule_[*], commenting on the rules switched off
28-
if (!silent)
29-
highsLogUser(options->log_options, HighsLogType::kInfo,
30-
"Presolve rules not allowed:\n");
28+
if (!silent) {
29+
if (options->presolve_rule_off) {
30+
highsLogUser(options->log_options, HighsLogType::kInfo,
31+
"Presolve rules not allowed:\n");
32+
} else {
33+
highsLogUser(options->log_options, HighsLogType::kInfo,
34+
"Permitted suppression of presolve rules via "
35+
"presolve_rule_off option:\n");
36+
}
37+
}
3138
HighsInt bit = 1;
3239
for (HighsInt rule_type = kPresolveRuleMin; rule_type < kPresolveRuleCount;
3340
rule_type++) {
@@ -37,17 +44,21 @@ void HPresolveAnalysis::setup(const HighsLp* model_,
3744
// This is a rule that can be switched off, so comment
3845
// positively if it is off
3946
allow_rule_[rule_type] = allow;
40-
if (!allow && !silent)
41-
highsLogUser(options->log_options, HighsLogType::kInfo,
42-
" Rule %2d (bit %4d): %s\n", (int)rule_type, (int)bit,
43-
utilPresolveRuleTypeToString(rule_type).c_str());
47+
if (!silent)
48+
if (!allow ||
49+
(!options->presolve_rule_off && options_->log_dev_level))
50+
highsLogUser(options->log_options, HighsLogType::kInfo,
51+
" Rule %2d (set bit %2d = %5d): %s\n",
52+
int(rule_type), int(rule_type), int(bit),
53+
utilPresolveRuleTypeToString(rule_type).c_str());
4454
} else if (!allow && !silent) {
4555
// This is a rule that cannot be switched off so, if an
4656
// attempt is made, don't allow it to be off and comment
4757
// negatively
4858
highsLogUser(options->log_options, HighsLogType::kWarning,
49-
"Cannot disallow rule %2d (bit %4d): %s\n", (int)rule_type,
50-
(int)bit, utilPresolveRuleTypeToString(rule_type).c_str());
59+
"Cannot disallow rule %2d (bit %2d = %5d): %s\n",
60+
int(rule_type), int(rule_type), int(bit),
61+
utilPresolveRuleTypeToString(rule_type).c_str());
5162
}
5263
bit *= 2;
5364
}
@@ -177,32 +188,33 @@ bool HPresolveAnalysis::analysePresolveRuleLog(const bool report) {
177188
if (report && sum_removed_row + sum_removed_col) {
178189
const std::string rule =
179190
"-------------------------------------------------------";
180-
highsLogDev(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
181-
highsLogDev(log_options, HighsLogType::kInfo,
182-
"%-25s Rows Cols Calls\n",
183-
"Presolve rule removed");
184-
highsLogDev(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
191+
highsLogUser(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
192+
highsLogUser(log_options, HighsLogType::kInfo,
193+
"%-25s Rows Cols Calls\n",
194+
"Presolve rule removed");
195+
highsLogUser(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
185196
for (HighsInt rule_type = kPresolveRuleMin; rule_type < kPresolveRuleCount;
186197
rule_type++)
187198
if (presolve_log_.rule[rule_type].call ||
188199
presolve_log_.rule[rule_type].row_removed ||
189200
presolve_log_.rule[rule_type].col_removed)
190-
highsLogDev(log_options, HighsLogType::kInfo, "%-25s %9d %9d %9d\n",
191-
utilPresolveRuleTypeToString(rule_type).c_str(),
192-
(int)presolve_log_.rule[rule_type].row_removed,
193-
(int)presolve_log_.rule[rule_type].col_removed,
194-
(int)presolve_log_.rule[rule_type].call);
195-
highsLogDev(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
196-
highsLogDev(log_options, HighsLogType::kInfo, "%-25s %9d %9d\n",
197-
"Total reductions", (int)sum_removed_row, (int)sum_removed_col);
198-
highsLogDev(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
199-
highsLogDev(log_options, HighsLogType::kInfo, "%-25s %9d %9d\n",
200-
"Original model", (int)original_num_row_,
201-
(int)original_num_col_);
202-
highsLogDev(log_options, HighsLogType::kInfo, "%-25s %9d %9d\n",
203-
"Presolved model", (int)(original_num_row_ - sum_removed_row),
204-
(int)(original_num_col_ - sum_removed_col));
205-
highsLogDev(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
201+
highsLogUser(log_options, HighsLogType::kInfo, "%-25s %9d %9d %9d\n",
202+
utilPresolveRuleTypeToString(rule_type).c_str(),
203+
(int)presolve_log_.rule[rule_type].row_removed,
204+
(int)presolve_log_.rule[rule_type].col_removed,
205+
(int)presolve_log_.rule[rule_type].call);
206+
highsLogUser(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
207+
highsLogUser(log_options, HighsLogType::kInfo, "%-25s %9d %9d\n",
208+
"Total reductions", (int)sum_removed_row,
209+
(int)sum_removed_col);
210+
highsLogUser(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
211+
highsLogUser(log_options, HighsLogType::kInfo, "%-25s %9d %9d\n",
212+
"Original model", (int)original_num_row_,
213+
(int)original_num_col_);
214+
highsLogUser(log_options, HighsLogType::kInfo, "%-25s %9d %9d\n",
215+
"Presolved model", (int)(original_num_row_ - sum_removed_row),
216+
(int)(original_num_col_ - sum_removed_col));
217+
highsLogUser(log_options, HighsLogType::kInfo, "%s\n", rule.c_str());
206218
}
207219
if (original_num_row_ == model->num_row_ &&
208220
original_num_col_ == model->num_col_) {

0 commit comments

Comments
 (0)