toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN/optimization conjugate_gradient.h


From: Edward Rosten
Subject: [Toon-members] TooN/optimization conjugate_gradient.h
Date: Thu, 09 Apr 2009 11:14:27 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/04/09 11:14:27

Modified files:
        optimization   : conjugate_gradient.h 

Log message:
        Update conjugate gradient to use Brent't linesearch algorithm. 
        
        In cg_test, this results in about half the total number of function
        evaluations.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/optimization/conjugate_gradient.h?cvsroot=toon&r1=1.1&r2=1.2

Patches:
Index: conjugate_gradient.h
===================================================================
RCS file: /cvsroot/toon/TooN/optimization/conjugate_gradient.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- conjugate_gradient.h        7 Apr 2009 14:33:06 -0000       1.1
+++ conjugate_gradient.h        9 Apr 2009 11:14:27 -0000       1.2
@@ -1,4 +1,4 @@
-#include <TooN/optimization/golden_section.h>
+#include <TooN/optimization/brent.h>
 #include <utility>
 #include <cmath>
 #include <cassert>
@@ -156,11 +156,12 @@
        Precision old_y;     ///< Function at  old_x
 
        Precision tolerance; ///< Tolerance used to determine if the 
optimization is complete. Defaults to square root of machine precision.
-       Precision epsilon;   ///< Additive term in tolerance to prevent 
excessive iterations if \f$x_\mathrm{optimal} = 0\f$. Known as \c ZEPS in 
numerical recipies.
+       Precision epsilon;   ///< Additive term in tolerance to prevent 
excessive iterations if \f$x_\mathrm{optimal} = 0\f$. Known as \c ZEPS in 
numerical recipies. Defaults to 1e-20
        int       max_iterations; ///< Maximum number of iterations. Defaults 
to \c size\f$*100\f$
 
        Precision bracket_initial_lambda;///< Initial stepsize used in 
bracketing the minimum for the line search. Defaults to 1.
        Precision linesearch_tolerance; ///< Tolerance used to determine if the 
linesearch is complete. Defaults to square root of machine precision.
+       Precision linesearch_epsilon; ///< Additive term in tolerance to 
prevent excessive iterations if \f$x_\mathrm{optimal} = 0\f$. Known as \c ZEPS 
in numerical recipies. Defaults to 1e-20
        int linesearch_max_iterations;  ///< Maximum number of iterations in 
the linesearch. Defaults to 100.
 
        int iterations; ///< Number of iterations performed
@@ -188,6 +189,7 @@
                bracket_initial_lambda = 1;
 
                linesearch_tolerance =  
sqrt(numeric_limits<Precision>::epsilon());
+               linesearch_epsilon = 1e-20;
                linesearch_max_iterations=100;
 
                iterations=0;
@@ -227,7 +229,7 @@
                assert(a_val > b_val && b_val < c_val);
                
                //Find the real minimum
-               Vector<2, Precision>  m = golden_section_search(a, b, c, b_val, 
line, linesearch_max_iterations); 
+               Vector<2, Precision>  m = brent_line_search(a, b, c, b_val, 
line, linesearch_max_iterations, linesearch_tolerance, linesearch_epsilon); 
        
                assert(m[0] >= a && m[0] <= c);
                assert(m[1] <= b_val);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]