1 classdef DetailedData < Greedy.User.IDetailedData
2 %
class generating the reduced basis space for the LinEvol problem with a
5 % Parameters given by the constructor argument
'bg_descr' of type
7 % - trainings sample (#train_sample_mode, #train_num_intervals, #train_seed)
8 % - trainings sample refinement (#refinement_mode, #max_refinement_level,
9 % #refinement_theta, #val_size, #val_seed, #stop_max_val_train_ratio)
10 % - the error indicator (#indicator_mode)
11 % - greedy variant selection by #Mmax_small
12 % - PODEI-greedy ('Mmax_small > 0'): #small_train_num_intervals,
14 % #maximum_temporary_error_growth_factor,
15 % #ei_minimum_residual,
16 % #extension_M_by_N_r,
18 % - subsequent generation of EI by EI-greedy and RB by POD-greedy. ('Mmax_small == 0')
20 % - general EI extension controls (#noof_ei_extensions) and
21 % - general greedy controls (#stop_Nmax, #stop_Mmax, #stop_timeout,
22 % #stop_epsilon, #stop_max_val_train_ratio)
24 properties (Dependent, SetAccess=private)
25 % a basis generation algorithm of type Greedy.Interface used to generated
26 % the reduced basis space.
30 properties (Access=
private)
37 % flag indicating whether the parameter sampling
for the training
set
38 % `M_{\text{train}}` type.
41 % - 'uniform': (default) for a ParameterSampling.Uniform
42 % - 'random': for a ParameterSampling.Random
43 train_sample_mode = 'uniform';
45 % number of intervals in the ParameterSampling.Uniform respectively number
46 % of vectors in the ParameterSampling.Random
for the training
set
47 % `M_{\text{train}}` of the parameter space `{\cal M}`.
48 train_num_intervals = 3;
50 % If
'train_sample_mode == random', a ParameterSampling.Random is generated
51 %
for the training
set `M_{\text{val}}` with size #train_num_intervals and
57 % Possible values are:
58 % - 'uniform': the parameter sampling is refined uniformly
59 % - 'adaptive': the parameter sampling is refined adaptively, such that
60 % only regions of the parameter space with high estimated
62 % - 'none': no Greedy.TrainingSetAdaptation object is created
63 refinement_mode = 'adaptive';
68 max_refinement_level = 5;
73 refinement_theta = 0.2;
75 % If
this value is non-zero, a ParameterSampling.Random is generated for the
76 % validation set `M_{\text{val}}` with size #val_size and seed #val_seed.
79 % If the value of
'val_size' is non-zero, a ParameterSampling.Random is
80 % generated for the validation set `M_{\text{val}}` with size #val_size
81 % and seed
'val_seed'.
84 % number of intervals in the ParameterSampling.Uniform
for the @em small
85 % training
set `M_{\text{small}}`
for the generation of an initial
86 % collateral reduced basis space.
88 % See #Mmax_small
for details.
89 small_train_num_intervals = 2;
93 % In order to use the estimator of a nonlinear evolution equation
for a
94 % basis extension with a greedy search in the parameter space, a collateral
95 % reduced basis space
for all existing operators needs to be present. For
96 %
this reason at the beginning of the basis generation algorithm, a
97 % collateral reduced bases of size at most #Mmax_small is generated
100 % #small_train_num_intervals as extension algorithm
for a
102 % limit is
set to #ei_epsilon_small.
104 % If #Mmax_small is equal to
'0', the initial collateral reduced bases are
105 % generated with stopping parameters #stop_Mmax and #stop_epsilon
'*'
106 % #epsilon_M_by_N_r, and the PODGreedyAlgorithm afterwards only extends the
107 % reduced basis space.
110 % ratio between the stop epsilon criterion
for collateral reduced basis
111 % spaces and reduced basis spaces.
113 % This option is only used in
case 'Mmax_small == 0'. See #Mmax_small
for
116 % Its purpose is to make the collateral reduced basis space more refined
117 % than the reduced basis space. This is necessary as the best possible
118 % error
for the basis generation of the reduced basis space @em depends on
119 % the quality of the collateral reduced basis space.
120 epsilon_M_by_N_r = 1e-4;
122 % maximum factor between the current maximum indicator and the smallest
123 % maximum error indicator during previous extensions
126 maximum_temporary_error_growth_factor = 0;
128 % sets the Greedy.Plugin.EI.minimum_residual
130 % This option is only used in case 'Mmax_small > 0'. See
#Mmax_small for
132 ei_minimum_residual = 1e-8;
136 % This option is only used in
case 'Mmax_small > 0'. See #Mmax_small
for
138 extension_M_by_N_r = 4;
140 % maximum error between
operator interpolations at which the initial value
143 % See #Mmax_small
for details.
144 ei_epsilon_small = 1e-2;
149 % sets the Greedy.Plugin.PODEI.stop_Nmax option
153 indicator_mode =
'estimator';
159 stop_max_val_train_ratio = 1.2;
162 stop_timeout = 12*60*60;
164 % sets the number of ei extensions
167 noof_ei_extensions = 1;
173 % constructor constructing the reduced basis spaces and storing it in a
177 % rmodel: of type LinEvol.ReducedModel
179 dd = dd@Greedy.User.
IDetailedData(rmodel.bg_descr, model_data);
181 dd.rb_generator = SnapshotsGenerator.Trajectories(rmodel.detailed_model);
183 dmodel = rmodel.detailed_model;
185 opstrings = cellfun(@func2str, dmodel.descr.ei_space_operators,
'UniformOutput',
false);
186 opcandidates(1).id =
'implicit';
187 opcandidates(1).op = dmodel.descr.L_I_local_ptr;
188 opcandidates(2).id =
'explicit';
189 opcandidates(2).op = dmodel.descr.L_E_local_ptr;
191 for i = 1:length(opcandidates)
193 if ~isempty(intersect(opstrings, func2str(opcandidates(i).op)))
194 ei_generator = SnapshotsGenerator.SpaceOpEvals(dmodel, opcandidates(i).
id, dd.rb_generator, opcandidates(i).op);
195 dd.ei_generators = [ dd.ei_generators, ei_generator ];
199 dd.datatree = gen_detailed_data(dd.bg_algorithm, rmodel, model_data);
206 function basis_gen = get.bg_algorithm(this)
207 % generates a default @ref Greedy.Interface "basis generation
object" for
210 % This function generates a Greedy.Interface implementation, with either
211 % a subsequent generation of empirical interpolation bases spaces for all
212 % operators and a reduced basis space afterwards, @b or a combined
213 % generation of all reduced spaces with the Greedy.Plugin.PODEI variant
214 % of the Greedy.Algorithm.
217 if isequal(this.train_sample_mode, 'uniform')
218 M_train = ParameterSampling.Uniform(this.train_num_intervals);
219 elseif isequal(this.train_sample_mode, 'random')
220 M_train = ParameterSampling.Random(this.train_num_intervals, this.train_seed);
222 error('unknown train_sample_mode');
225 M_val = ParameterSampling.Random(this.val_size, this.val_seed);
230 rb_ext = Greedy.Plugin.POD(this.rb_generator);
231 rb_ext.indicator_mode = this.indicator_mode;
232 rb_ext.stop_Nmax = this.stop_Nmax;
234 ei_ext_array = cell(1, length(this.ei_generators));
235 for i = 1:length(this.ei_generators)
236 ei_ext_array{i} = Greedy.Plugin.EI(this.ei_generators(i));
238 if length(ei_ext_array) > 1
239 ei_ext = [ ei_ext_array{:} ];
241 ei_ext = ei_ext_array{1};
244 ei_ext.stop_Mmax = this.stop_Mmax;
246 ei_ext.noof_extensions = this.noof_ei_extensions;
250 if this.Mmax_small > 0
252 ei_ext.minimum_residual = this.ei_minimum_residual;
254 M_train_small = ParameterSampling.Uniform(this.small_train_num_intervals);
255 ei_greedy_small = Greedy.Algorithm(ei_ext, M_train_small);
256 ei_greedy_small.stop_epsilon = this.ei_epsilon_small;
258 all_ext = Greedy.Plugin.PODEI(rb_ext, ei_ext, ei_greedy_small, this.Mmax_small);
259 all_ext.M_by_N_ratio = this.extension_M_by_N_r;
260 all_ext.maximum_temporary_error_growth_factor = this.maximum_temporary_error_growth_factor;
262 if this.extension_M_by_N_r > 0
263 all_ext.skip_rb_after_bad_extension =
false;
264 all_ext.discard_last_rb_after_bad_extension =
false;
265 all_ext.skip_ei_after_bad_extension =
false;
268 pod_greedy = Greedy.Algorithm(all_ext, M_train, M_val);
270 pod_greedy.val_train_ratio_seq_for_break = 2;
272 ei_greedy = Greedy.Algorithm(ei_ext, M_train);
273 ei_greedy.stop_epsilon = this.stop_epsilon * this.epsilon_M_by_N_r;
275 pod_greedy = Greedy.Algorithm(rb_ext, M_train, M_val);
277 pod_greedy.val_train_ratio_seq_for_break = 1;
280 pod_greedy.stop_epsilon = this.stop_epsilon;
281 pod_greedy.stop_max_val_train_ratio = this.stop_max_val_train_ratio;
282 pod_greedy.stop_timeout = this.stop_timeout;
284 if isa(M_train,
'ParameterSampling.IRefineable')
286 if ~isequal(this.refinement_mode, 'none')
287 pod_greedy = Greedy.TrainingSetAdaptation(pod_greedy);
288 pod_greedy.refinement_mode = this.refinement_mode;
289 pod_greedy.max_refinement_level = this.max_refinement_level;
292 if isequal(this.refinement_mode, 'adaptive')
293 pod_greedy.refinement_theta = this.refinement_theta;
298 if this.Mmax_small > 0
299 basis_gen = pod_greedy;
301 basis_gen = [ei_greedy, pod_greedy];
306 function rb_size = get_rb_size(this, rmodel)
307 leaf_dd = get_leaf(this, rmodel);
308 rb_size = get_rb_size(leaf_dd);