2 %> Exact line search
using golden section
4 %> @author <a href=
"http://people.epfl.ch/michel.bierlaire">Michel Bierlaire </a>
5 %> @date Fri Mar 20 17:38:25 2015
10 %> Find the global minimum of \f$h(\alpha)\f$ on \f$[\ell,u]\f$, where \f$h:\mathbb{R}\to\mathbb{R}\f$ is strictly unimodular on \f$[\ell,u]\f$. If the
function is not strictly unimodular, the result is unspecified.
12 %> \note Tested with \ref runGoldenSection.m
14 %> @param obj the name of the Octave
function defining h(x)
15 %> @param l the lower bound of the interval
16 %> @param u the upper bound of the interval
17 %> @param eps tolerance.
18 %> @
return xstar the local minimum
20 rho = (3.0 - sqrt(5.0)) / 2.0 ;
21 alpha1 = l + rho * (u - l) ;
22 h1 = feval(obj,alpha1) ;
23 alpha2 = u - rho * (u - l) ;
24 h2 = feval(obj,alpha2) ;
27 printf(
"%d\t%.6g\t%.6g\t%.6g\t%.6g\t%.6g\t%.6g\n",k,l,alpha1,alpha2,u,h1,h2)
31 alpha1 = l + rho * (u - l) ;
32 h1 = feval(obj,alpha1) ;
33 alpha2 = u - rho * (u - l) ;
34 h2 = feval(obj,alpha2) ;
39 alpha2 = u - rho * (u - l) ;
40 h2 = feval(obj,alpha2) ;
45 alpha1 = l + rho * (u - l) ;
46 h1 = feval(obj,alpha1) ;
50 printf(
"%d\t%.6g\t%.6g\t%.6g\t%.6g\t%.6g\t%.6g\n",k,l,alpha1,alpha2,u,h1,h2)
function goldenSection(in obj, in l, in u, in eps)
Find the global minimum of on , where is strictly unimodular on . If the function is not strictly u...