clear variables
close all
clc

get_SimData()

for i = 1:50
pocet_iteraci = 200;
kritname = 'itae';
tic
%  nacteni parametru optimalizace
[ fmin_param, fmin_param_names ] = loadfminparam();
j = 1;

measurenames{j} = ('Chlazeni_50_2');
j = j+1;
% measurenames{j} = ('Chlazeni2');
% j = j+1;
% measurenames{j} = ('Ventilatory');
% j = j+1;
measurenames{j} = ('Topeni100');
j = j+1;
measurenames{j} = ('Svetla10');
j = j+1;
% measurenames{j} = ('Svetla20_new');
% j = j+1;
% measurenames{j} = ('Svetla80_new');
% j = j+1;
% measurenames{j} = ('Chlazeni50svetla50');
% j = j+1;
% measurenames{j} = ('ZvlOdvl_new');
% j = j+1;
% measurenames{j} = ('Chlazeni100_new');
% j = j+1;
% measurenames{j} = ('Chlazeni75_new');
% j = j+1;
% measurenames{j} = ('Chlazeni10_new');
% j = j+1;
% measurenames{j} = ('Topeni50_new');

%   vytvoreni optimalizacni struktury
opt_param_all = makeopt_param_all(measurenames, fmin_param_names, kritname);

%   nastaveni fminsearch
options = optimset('Display','iter','PlotFcns',@optimplotfval);
options.MaxIter = pocet_iteraci;

fmin_param_end = fminsearch(@(fmin_param) optim_all(fmin_param, opt_param_all), fmin_param, options);

save('fmin_param.mat', 'fmin_param_end', 'fmin_param_names');
savefminparam(fmin_param_end)
toc

end

