[sdpb] 123/233: Included printHeader and printIteration methods in SDPSolver

Tobias Hansen thansen at moszumanska.debian.org
Thu Mar 9 04:06:28 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 dc743d8e85ed61158330dae4248445b03a91a0c8
Author: David Simmons-Duffin <davidsd at gmail.com>
Date:   Fri Jan 9 13:18:40 2015 +1300

    Included printHeader and printIteration methods in SDPSolver
---
 src/SDPSolver.cpp   |  6 ++---
 src/SDPSolver.h     | 41 +++++++++++++++++--------------
 src/SDPSolverIO.cpp | 71 ++++++++++++++++++++++++-----------------------------
 3 files changed, 57 insertions(+), 61 deletions(-)

diff --git a/src/SDPSolver.cpp b/src/SDPSolver.cpp
index 4a4b7f7..874e97d 100644
--- a/src/SDPSolver.cpp
+++ b/src/SDPSolver.cpp
@@ -608,7 +608,7 @@ SDPSolverTerminateReason SDPSolver::run(const path checkpointFile) {
   Real primalStepLength;
   Real dualStepLength;
 
-  printSolverHeader();
+  printHeader();
 
   for (int iteration = 1;; iteration++) {
     if (timers["Last checkpoint"].elapsed().wall >= parameters.checkpointInterval * 1000000000LL)
@@ -686,9 +686,7 @@ SDPSolverTerminateReason SDPSolver::run(const path checkpointFile) {
       dualStepLength = primalStepLength;
     }
 
-    printSolverInfo(iteration, mu, primalObjective, dualObjective, dualityGap,
-                    primalError, dualError, primalStepLength, dualStepLength,
-                    betaCorrector, sdp.dualObjective.size(), Q.rows);
+    printIteration(iteration, mu, primalStepLength, dualStepLength, betaCorrector);
 
     // Update current point
     scaleVector(dx, primalStepLength);
diff --git a/src/SDPSolver.h b/src/SDPSolver.h
index 0341b07..2c1f39f 100644
--- a/src/SDPSolver.h
+++ b/src/SDPSolver.h
@@ -297,28 +297,33 @@ public:
   // Run the solver, backing up to checkpointFile
   SDPSolverTerminateReason run(const path checkpointFile);
 
+  // Input/output
+  void saveCheckpoint(const path &checkpointFile);
+  void loadCheckpoint(const path &checkpointFile);
+  void saveSolution(const SDPSolverTerminateReason, const path &outFile);
+  void printHeader();
+  void printIteration(int iteration,
+                      Real mu,
+                      Real primalStepLength,
+                      Real dualStepLength,
+                      Real betaCorrector)
+
+ private:
+  // Compute data needed to solve the Schur complement equation
   void initializeSchurComplementSolver(const BlockDiagonalMatrix &BilinearPairingsXInv,
                                        const BlockDiagonalMatrix &BilinearPairingsY,
                                        const Real &choleskyStabilizeThreshold);
-  void solveSchurComplementEquation(Vector &dx, Vector &dz);
+
+  // Solve the Schur complement equation in-place for dx, dy.  dx and
+  // dy will initially be set to the right-hand side of the equation.
+  // This function replaces them with the corresponding solutions.
+  void solveSchurComplementEquation(Vector &dx, Vector &dy);
+
+  // Compute (dx, dX, dy, dY), given the current mu, a reduction
+  // parameter beta.  `correctorPhase' specifies whether to use the
+  // R-matrix corresponding to the corrector step (if false, we use
+  // the predictor R-matrix)
   void computeSearchDirection(const Real &beta, const Real &mu, const bool correctorPhase);
-  void saveCheckpoint(const path &checkpointFile);
-  void loadCheckpoint(const path &checkpointFile);
-  void saveSolution(const SDPSolverTerminateReason, const path &outFile);
 };
 
-void printSolverHeader();
-void printSolverInfo(int iteration,
-                     Real mu,
-                     Real primalObjective,
-                     Real dualObjective,
-                     Real dualityGap,
-                     Real primalError,
-                     Real dualError,
-                     Real primalStepLength,
-                     Real dualStepLength,
-                     Real betaCorrector,
-                     int dualObjectiveSize,
-                     int Qrows);
-
 #endif  // SDPB_SDPSOLVER_H_
diff --git a/src/SDPSolverIO.cpp b/src/SDPSolverIO.cpp
index 6e85093..92b7eb9 100644
--- a/src/SDPSolverIO.cpp
+++ b/src/SDPSolverIO.cpp
@@ -24,45 +24,6 @@ using boost::posix_time::time_duration;
 using boost::posix_time::microseconds;
 using std::cout;
 
-void printSolverHeader() {
-  cout << "\n     time      mu        P-obj       D-obj      gap         P-err       D-err      P-step   D-step   beta  dim/stabilized\n";
-  cout << "-------------------------------------------------------------------------------------------------------------------------\n";
-}
-
-void printSolverInfo(int iteration,
-                     Real mu,
-                     Real primalObjective,
-                     Real dualObjective,
-                     Real dualityGap,
-                     Real primalError,
-                     Real dualError,
-                     Real primalStepLength,
-                     Real dualStepLength,
-                     Real betaCorrector,
-                     int dualObjectiveSize,
-                     int Qrows) {
-  Real time = Real(timers["Solver runtime"].elapsed().wall)/1000000000;
-  time_duration td(microseconds(timers["Solver runtime"].elapsed().wall)/1000);
-  std::stringstream ss;
-  ss << td;
-  gmp_fprintf(stdout,
-              "%3d  %s  %-8.1Fe %-+11.2Fe %-+11.2Fe %-9.2Fe  %-+10.2Fe  %-+10.2Fe  %-8.3Fg %-8.3Fg %-4.2Fg  %d/%d",
-              iteration,
-              ss.str().substr(0, 8).c_str(),
-              mu.get_mpf_t(),
-              primalObjective.get_mpf_t(),
-              dualObjective.get_mpf_t(),
-              dualityGap.get_mpf_t(),
-              primalError.get_mpf_t(),
-              dualError.get_mpf_t(),
-              primalStepLength.get_mpf_t(),
-              dualStepLength.get_mpf_t(),
-              betaCorrector.get_mpf_t(),
-              dualObjectiveSize,
-              Qrows);
-  cout << endl;
-}
-
 ostream& operator<<(ostream& os, const SDPSolverParameters& p) {
   os << std::boolalpha;
   os << "maxIterations                = " << p.maxIterations                << endl;
@@ -118,6 +79,38 @@ ostream &operator<<(ostream& os, const SDPSolverTerminateReason& r) {
   return os;
 }
 
+void SDPSolver::printHeader() {
+  cout << "\n     time      mu        P-obj       D-obj      gap         P-err       D-err      P-step   D-step   beta  dim/stabilized\n";
+  cout << "-------------------------------------------------------------------------------------------------------------------------\n";
+}
+
+void SDPSolver::printIteration(int iteration,
+                               Real mu,
+                               Real primalStepLength,
+                               Real dualStepLength,
+                               Real betaCorrector) {
+  Real time = Real(timers["Solver runtime"].elapsed().wall)/1000000000;
+  time_duration td(microseconds(timers["Solver runtime"].elapsed().wall)/1000);
+  std::stringstream ss;
+  ss << td;
+  gmp_fprintf(stdout,
+              "%3d  %s  %-8.1Fe %-+11.2Fe %-+11.2Fe %-9.2Fe  %-+10.2Fe  %-+10.2Fe  %-8.3Fg %-8.3Fg %-4.2Fg  %d/%d",
+              iteration,
+              ss.str().substr(0, 8).c_str(),
+              mu.get_mpf_t(),
+              primalObjective.get_mpf_t(),
+              dualObjective.get_mpf_t(),
+              dualityGap.get_mpf_t(),
+              primalError.get_mpf_t(),
+              dualError.get_mpf_t(),
+              primalStepLength.get_mpf_t(),
+              dualStepLength.get_mpf_t(),
+              betaCorrector.get_mpf_t(),
+              static_cast<int>(sdp.dualObjective.size()),
+              Q.rows);
+  cout << endl;
+}
+
 void backupCheckpointFile(path const& checkpointFile) {
   path backupFile(checkpointFile);
   backupFile.replace_extension(".ck.bk");

-- 
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