EXAMPLE (LINE SEARCH ALGORITHM)
--------------------------------
Consider the line search subproblem in the kth iteration,
which consists of:
i) given a candidate solution x(k) and a direction of search s(k)
ii) find alpha(k) to minimize f(x(k)+alpha*s(k)) with respect to alpha, such that
iii) x(k+1) = x(k) + alpha(k)*s(k)
Let us apply our matlab function to the example given in Fletcher (2006):
* Suppose f is the Rosenbrock's function:
f(x) = 100*(x2-x1^2)^2+(1-x1)^2 .
Moreover, let x(k)=[0,0] and s(k)=[1,0]' .
** The solution is found in two steps:
*** First, we need to construct a matlab function that
returns f(alpha) and df/dalpha for any x(k), s(k) and alpha.
This can be done as follows:
function [f,df] = function_name(x,ds,alpha);
x = x' + alpha*ds;
f = 100*( x(2) - x(1)^2 )^2 + ( 1 - x(1) )^2;
df(1) = -400 *(x(2)-x(1)^2)*x(1) -2*(1-x(1));
df(2) = 200*( x(2) - x(1)^2 );
df = df*ds;
*** Second, suppose we want to perform an exact line search: sigma=0.1
with the initial guess alpha=0.1, then we only have to write
in the command window:
>> [alpha] = line_search('function_name',zeros(1,2),[1,0]',0,0.1,0.1)
, which gives us the solution:
alpha = 0.1609
Angel Luis López
URL: http://www.angelluislopez.net Email: alopezr [at] iese [edu]