[mlpack-git] master, mlpack-1.0.x: Better ToString() output. (57b9be5)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:45:42 EST 2015


Repository : https://github.com/mlpack/mlpack

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit 57b9be5f35b4891771e445c483724bb1d6707212
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Mar 28 15:53:27 2014 +0000

    Better ToString() output.


>---------------------------------------------------------------

57b9be5f35b4891771e445c483724bb1d6707212
 src/mlpack/core/optimizers/lrsdp/lrsdp.cpp          |  5 +----
 src/mlpack/core/optimizers/lrsdp/lrsdp_function.cpp | 15 +++++++++++++++
 src/mlpack/core/optimizers/lrsdp/lrsdp_function.hpp |  5 ++++-
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/mlpack/core/optimizers/lrsdp/lrsdp.cpp b/src/mlpack/core/optimizers/lrsdp/lrsdp.cpp
index b593889..9019ded 100644
--- a/src/mlpack/core/optimizers/lrsdp/lrsdp.cpp
+++ b/src/mlpack/core/optimizers/lrsdp/lrsdp.cpp
@@ -30,9 +30,6 @@ std::string LRSDP::ToString() const
 {
   std::ostringstream convert;
   convert << "LRSDP [" << this << "]" << std::endl;
-  convert << "  Matrix Size: " << function.C().n_rows << "x"
-      << function.C().n_cols << std::endl;
-  convert << "  Initial point Size : " << function.GetInitialPoint().n_rows
-      << "x" << function.GetInitialPoint().n_cols << std::endl;
+  convert << "  Optimizer: " << util::Indent(augLag.ToString(), 1) << std::endl;
   return convert.str();
 }
diff --git a/src/mlpack/core/optimizers/lrsdp/lrsdp_function.cpp b/src/mlpack/core/optimizers/lrsdp/lrsdp_function.cpp
index 9eac7e8..cca0c8e 100644
--- a/src/mlpack/core/optimizers/lrsdp/lrsdp_function.cpp
+++ b/src/mlpack/core/optimizers/lrsdp/lrsdp_function.cpp
@@ -55,6 +55,21 @@ void LRSDPFunction::GradientConstraint(const size_t /* index */,
       << "optimizers!" << std::endl;
 }
 
+// Return a string representation of the object.
+std::string LRSDPFunction::ToString() const
+{
+  std::stringstream convert;
+  convert << "LRSDPFunction [" << this << "]" << std::endl;
+  convert << "  Number of constraints: " << a.size() << std::endl;
+  convert << "  Constraint matrix (A_i) size: " << initialPoint.n_rows << "x"
+      << initialPoint.n_cols << std::endl;
+  convert << "  A_i modes: " << aModes.t();
+  convert << "  Constraint b_i values: " << b.t();
+  convert << "  Objective matrix (C) size: " << c.n_rows << "x" << c.n_cols
+      << std::endl;
+  return convert.str();
+}
+
 namespace mlpack {
 namespace optimization {
 
diff --git a/src/mlpack/core/optimizers/lrsdp/lrsdp_function.hpp b/src/mlpack/core/optimizers/lrsdp/lrsdp_function.hpp
index 73427fd..19089ad 100644
--- a/src/mlpack/core/optimizers/lrsdp/lrsdp_function.hpp
+++ b/src/mlpack/core/optimizers/lrsdp/lrsdp_function.hpp
@@ -57,7 +57,7 @@ class LRSDPFunction
   size_t NumConstraints() const { return b.n_elem; }
 
   //! Get the initial point of the LRSDP.
-  const arma::mat& GetInitialPoint() const {return initialPoint; }
+  const arma::mat& GetInitialPoint() const { return initialPoint; }
 
   //! Return the objective function matrix (C).
   const arma::mat& C() const { return c; }
@@ -79,6 +79,9 @@ class LRSDPFunction
   //! Modify the vector of B values.
   arma::vec& B() { return b; }
 
+  //! Return string representation of object.
+  std::string ToString() const;
+
  private:
   //! Objective function matrix c.
   arma::mat c;



More information about the mlpack-git mailing list