1 function [t_opt,nr_fct,nr_grad]=stepsize_wolfe_powell (model, x, d);
2 %
function [t_opt,nr_fct,nr_grad]=stepsize_wolfe_powell (model, x, d)
4 % Function calculating a stepsize following the Wolfe-Powell-rule
6 %Required fields of model:
7 % model.optimization.get_Jacobian: gradient function
8 % model.optimization.objective_function: function to be optimized
14 % t_opt: optimal value for stepsize t
15 % nr_fct: number of function calls needed during process
16 % nr_grad: number of calculations of the gradient
19 % Oliver Zeeb 20.05.2010%
22 nr_fct = 0; %counter
for number of
function calls
23 nr_grad = 0; %counter
for number of gradient calculations
25 rho = 0.25; % 0 < rho < 0.5
26 sigma = 0.125; % 0 < sigma < 0.5
28 grad_f = model.optimization.get_Jacobian;
29 func = model.optimization.objective_function;
33 %needed functions
for the algorithm
34 grad_phi_0 = grad_f(x)*d
';
37 phi = @(t) func(x+t*d);
38 psi = @(t) phi(t) - phi(0) - sigma*t*grad_phi_0;
40 grad_phi = @(t) grad_f(x+t*d)*d';
44 psi_test=phi(t) - phi(0) - sigma*t*grad_phi_0;
45 grad_ohi_test=grad_f(x+t*d)*d
';
52 kondition_a = 0; % condition, to enter the Phase-A-loop
59 while kondition_a == 0
60 nr_fct=nr_fct+1; % checking the next if-condition needs a function call
65 break; % leaving this loop, continuing with Phase B
66 elseif grad_phi(t) >= rho*grad_phi_0 % psi(t) < 0 and phi_strich(t) >= rho * phi_strich(0) --> algorithm found an optimal stepsize t
70 else % psi(t) < 0 an phi_strich(t) < rho * phi_strich(0)
71 nr_grad=nr_grad+1; %grad_phi in elseif condition needed calculation of the gradient
82 tau1 = 0.2; % 0 < tau1 < 0.5
83 tau2 = 0.2; % 0 < tau2 < 0.5
85 kondition_b=0; % condition to enter the Phase-B-loop
87 % According to the Wolfe-Powell-Algorithm the following loop terminates
88 while kondition_b == 0
90 t=0.5*(a*(1-tau1+tau2) + b*(1+tau1-tau2)); % choose t in [a+tau1(b-a), b-tau2(b-a)
93 nr_fct=nr_fct+1; %checking the next if-condition needs a function call
96 elseif grad_phi(t) >= rho * grad_phi_0 % psi(t) > 0 and phi_strich(t) >= rho* phi_strich(0) --> algorithm found an optimal stepsize t
99 return % STOP 2 point where the algorithm terminates! --> leaves the function
100 else % psi(t) < 0 and phi_strich(t) < rho * phi_strich(0)
101 nr_grad=nr_grad+1; %grad_phi in elseif condition needed calculation of the gradient