rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
set_mu_to_optimize.m
Go to the documentation of this file.
1 function [model] = set_mu_to_optimize(model,x,varargin)
2 %function [model] = change_x(model,x,t,d)
3 %Funcion sets the parameters that are to be optimized to the values given
4 %by x
5 %Also usable for optimization: function sets the parameters to x+t*d if t
6 %and d are given
7 %
8 %Required fields of model:
9 % model.mu_names: field with the names of the paramters that are to be
10 %changed
11 % model.??? all the fields that are given in model.mu_names and are to be
12 %optimized
13 % model.optimization.params_to_optimize: which parameters are to be changed?
14 %
15 % x : the current setting of the parameters (should have the same length as there
16 % are ones in model.optimization.params_to_optimize, i.e. the number of parameters that are to be optimized)
17 %optional:
18 % t : is stepsize
19 % d : the search direction (i.e. the gradient in gradient search)
20 %
21 % Oliver Zeeb 07.06.10
22 
23 if length(varargin) > 0
24  t=varargin{1};
25  d=varargin{2};
26  %error('more implementation needed here')
27 else
28  t=0;
29  d=zeros(size(x));
30 end
31 
32 if length(x)~=length(get_mu(model))
33  error('implement exception for params to optimize here!')
34 else
35  %check if x+t*d is inside model bounds
36  mu_next = x+t.*d;
37  mu_ranges = model.mu_ranges;
38  if(length(mu_next) == length(mu_ranges))
39  for i=1:length(mu_ranges)
40  if mu_next(i)<mu_ranges{i}(1)
41  mu_next(i) = mu_ranges{i}(1);
42  elseif mu_next(i)>mu_ranges{i}(2)
43  mu_next(i) = mu_ranges{i}(2);
44  end
45  end
46  end
47  model = set_mu(model,mu_next);
48 end
49 % l=1;
50 % for k=1:length(model.optimization.params_to_optimize)
51 % if model.optimization.params_to_optimize(k) == 1
52 % model.(model.mu_names{k}) = x(l)+t*d(l);
53 % l=l+1;
54 % end
55 % end
56 
57 
58 
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)
Definition: optimize.m:17