1 function [model,t_opt,nr_fct,output]=stepsize_dichotomie(model, model_data, output, x, d);
2 %
function [model,t_opt,nr_fct,output]=stepsize_dichotomie(model, model_data, output, x, d)
4 % Function calculating a stepsize following a Dichotomie-algorithm
6 %Required fields of model:
7 % model.optimization.objective_function:
function to be optimized
8 % model.optimization.tol: tolerance
for exactness of the stepsize
14 % t_opt: optimal value
for stepsize t
15 % nr_fct: number of
function calls needed during process
18 % Oliver Zeeb 25.05.2010%
21 disp(
'entered stepsize_dichotomie')
24 if model.optimization.min_or_max == 'min'
26 elseif model.optimization.min_or_max == 'max'
28 else disp('maximize or minimize? model.optimization.min_or_max not properly defined')
34 tol = model.optimization.tol;
35 nr_fct = 0; %counter for the number of function calls
36 t = 1; %Initial stepsize
39 h_t = calc_h(model,model_data,x,t,d)*min_or_max; nr_fct=nr_fct+1;
40 h_2_t = calc_h(model,model_data,x,2*t,d)*min_or_max; nr_fct=nr_fct+1;
41 h_0 = calc_h(model,model_data,x,0,d)*min_or_max; nr_fct=nr_fct+1;
43 if isempty(output) %first component, before mu is changed. i.e. value of the functional with init_params, saves one simulation in gradient_opt
49 % Surrounding the minimum
52 disp('in stepsize_dichotomie, Phase 1')
64 h_t = calc_h(model,model_data,x,t,d)*min_or_max;
67 iter_phase_1=iter_phase_1+1
68 if iter_phase_1 == max_iter_phase_1
80 h_2_t = calc_h(model,model_data,x,t,d)*min_or_max;
83 %iter_phase_1=iter_phase_1+1
84 %if iter_phase_1 == max_iter_phase_1
101 disp('in stepsize_dichotomie, Phase 2')
109 h_b = calc_h(model,model_data,x,b,d)*min_or_max; nr_fct=nr_fct+1;
111 nr_fct=nr_fct+1; %checking the following if condition needs a function call
112 if calc_h(model,model_data,x,(a+b)/2,d)*min_or_max < h_b
115 h_b=calc_h(model,model_data,x,b,d)*min_or_max; nr_fct=nr_fct+1;
116 elseif calc_h(model,model_data,x,(b+c)/2,d)*min_or_max < h_b
117 nr_fct=nr_fct+1; % elseif-condition was just checked, that needed a function call
120 h_b=calc_h(model,model_data,x,b,d)*min_or_max; nr_fct=nr_fct+1;
121 else % h(b) <= min{h((a+b)/2), h((b+c)/2)}
122 nr_fct=nr_fct+1; % elseif-condition was just checked, that needed a
function call
128 iter_phase_2=iter_phase_2+1
129 if mod(iter_phase_2,50) == 0
130 zeit_vergangen_phase_2=toc;
140 func_t_opt=calc_h(model,model_data,x,t_opt,d)*min_or_max;
141 output=[output;func_t_opt];
145 disp(
'leaving stepsize_dichotomie')
149 %calculation of function h(t), i.e. function f(x+t*d)
150 function h_t=calc_h(model,model_data,x,t,d)
152 h_t=model.optimization.objective_function(model_t_d,model_data);
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...