[mlpack] 14/207: Remove unsued debug messages.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Thu Mar 23 17:53:36 UTC 2017
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch master
in repository mlpack.
commit d2ea6a70cad53111e50868129dddb2320cfb9b06
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date: Fri Jan 6 18:25:00 2017 +0100
Remove unsued debug messages.
---
.../aug_lagrangian_test_functions.cpp | 43 +---------------------
.../aug_lagrangian_test_functions.hpp | 2 -
2 files changed, 1 insertion(+), 44 deletions(-)
diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
index 5d67b3d..e206aed 100644
--- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
+++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
@@ -175,35 +175,21 @@ LovaszThetaSDP::LovaszThetaSDP(const arma::mat& edges) : edges(edges),
{
// Calculate V by finding the maximum index in the edges matrix.
vertices = max(max(edges)) + 1;
-// Log::Debug << vertices << " vertices in graph." << std::endl;
}
double LovaszThetaSDP::Evaluate(const arma::mat& coordinates)
{
// The objective is equal to -Tr(ones * X) = -Tr(ones * (R^T * R)).
// This can be simplified into the negative sum of (R^T * R).
-// Log::Debug << "Evaluting objective function with coordinates:" << std::endl;
-// std::cout << coordinates << std::endl;
-// Log::Debug << "trans(coord) * coord:" << std::endl;
-// std::cout << (trans(coordinates) * coordinates) << std::endl;
-
-
arma::mat x = trans(coordinates) * coordinates;
double obj = -accu(x);
-// double obj = 0;
-// for (size_t i = 0; i < coordinates.n_cols; i++)
-// obj -= dot(coordinates.col(i), coordinates.col(i));
-
-// Log::Debug << "Objective function is " << obj << "." << std::endl;
-
return obj;
}
void LovaszThetaSDP::Gradient(const arma::mat& coordinates,
arma::mat& gradient)
{
-
// The gradient is equal to (2 S' R^T)^T, with R being coordinates.
// S' = C - sum_{i = 1}^{m} [ y_i - sigma (Tr(A_i * (R^T R)) - b_i)] * A_i
// We will calculate it in a not very smart way, but it should work.
@@ -225,10 +211,6 @@ void LovaszThetaSDP::Gradient(const arma::mat& coordinates,
(accu(trans(coordinates) % coordinates) - 1);
arma::mat zz = (inner * arma::eye<arma::mat>(n, n));
-
-// Log::Debug << "Constraint " << i << " matrix to add is " << std::endl;
-// Log::Debug << zz << std::endl;
-
s -= zz;
}
else
@@ -247,23 +229,12 @@ void LovaszThetaSDP::Gradient(const arma::mat& coordinates,
(accu(a % (trans(coordinates) * coordinates)));
arma::mat zz = (inner * a);
-
-// Log::Debug << "Constraint " << i << " matrix to add is " << std::endl;
-// Log::Debug << zz << std::endl;
-
s -= zz;
}
}
+ // The gradient of -Tr(ones * X) is equal to -2 * ones * R.
gradient = trans(2 * s * trans(coordinates));
-
- // The gradient of -Tr(ones * X) is equal to -2 * ones * R
-// arma::mat ones;
-// ones.ones(coordinates.n_rows, coordinates.n_rows);
-// gradient = -2 * ones * coordinates;
-
-// Log::Debug << "Done with gradient." << std::endl;
-// std::cout << gradient;
}
size_t LovaszThetaSDP::NumConstraints() const
@@ -281,16 +252,12 @@ double LovaszThetaSDP::EvaluateConstraint(const size_t index,
for (size_t i = 0; i < coordinates.n_cols; i++)
sum += std::abs(dot(coordinates.col(i), coordinates.col(i)));
-// Log::Debug << "Constraint " << index << " evaluates to " << sum << std::endl;
return sum;
}
size_t i = edges(0, index - 1);
size_t j = edges(1, index - 1);
-// Log::Debug << "Constraint " << index << " evaluates to " <<
-// dot(coordinates.col(i), coordinates.col(j)) << "." << std::endl;
-
// The constraint itself is X_ij, or (R^T R)_ij.
return std::abs(dot(coordinates.col(i), coordinates.col(j)));
}
@@ -299,18 +266,14 @@ void LovaszThetaSDP::GradientConstraint(const size_t index,
const arma::mat& coordinates,
arma::mat& gradient)
{
-// Log::Debug << "Gradient of constraint " << index << " is " << std::endl;
if (index == 0) // This is the constraint Tr(X) = 1.
{
gradient = 2 * coordinates; // d/dR (Tr(R R^T)) = 2 R.
-// std::cout << gradient;
return;
}
-// Log::Debug << "Evaluating gradient of constraint " << index << " with ";
size_t i = edges(0, index - 1);
size_t j = edges(1, index - 1);
-// Log::Debug << "i = " << i << " and j = " << j << "." << std::endl;
// Since the constraint is (R^T R)_ij, the gradient for (x, y) will be (I
// derived this for one of the MVU constraints):
@@ -325,8 +288,6 @@ void LovaszThetaSDP::GradientConstraint(const size_t index,
gradient.col(i) = coordinates.col(j);
gradient.col(j) += coordinates.col(i); // In case j = i (shouldn't happen).
-
-// std::cout << gradient;
}
const arma::mat& LovaszThetaSDP::GetInitialPoint()
@@ -334,8 +295,6 @@ const arma::mat& LovaszThetaSDP::GetInitialPoint()
if (initialPoint.n_rows != 0 && initialPoint.n_cols != 0)
return initialPoint; // It has already been calculated.
-// Log::Debug << "Calculating initial point." << std::endl;
-
// First, we must calculate the correct value of r. The matrix we return, R,
// will be r x V, because X = R^T R is of dimension V x V.
// The rule for calculating r (from Monteiro and Burer, eq. 5) is
diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp
index 430ebb3..645feec 100644
--- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp
+++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp
@@ -80,8 +80,6 @@ class GockenbachFunction
arma::mat initialPoint;
};
-
-
/**
* This function is the Lovasz-Theta semidefinite program, as implemented in the
* following paper:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list