Skip to content

Commit

Permalink
No extra EOL is solve_message
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Jan 9, 2024
1 parent d91b160 commit 9495e1d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/mp/backend-std.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,22 +443,22 @@ class StdBackend :
}
if (exportKappa() && 1)
writer.write("\nkappa value: {}", Kappa());
writer.write("\n");
if (solver_msg_extra_.size()) {
writer.write("\n");
writer.write(solver_msg_extra_);
}
/// Summary on alternative solutions
if (kIntermSol_) {
if (objIntermSol_.first > -1e50)
writer.write("{} alternative solution(s)\n"
writer.write("\n{} alternative solution(s)\n"
" with objective values {}..{}\n"
" written to '{}1.sol' ... '{}{}.sol'.\n",
kIntermSol_,
objIntermSol_.first, objIntermSol_.second,
solution_stub(), solution_stub(),
kIntermSol_);
else
writer.write("{} alternative solution(s)\n"
writer.write("\n{} alternative solution(s)\n"
" written to '{}1.sol' ... '{}{}.sol'.\n",
kIntermSol_,
solution_stub(), solution_stub(),
Expand Down
6 changes: 3 additions & 3 deletions solvers/gurobi/gurobibackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1004,13 +1004,13 @@ void GurobiBackend::ReportGurobiResults() {

void GurobiBackend::AddGurobiMessage() {
AddToSolverMessage(
fmt::format("{} simplex iterations\n", SimplexIterations()));
fmt::format("{} simplex iteration(s)\n", SimplexIterations()));
if (auto nbi = BarrierIterations())
AddToSolverMessage(
fmt::format("{} barrier iterations\n", nbi));
fmt::format("{} barrier iteration(s)\n", nbi));
if (auto nnd = NodeCount())
AddToSolverMessage(
fmt::format("{} branching nodes\n", nnd));
fmt::format("{} branching node(s)\n", nnd));
}

void GurobiBackend::DoGurobiTune() {
Expand Down
9 changes: 6 additions & 3 deletions src/sol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ void mp::internal::WriteMessage(fmt::BufferedFile &file, const char *message) {
++line_end;
// Replace an empty line with a line containing a single space
// because an empty line indicates the end of message.
if (line_end == line_start)
if (line_end == line_start
&& *line_end) // but not when end of string
std::fputc(' ', file.get());
else
else {
std::fwrite(line_start, 1, line_end - line_start, file.get());
if (!*line_end)
std::fputc('\n', file.get()); // make empty line in the end
}
std::fputc('\n', file.get());
if (!*line_end)
break;
line_start = line_end + 1;
}
std::fputc('\n', file.get());
}

0 comments on commit 9495e1d

Please sign in to comment.