1 % script generating landscapes plot data by computing the error estimator of
2 % reduced simulations
for given test parameters over differing basis sizes.
4 % The generated cell array
'output' can later be visualized with
7 % required variables that need to be
set:
10 % - 'Nsize' : number of reduced basis sizes to be tested.
11 % - 'Msize' : number of colletaral reduced basis sizes to be tested.
12 % - 'Mstrich_samples' : vector of values that are assigned to M\' for plots
14 % - 'csample' : vector of increasing values between 0 and 1 indicating a
15 % set of reduced basis sizes to be tested for coupled
16 % plots. See also couple_N_and_M_by_c() for more
18 % - 'cdescr' : description text for coupled plots.
19 % - 'mu_set_size' : default size of test parameter set.
20 % - 'model.RB_detailed_train_savepath' : path to detailed simulations
21 % for train parameter set.
22 % - 'params.step8_outputfile' : file name where the generated output
25 % optional variables that can be set:
26 % - 'estimator_plots' : cell array of strings specifying which test cases
27 % shall be handled by the script. Possible choices are
28 % -# 'Mstrich_1_coupled' -- plot of error estimates over 'c', where 'c'
29 % couples 'N' and 'M' by couple_N_and_M_by_c() and
30 % 'Mstrich' is set to 1 .
31 % -# 'Mstrich_max_coupled' -- plot of error estimates over 'c', where 'c'
32 % couples 'N' and 'M' by couple_N_and_M_by_c() and
33 % 'Mstrich' is set to maximum value in
35 % -# 'Mstrich_1' -- landscape plot over 'N' and 'M' and 'Mstrich' is
37 % -# 'Mstrich_max' -- landscape plot over 'N' and 'M' and 'Mstrich' is
38 % set to maximum value in array 'Mstrich_samples'.
39 % -# 'Mmax_train' -- landscape plot over 'N' and 'Mstrich' with 'M' set to
40 % maximum possible value for test parameter set used
41 % in reduced basis generation.
42 % -# 'coupled' -- landscape plot over 'c' and 'Mstrich' where 'c' couples
43 % 'N' and 'M' by couple_N_and_M_by_c().
44 % -# 'Mmax' -- landscape plot over 'N' and 'Mstrich' with 'M' set to
45 % maximum possible value.
46 % -# 'Nmax' -- landscape plot over 'M' and 'Mstrich' with 'N' set to
47 % maximum reduced basis size.
50 % By default all estimator landscapes are selected.
52 if ~exist('estimator_plots','var')
56 Nmax = get_rb_size(detailed_data);
57 Mmax = get_ei_size(detailed_data);
59 info = find_active_info(detailed_data);
61 disp(
'warning: takes a few hours!');
63 if basis_gen.verbose < 20 && ~basis_gen.debug
64 warning(
'off',
'MATLAB:nearlySingularMatrix');
67 % reduced basis sizes to be tested (depends on Nsize)
68 Nsamples = 1+round((0:Nsize-1) .* (Nmax-1) ./ (Nsize-1));
69 % collateral reduced basis sizes to be tested (depends on Msize)
70 Msamples = 1+round((0:Msize-1) .* (Mmax-1-max(Mstrich_samples)) ./ (Msize-1));
72 % produce reduced data
73 reduced_data = gen_reduced_data(basis_gen,detailed_data);
76 sconf =
struct(
'pf',[],
'samples',[],
'pf_descr',[],
'Mstrich',[],...
77 'M',[],
'N',[],
'run_name_infix',[],
'mu_set',[],...
79 if isempty(estimator_plots) || ismember(
'Mstrich_1_coupled', estimator_plots)
80 % plot of error estimates over
'c', where
'c' couples
'N' and
'M' by `(N,M) =
81 % c (Nmax, Mmax)` and
'Mstrich' is
set to 1
84 sconf(i).samples = {csample};
85 sconf(i).pf_descr = {cdescr};
87 sconf(i).run_name_infix =
'coupled_Mstrich_1_';
90 if isempty(estimator_plots) || ismember(
'Mstrich_max_coupled', estimator_plots)
91 % plot of error estimates over
'c', where
'c' couples
'N' and
'M' by `(N,M) =
92 % c (Nmax, Mmax)` and
'Mstrich' is
set to its maximum value
95 sconf(i).samples = {csample};
96 sconf(i).pf_descr = {cdescr};
97 sconf(i).Mstrich = max(Mstrich_samples);
98 sconf(i).run_name_infix =
'coupled_Mstrich_Mmax_';
101 if isempty(estimator_plots) || ismember(
'Mmax_train', estimator_plots)
104 sconf(i).pf = {
'N' };
105 sconf(i).samples = { Nsamples };
106 sconf(i).mu_set = info.M_train.sample;
107 sconf(i).pf_descr = {
'N' };
108 sconf(i).Mstrich = max(Mstrich_samples);
109 sconf(i).M = get_ei_size(detailed_data)-sconf(i).Mstrich;
110 sconf(i).run_name_infix =
'N_Mstrich_Mmax_train_set';
113 if isempty(estimator_plots) || ismember(
'Mstrich_1', estimator_plots)
114 % plot of error estimates over
'N' and
'M', where and
'Mstrich' is
set to
117 sconf(i).pf = {
'N',
'M' };
118 sconf(i).max = [ Nmax, Mmax-1 ];
119 sconf(i).sample_size = [ Nsize, Msize ];
120 sconf(i).Mstrich = 1;
121 sconf(i).run_name_infix =
'Mstrich_1_';
124 if isempty(estimator_plots) || ismember(
'Mstrich_max', estimator_plots)
125 % plot of error estimates over
'N' and
'M', where and
'Mstrich' is
set to
128 sconf(i).pf = {
'N',
'M' };
129 sconf(i).max = [ Nmax, Mmax - max(Mstrich_samples) ];
130 sconf(i).sample_size = [ Nsize, Msize ];
131 sconf(i).Mstrich = max(Mstrich_samples);
132 sconf(i).run_name_infix =
'Mstrich_max_';
135 if isempty(estimator_plots) || ismember(
'coupled', estimator_plots)
136 % plot of error estimates over
'c' and
'Mstrich', where
'c' couples
'N' and
137 %
'M' by `(N,M) = c (Nmax, Mmax)`.
140 sconf(i).samples = { Mstrich_samples, csample };
141 sconf(i).pf_descr = {
'M''', cdescr };
142 sconf(i).run_name_infix =
'coupled_Mstrich_';
145 if isempty(estimator_plots) || ismember(
'Mmax', estimator_plots)
146 % plot of error estimates over
'N' and
'Mstrich'
148 sconf(i).pf = {
'N',
'Mstrich' };
149 sconf(i).samples = { Nsamples, Mstrich_samples };
150 sconf(i).pf_descr = {
'N',
'M''' };
151 sconf(i).run_name_infix =
'N_Mstrich_';
152 sconf(i).M = get_ei_size(detailed_data)-max(Mstrich_samples);
155 if isempty(estimator_plots) || ismember(
'Nmax', estimator_plots)
156 % plot of error estimates over
'M' and
'Mstrich'
158 sconf(i).pf = {
'M',
'Mstrich' };
159 sconf(i).samples = { Msamples, Mstrich_samples };
160 sconf(i).pf_descr = {
'M',
'M''' };
161 sconf(i).run_name_infix =
'M_Mstrich_';
162 sconf(i).N = get_rb_size(detailed_data);
165 if exist(
'M_by_N_ratio',
'var')
166 params.M_by_N_ratio = M_by_N_ratio;
169 output = cell(1,length(sconf));
170 % produce plots specified by the configuration structure 'sconf'
171 for i = 1:length(sconf)
173 range_params.plot_fields = sconf(i).pf;
174 if isempty(sconf(i).max)
175 range_params.samples = sconf(i).samples;
177 range_params.max = sconf(i).max;
178 range_params.sample_size = sconf(i).sample_size;
180 if ~isempty(sconf(i).pf_descr)
181 range_params.plot_field_descr = sconf(i).pf_descr;
183 if ~isempty(sconf(i).Mstrich)
184 basis_gen.Mstrich = sconf(i).Mstrich;
186 if ~isempty(sconf(i).M)
187 basis_gen.M = sconf(i).M;
189 if ~isempty(sconf(i).N)
190 basis_gen.N = sconf(i).N;
192 if ~isempty(sconf(i).mu_set)
193 range_params.mu_set = sconf(i).mu_set;
194 testdir = [ basis_gen.model.name, '_' , sconf(i).run_name_infix, ...
197 range_params.mu_set_size = mu_set_size;
198 testdir = [ basis_gen.model.name, '_', sconf(i).run_name_infix, '_', ...
199 num2str(range_params.mu_set_size) ];
201 params.run_name = [ testdir, '_step8'];
202 params.mode = 'estimator';
203 % params.mode = 'check';
205 output{i}=stochastic_error_estimation(basis_gen, detailed_data, ...
207 range_params, params);
209 save([params.step8_outputfile,
'_tmp'],
'output');
211 save(params.step8_outputfile,
'output');