[sdpb] 75/233: Nicer formatting

Tobias Hansen thansen at moszumanska.debian.org
Thu Mar 9 04:06:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository sdpb.

commit bfa8df27696c5e324d8462141aa0f1d8dd9b7482
Author: David Simmons-Duffin <dsd at neptune.sns.ias.edu>
Date:   Mon Aug 11 22:28:55 2014 -0400

    Nicer formatting
---
 src/SDPSolver.cpp   |  2 +-
 src/SDPSolverIO.cpp | 22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/SDPSolver.cpp b/src/SDPSolver.cpp
index 3cf8320..d1cac6c 100644
--- a/src/SDPSolver.cpp
+++ b/src/SDPSolver.cpp
@@ -619,7 +619,7 @@ SDPSolverTerminateReason SDPSolver::run(const SDPSolverParameters &parameters,
   SDPSolverTerminateReason finished = MaxIterationsExceeded;
 
   for (int iteration = 1;; iteration++) {
-    
+
     if (timers["Save checkpoint"].elapsed().wall >= checkpointNanoseconds) {
       saveCheckpoint(checkpointFile);
       timers["Save checkpoint"].start();
diff --git a/src/SDPSolverIO.cpp b/src/SDPSolverIO.cpp
index 5dbf673..30cfee5 100644
--- a/src/SDPSolverIO.cpp
+++ b/src/SDPSolverIO.cpp
@@ -10,13 +10,11 @@
 #include "Timers.h"
 
 using boost::filesystem::path;
-using boost::timer::nanosecond_type;
 using std::cout;
 
-
 void printSolverHeader() {
-  cout << "\n     mu       P-obj       D-obj     gap         P-err        D-err       P-step   D-step   beta\n";
-  cout << "---------------------------------------------------------------------------------------------------\n";
+  cout << "\n     time    mu        P-obj       D-obj      gap         P-err         D-err       P-step   D-step   beta\n";
+  cout << "-----------------------------------------------------------------------------------------------------------\n";
 }
 
 void printSolverInfo(int iteration,
@@ -27,9 +25,11 @@ void printSolverInfo(int iteration,
                      Real primalStepLength,
                      Real dualStepLength,
                      Real betaCorrector) {
+  Real time = Real(timers["Run solver"].elapsed().wall)/1000000000;
   gmp_fprintf(stdout,
-              "%3d  %4.1Fe  %+7.2Fe  %+7.2Fe  %+7.2Fe  %s%+7.2Fe%s  %s%+7.2Fe%s  %4.1Fe  %4.1Fe  %4.2Fe\n",
+              "%3d  %-7.3Fg %-8.1Fe %-+11.2Fe %-+11.2Fe %-9.2Fe %s%-+10.2Fe%s  %s%-+10.2Fe%s  %-8.3Fg %-8.3Fg %-4.2Fg\n",
               iteration,
+              time.get_mpf_t(),
               mu.get_mpf_t(),
               status.primalObjective.get_mpf_t(),
               status.dualObjective.get_mpf_t(),
@@ -120,6 +120,14 @@ void SDPSolver::saveSolution(const path &outFile) {
   boost::filesystem::ofstream ofs(outFile);
   cout << "Saving solution to: " << outFile << endl;
   ofs.precision(int(status.primalObjective.get_prec() * 0.30102999566398114 + 5));
-  ofs << status << endl;
-  ofs << freeVariableSolution() << endl;
+  ofs << "primalObjective = " << status.primalObjective << ";\n";
+  ofs << "dualObjective   = " << status.dualObjective   << ";\n";
+  ofs << "dualityGap      = " << status.dualityGap()    << ";\n";
+  ofs << "primalError     = " << status.primalError     << ";\n";
+  ofs << "dualError       = " << status.dualError       << ";\n";
+  ofs << "runtime         = " << float(timers["Run solver"].elapsed().wall)/1000000000 << ";\n";
+  ofs << "freeVariables   = " << freeVariableSolution() << ";\n";
+  ofs << "x = " << x << ";\n";
+  ofs << "X = " << X << ";\n";
+  ofs << "Y = " << Y << ";\n";
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sdpb.git



More information about the debian-science-commits mailing list