From 9717c6ca8bd7c43b905293fbbcd6b64ebfa10c3b Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 25 May 2008 21:11:59 +0000 Subject: [PATCH] Made the optimization functions not return the value of the objective function. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402271 --- dlib/optimization/optimization.h | 18 +++++++++++------- dlib/optimization/optimization_abstract.h | 6 ++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/dlib/optimization/optimization.h b/dlib/optimization/optimization.h index 71aa40fb6..8595ed977 100644 --- a/dlib/optimization/optimization.h +++ b/dlib/optimization/optimization.h @@ -209,7 +209,9 @@ namespace dlib double alpha = mu*poly_min_extrap(f0, d0, f1, d1); alpha = put_in_range(0.1*mu, 0.9*mu, alpha); - DLIB_CASSERT(alpha < std::numeric_limits::infinity(), alpha); + DLIB_CASSERT(alpha < std::numeric_limits::infinity(), + "alpha: " << alpha << " mu: " << mu << " f0: " << f0 << " d0: " << d0 << " f1: " << f1 << " d1: " << d1 + ); double last_alpha = 0; double last_val = f0; @@ -302,12 +304,16 @@ namespace dlib } - DLIB_CASSERT(alpha < std::numeric_limits::infinity(), alpha); + DLIB_CASSERT(alpha < std::numeric_limits::infinity(), + "alpha: " << alpha << " mu: " << mu << " f0: " << f0 << " d0: " << d0 << " f1: " << f1 << " d1: " << d1 + ); // Now do the sectioning phase from 2.6.4 while (true) { - DLIB_CASSERT(alpha < std::numeric_limits::infinity(), alpha); + DLIB_CASSERT(alpha < std::numeric_limits::infinity(), + "alpha: " << alpha << " mu: " << mu << " f0: " << f0 << " d0: " << d0 << " f1: " << f1 << " d1: " << d1 + ); double first = a + tau2*(b-a); double last = b - tau3*(b-a); @@ -358,7 +364,7 @@ namespace dlib typename funct_der, typename T > - double find_min_quasi_newton ( + void find_min_quasi_newton ( const funct& f, const funct_der& der, T& x, @@ -423,7 +429,6 @@ namespace dlib g.swap(g2); } - return f_value; } // ---------------------------------------------------------------------------------------- @@ -433,7 +438,7 @@ namespace dlib typename funct_der, typename T > - double find_min_conjugate_gradient ( + void find_min_conjugate_gradient ( const funct& f, const funct_der& der, T& x, @@ -477,7 +482,6 @@ namespace dlib g.swap(g2); } - return f_value; } // ---------------------------------------------------------------------------------------- diff --git a/dlib/optimization/optimization_abstract.h b/dlib/optimization/optimization_abstract.h index 8ac27e740..2ef989e8f 100644 --- a/dlib/optimization/optimization_abstract.h +++ b/dlib/optimization/optimization_abstract.h @@ -149,7 +149,7 @@ namespace dlib typename funct_der, typename T > - double find_min_quasi_newton ( + void find_min_quasi_newton ( const funct& f, const funct_der& der, T& x, @@ -171,7 +171,6 @@ namespace dlib - the change in f() from one iteration to the next is less than min_delta - f(#x) <= min_f - #x == the value of x that was found to minimize f() - - returns f(#x) !*/ // ---------------------------------------------------------------------------------------- @@ -181,7 +180,7 @@ namespace dlib typename funct_der, typename T > - double find_min_conjugate_gradient ( + void find_min_conjugate_gradient ( const funct& f, const funct_der& der, T& x, @@ -203,7 +202,6 @@ namespace dlib - the change in f() from one iteration to the next is less than min_delta - f(#x) <= min_f - #x == the value of x that was found to minimize f() - - returns f(#x) !*/ // ----------------------------------------------------------------------------------------