Skip to content

Commit 0263073

Browse files
committed
Separated solme logging blocks; formatted
1 parent f1f54b8 commit 0263073

File tree

5 files changed

+56
-47
lines changed

5 files changed

+56
-47
lines changed

highs/lp_data/Highs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ HighsStatus Highs::optimizeModel() {
16271627
presolve_.data_.recovered_basis_ = basis_;
16281628

16291629
if (model_presolve_status_ == HighsPresolveStatus::kReduced)
1630-
this->lpKktCheck(presolve_.getReducedProblem(), "Before postsolve");
1630+
this->lpKktCheck(presolve_.getReducedProblem(), "Before postsolve");
16311631

16321632
this_postsolve_time = -timer_.read(timer_.postsolve_clock);
16331633
timer_.start(timer_.postsolve_clock);
@@ -1637,11 +1637,11 @@ HighsStatus Highs::optimizeModel() {
16371637
presolve_.info_.postsolve_time = this_postsolve_time;
16381638

16391639
if (postsolve_status == HighsPostsolveStatus::kSolutionRecovered) {
1640-
// Indicate that nontrivial postsolve has been performed
1640+
// Indicate that nontrivial postsolve has been performed
16411641
if (model_presolve_status_ == HighsPresolveStatus::kReduced ||
1642-
model_presolve_status_ == HighsPresolveStatus::kReducedToEmpty)
1643-
highsLogUser(log_options, HighsLogType::kInfo,
1644-
"Performed postsolve\n");
1642+
model_presolve_status_ == HighsPresolveStatus::kReducedToEmpty)
1643+
highsLogUser(log_options, HighsLogType::kInfo,
1644+
"Performed postsolve\n");
16451645
// Set solution and its status
16461646
solution_.clear();
16471647
solution_ = presolve_.data_.recovered_solution_;
@@ -2314,7 +2314,7 @@ HighsStatus Highs::setSolution(const HighsInt num_entries,
23142314
highsLogUser(options_.log_options, HighsLogType::kWarning,
23152315
"setSolution: User set of indices has %d duplicate%s: last "
23162316
"value used\n",
2317-
int(num_duplicates), num_duplicates > 1 ? "s" : "");
2317+
int(num_duplicates), num_duplicates == 1 ? "" : "s");
23182318
return_status = HighsStatus::kWarning;
23192319
}
23202320

highs/lp_data/HighsInterface.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ void Highs::reportModelStats() const {
6666
highsLogDev(log_options, HighsLogType::kInfo, "%4s : %s\n",
6767
problem_type.c_str(), lp.model_name_.c_str());
6868
highsLogDev(log_options, HighsLogType::kInfo,
69-
"Row%s : %" HIGHSINT_FORMAT "\n",
70-
lp.num_row_, lp.num_row_ > 1 ? "s" : "");
69+
"Row%s : %" HIGHSINT_FORMAT "\n", lp.num_row_,
70+
lp.num_row_ == 1 ? "" : "s");
7171
highsLogDev(log_options, HighsLogType::kInfo,
72-
"Col%s : %" HIGHSINT_FORMAT "\n",
73-
lp.num_col_, lp.num_col_ > 1 ? "s" : "");
72+
"Col%s : %" HIGHSINT_FORMAT "\n", lp.num_col_,
73+
lp.num_col_ == 1 ? "" : "s");
7474
if (q_num_nz) {
7575
highsLogDev(log_options, HighsLogType::kInfo,
7676
"Matrix Nz : %" HIGHSINT_FORMAT "\n", a_num_nz);
7777
highsLogDev(log_options, HighsLogType::kInfo,
7878
"Hessian Nz: %" HIGHSINT_FORMAT "\n", q_num_nz);
7979
} else {
8080
highsLogDev(log_options, HighsLogType::kInfo,
81-
"Nonzero%s : %" HIGHSINT_FORMAT "\n",
82-
a_num_nz, a_num_nz > 1 ? "s" : "");
81+
"Nonzero%s : %" HIGHSINT_FORMAT "\n", a_num_nz,
82+
a_num_nz == 1 ? "" : "s");
8383
}
8484
if (num_integer)
8585
highsLogDev(log_options, HighsLogType::kInfo,
@@ -96,19 +96,22 @@ void Highs::reportModelStats() const {
9696
std::stringstream stats_line;
9797
stats_line << problem_type;
9898
if (lp.model_name_.length()) stats_line << " " << lp.model_name_;
99-
stats_line << " has "
100-
<< lp.num_row_ << " row" << (lp.num_row_ > 1 ? "s" : "") << "; "
101-
<< lp.num_col_ << " col" << (lp.num_col_ > 1 ? "s" : "");
99+
stats_line << " has " << lp.num_row_ << " row"
100+
<< (lp.num_row_ == 1 ? "" : "s") << "; " << lp.num_col_ << " col"
101+
<< (lp.num_col_ == 1 ? "" : "s");
102102
if (q_num_nz) {
103-
stats_line << "; " << a_num_nz << " matrix nonzero" << (a_num_nz > 1 ? "s" : "");
104-
stats_line << "; " << q_num_nz << " Hessian nonzero" << (q_num_nz > 1 ? "s" : "");
103+
stats_line << "; " << a_num_nz << " matrix nonzero"
104+
<< (a_num_nz == 1 ? "" : "s");
105+
stats_line << "; " << q_num_nz << " Hessian nonzero"
106+
<< (q_num_nz == 1 ? "" : "s");
105107
} else {
106-
stats_line << "; " << a_num_nz << " nonzero" << (a_num_nz > 1 ? "s" : "");
108+
stats_line << "; " << a_num_nz << " nonzero"
109+
<< (a_num_nz == 1 ? "" : "s");
107110
}
108111
if (num_integer)
109-
stats_line << "; "
110-
<< num_integer << " integer variable" << (a_num_nz > 1 ? "s" : "") << " ("
111-
<< num_binary << " binary)";
112+
stats_line << "; " << num_integer << " integer variable"
113+
<< (a_num_nz == 1 ? "" : "s") << " (" << num_binary
114+
<< " binary)";
112115
if (num_semi_continuous)
113116
stats_line << "; " << num_semi_continuous << " semi-continuous variables";
114117
if (num_semi_integer)
@@ -2662,12 +2665,11 @@ HighsStatus Highs::lpKktCheck(const HighsLp& lp, const std::string& message) {
26622665
dual_residual_tolerance = options.kkt_tolerance;
26632666
optimality_tolerance = options.kkt_tolerance;
26642667
}
2665-
info.objective_function_value =
2666-
lp.objectiveValue(solution_.col_value);
2668+
info.objective_function_value = lp.objectiveValue(solution_.col_value);
26672669
HighsPrimalDualErrors primal_dual_errors;
26682670
const bool get_residuals = !basis_.valid;
2669-
getLpKktFailures(options, lp, solution, basis_, info,
2670-
primal_dual_errors, get_residuals);
2671+
getLpKktFailures(options, lp, solution, basis_, info, primal_dual_errors,
2672+
get_residuals);
26712673
if (this->model_status_ == HighsModelStatus::kOptimal)
26722674
reportLpKktFailures(lp, options, info, message);
26732675
// get_residuals is false when there is a valid basis, since

highs/lp_data/HighsLpUtils.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,20 +1808,21 @@ void reportLpDimensions(const HighsLogOptions& log_options, const HighsLp& lp) {
18081808
else
18091809
lp_num_nz = lp.a_matrix_.start_[lp.num_col_];
18101810
highsLogUser(log_options, HighsLogType::kInfo,
1811-
"LP has %" HIGHSINT_FORMAT " row%s, %" HIGHSINT_FORMAT " column%s",
1812-
lp.num_row_, lp.num_row_ > 1 ? "s" : "",
1813-
lp.num_col_, lp.num_col_ > 1 ? "s" : "");
1811+
"LP has %" HIGHSINT_FORMAT " row%s, %" HIGHSINT_FORMAT
1812+
" column%s",
1813+
lp.num_row_, lp.num_row_ == 1 ? "" : "s", lp.num_col_,
1814+
lp.num_col_ == 1 ? "" : "s");
18141815
HighsInt num_int = getNumInt(lp);
18151816
if (num_int) {
18161817
highsLogUser(log_options, HighsLogType::kInfo,
18171818
", %" HIGHSINT_FORMAT " nonzeros and %" HIGHSINT_FORMAT
18181819
" integer column%s\n",
1819-
lp_num_nz, lp_num_nz > 1 ? "s" : "",
1820-
num_int, num_int > 1 ? "s" : "");
1820+
lp_num_nz, lp_num_nz == 1 ? "" : "s", num_int,
1821+
num_int == 1 ? "" : "s");
18211822
} else {
18221823
highsLogUser(log_options, HighsLogType::kInfo,
1823-
" and %" HIGHSINT_FORMAT " nonzero%s\n",
1824-
lp_num_nz, lp_num_nz > 1 ? "s" : "");
1824+
" and %" HIGHSINT_FORMAT " nonzero%s\n", lp_num_nz,
1825+
lp_num_nz == 1 ? "" : "s");
18251826
}
18261827
}
18271828

highs/lp_data/HighsModelUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ HighsStatus normaliseNames(const HighsLogOptions& log_options, bool column,
428428
"Replaced %d blank %6s name%s by name%s with prefix \"%s\", "
429429
"beginning with suffix %d\n",
430430
int(num_blank), column ? "column" : "row",
431-
num_blank > 1 ? "s" : "", num_blank > 1 ? "s" : "",
431+
num_blank == 1 ? "" : "s", num_blank == 1 ? "" : "s",
432432
name_prefix.c_str(), int(from_name_suffix));
433433
return HighsStatus::kWarning;
434434
}

highs/mip/HighsMipSolverData.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,10 @@ void HighsMipSolverData::runMipPresolve(
705705
}
706706
mipsolver.timer_.stop(mipsolver.timer_.presolve_clock);
707707

708-
reportPresolveReductions(mipsolver.options_mip_->log_options, presolve_status,
709-
*mipsolver.orig_model_, *mipsolver.model_);
708+
if (numRestarts == 0)
709+
reportPresolveReductions(mipsolver.options_mip_->log_options,
710+
presolve_status, *mipsolver.orig_model_,
711+
*mipsolver.model_);
710712
}
711713

712714
void HighsMipSolverData::runSetup() {
@@ -980,34 +982,38 @@ void HighsMipSolverData::runSetup() {
980982
highsLogUser(mipsolver.options_mip_->log_options, HighsLogType::kInfo,
981983
// clang-format off
982984
"\nSolving MIP model with:\n"
983-
" %" HIGHSINT_FORMAT " rows\n"
984-
" %" HIGHSINT_FORMAT " cols ("
985+
" %" HIGHSINT_FORMAT " row%s\n"
986+
" %" HIGHSINT_FORMAT " col%s ("
985987
"%" HIGHSINT_FORMAT" binary, "
986988
"%" HIGHSINT_FORMAT " integer, "
987989
"%" HIGHSINT_FORMAT" implied int., "
988990
"%" HIGHSINT_FORMAT " continuous, "
989991
"%" HIGHSINT_FORMAT " domain fixed)\n"
990-
" %" HIGHSINT_FORMAT " nonzeros\n",
992+
" %" HIGHSINT_FORMAT " nonzero%s\n",
991993
// clang-format on
992-
mipsolver.numRow(), num_col, num_binary, num_general_integer,
993-
num_implied_integer, num_continuous, num_domain_fixed,
994-
mipsolver.numNonzero());
994+
mipsolver.numRow(), mipsolver.numRow() == 1 ? "" : "s",
995+
num_col, num_col == 1 ? "" : "s", num_binary,
996+
num_general_integer, num_implied_integer, num_continuous,
997+
num_domain_fixed, mipsolver.numNonzero(),
998+
mipsolver.numNonzero() == 1 ? "" : "s");
995999
} else {
9961000
highsLogUser(mipsolver.options_mip_->log_options, HighsLogType::kInfo,
9971001
"Model after restart has "
9981002
// clang-format off
999-
"%" HIGHSINT_FORMAT " rows, "
1000-
"%" HIGHSINT_FORMAT " cols ("
1003+
"%" HIGHSINT_FORMAT " row%s, "
1004+
"%" HIGHSINT_FORMAT " col%s ("
10011005
"%" HIGHSINT_FORMAT " bin., "
10021006
"%" HIGHSINT_FORMAT " int., "
10031007
"%" HIGHSINT_FORMAT " impl., "
10041008
"%" HIGHSINT_FORMAT " cont., "
10051009
"%" HIGHSINT_FORMAT " dom.fix.), and "
1006-
"%" HIGHSINT_FORMAT " nonzeros\n",
1010+
"%" HIGHSINT_FORMAT " nonzero%s\n",
10071011
// clang-format on
1008-
mipsolver.numRow(), num_col, num_binary, num_general_integer,
1009-
num_implied_integer, num_continuous, num_domain_fixed,
1010-
mipsolver.numNonzero());
1012+
mipsolver.numRow(), mipsolver.numRow() == 1 ? "" : "s",
1013+
num_col, num_col == 1 ? "" : "s", num_binary,
1014+
num_general_integer, num_implied_integer, num_continuous,
1015+
num_domain_fixed, mipsolver.numNonzero(),
1016+
mipsolver.numNonzero() == 1 ? "" : "s");
10111017
}
10121018

10131019
heuristics.setupIntCols();

0 commit comments

Comments
 (0)