Skip to content

Commit 9b202d2

Browse files
author
Julian Hall
committed
Added unit test presolve-rule-off
1 parent 849b1df commit 9b202d2

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

check/TestPresolve.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,13 +865,38 @@ TEST_CASE("dual-bound-tightening", "[highs_test_presolve]") {
865865
}
866866

867867
TEST_CASE("presolve-rule-off", "[highs_test_presolve]") {
868+
std::string model = "afiro";
868869
std::string model_file =
869-
std::string(HIGHS_DIR) + "/check/instances/flugpl.mps";
870+
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
870871
Highs h;
871-
// h.setOptionValue("output_flag", dev_run);
872+
h.setOptionValue("output_flag", dev_run);
872873
h.readModel(model_file);
873874
h.setOptionValue("log_dev_level", 1);
874-
h.run();
875-
875+
h.setOptionValue("presolve_rule_logging", true);
876+
HighsInt full_presolve_num_col, full_presolve_num_row;
877+
// Run presolve with and without aggregator
878+
for (HighsInt k = 0; k < 2; k++) {
879+
h.presolve();
880+
if (k == 0) {
881+
full_presolve_num_col = h.getPresolvedLp().num_col_;
882+
full_presolve_num_row = h.getPresolvedLp().num_row_;
883+
if (dev_run)
884+
printf("Presolved %s has num_col = %d; num_row = %d\n", model.c_str(),
885+
int(full_presolve_num_col), int(full_presolve_num_row));
886+
HighsPresolveLog presolve_log = h.getPresolveLog();
887+
REQUIRE(presolve_log.rule[kPresolveRuleAggregator].col_removed > 0);
888+
HighsInt presolve_rule_off =
889+
std::pow(int(2), int(kPresolveRuleAggregator));
890+
h.setOptionValue("presolve_rule_off", presolve_rule_off);
891+
} else if (k > 0) {
892+
HighsInt presolve_num_col = h.getPresolvedLp().num_col_;
893+
HighsInt presolve_num_row = h.getPresolvedLp().num_row_;
894+
REQUIRE(presolve_num_col > full_presolve_num_col);
895+
REQUIRE(presolve_num_row > full_presolve_num_row);
896+
if (dev_run)
897+
printf("Presolved %s has num_col = %d; num_row = %d\n", model.c_str(),
898+
int(presolve_num_col), int(presolve_num_row));
899+
}
900+
}
876901
h.resetGlobalScheduler(true);
877902
}

0 commit comments

Comments
 (0)