Optimization: principles and algorithms, by Michel Bierlaire
steepestDescent.m
Go to the documentation of this file.
1 %> \file
2 %> Algorithm 11.6: Steepest descent algorithm. Implementation of algorithm 11.6 of \cite Bier15-book
3 %>
4 %> @author <a href="http://people.epfl.ch/michel.bierlaire">Michel Bierlaire</a>
5 %> @date Fri Mar 20 17:03:30 2015
6 %> @ingroup Algorithms
7 %> @ingroup chap11
8 
9 %> \note Tested with \ref runRosenbrockSteepestDescent.m
10 %> \note Calls \ref lineSearch
11 
12 %> Applies the steepest descent algorithm with linesearch to solve \f$\min_x f(x)\f$ where \f$f:\mathbb{R}^n\to\mathbb{R}\f$.
13 %> @param obj the name of the Octave function defining f(x) and its derivatives
14 %> @param x0 the starting point
15 %> @param eps algorithm stops if \f$\|F(x)\| \leq \varepsilon \f$.
16 %> @param maxiter maximum number of iterations (Default: 100)
17 %> @return [solution,iteres,niter]
18 %> @return solution: local minimum of the function
19 %> @return iteres: sequence of iterates generated by the algorithm. It contains n+2 columns. Columns 1:n contains the value of the current iterate. Column n+1 contains the value of the objective function. Column n+2 contains the value of the norm of the gradient. It contains maxiter rows, but only the first niter rows are meaningful.
20 %> @return niter: total number of iterations
21 function [solution, iteres, niter] = steepestDescent(obj,x0,eps,maxiter = 100)
22  xk = x0 ;
23  [f,g] = feval(obj,xk) ;
24  iteres = zeros(1+ maxiter,4) ;
25  k = 0 ;
26  iteres(1,:) = [xk' f norm(g) ] ;
27  do
28  alpha = lineSearch(obj,xk,-g,1.0,1.0e-4,0.99,2) ;
29  xk = xk - alpha * g ;
30  [f,g] = feval(obj,xk);
31  k=k+1 ;
32  iteres(k+1,:) = [xk' f norm(g) ] ;
33  until (norm(g) <= eps || k >= maxiter)
34  solution = xk ;
35  niter = k ;
36 endfunction
function steepestDescent(in obj, in x0, in eps, in maxiter)
Applies the steepest descent algorithm with linesearch to solve where .
function lineSearch(in obj, in x, in d, in alpha0, in beta1, in beta2, in lambda, in printlevel)
Applies the line search algorithm to find a step along a direction that verifies the Wolfe conditions...
Copyright 2015-2016 Michel Bierlaire