1 function [model, t_opt,nr_fct,output, data_return] = stepsize_armijo(model, model_data, output, x, d)
2 %
function [model, t_opt,nr_fct,output] = stepsize_armijo(model, model_data, output, x, d)
4 % Function calculating a stepsize following the Armijo-rule
6 %Required fields of model:
7 % model.optimization.get_Jacobian: gradient
function
8 % model.optimization.objective_function:
function to be optimized
11 % output : vector with the sequence of the values of the functional during optimization
12 % x : vector with the current values of mu, that means parameters to
14 % d : search direction, i.e. negative gradient in gradient-method
17 % t_opt: optimal value
for stepsize t
18 % nr_fct: number of
function calls needed during process
19 % ouput: vector with the sequence of the values of the functional during
20 % optimization, value of the
new setting of mu given by the armijo rule
21 % was added at the end of the vector
24 % Oliver Zeeb 20.05.2010
28 disp(
'entered stepsize_armijo')
31 if model.optimization.min_or_max == 'min'
33 elseif model.optimization.min_or_max == 'max'
35 else disp('maximize or minimize? model.optimization.min_or_max not properly defined')
39 if isfield(model.optimization,'sigma')
40 sigma = model.optimization.sigma;
42 sigma=0.8; % 0 < sigma < 1
44 if isfield(model.optimization,'stepsize_factor')
45 stepsize_factor = model.optimization.stepsize_factor;
47 stepsize_factor=0.5; % 0 < stepsize < 1
49 if isfield(model.optimization,'initial_stepsize')
50 t = model.optimization.initial_stepsize;
58 if isfield(model,'armijo_t_min')
59 t_tol = model.optimization.armijo_t_min; %controls, that the stepsize does not become too small to avoid infinite loops
66 [func_f_x,data] = model.optimization.objective_function(model,model_data); nr_fct = nr_fct+1;
67 func_f_x = func_f_x * min_or_max;
68 if ~isempty(data)&&isfield(data,'nRB')
74 if isempty(output) %first component, before mu is changed. i.e. value of the functional with init_params, saves one simulation in gradient_opt
75 output=[output,func_f_x];
78 %calculate func(x+t*d)
81 [func_f_x_td,data] = model.optimization.objective_function(x_td_model,model_data); nr_fct = nr_fct+1;
82 func_f_x_td=func_f_x_td*min_or_max;
83 if ~isempty(data)&&isfield(data,'nRB')
89 while (func_f_x_td > func_f_x + sigma*t*grad_f_x(:)'*d) && (t >= t_tol)
91 disp('while-Schleife in Armijo')
95 [func_f_x_td,data] = model.optimization.objective_function(x_td_model, model_data);
96 func_f_x_td = func_f_x_td*min_or_max;
97 if ~isempty(data)&&isfield(data,'nRB')
107 output=[output;func_f_x_td];
108 data_return.nRB = nRB;
111 disp('leaving stepsize_armijo')
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
function model = set_mu_to_optimize(model, x, varargin)
Funcion sets the parameters that are to be optimized to the values given by x Also usable for optimiz...
function [ opt_data , model ] = optimize(model, model_data, detailed_data, reduced_data)
opt_data = optimize(model, model_data, detailed_data, reduced_data)