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.
43 train_sample_mode =
'uniform';
47 % `M_{\text{train}}` of the parameter space `{\cal M}`.
48 train_num_intervals = 3;
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
63 refinement_mode =
'adaptive';
68 max_refinement_level = 5;
73 refinement_theta = 0.2;
76 % validation set `M_{\text{val}}` with size #val_size and seed #val_seed.
80 % generated
for the validation set `M_{\text{val}}` with size #val_size
81 % and seed
'val_seed'.
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
GreedyPlugin.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
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
GreedyPlugin.PODEI variant
217 if isequal(this.train_sample_mode, 'uniform')
219 elseif isequal(this.train_sample_mode, 'random')
222 error('unknown train_sample_mode');
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)
238 if length(ei_ext_array) > 1
239 ei_ext = [ ei_ext_array{:} ];
241 ei_ext = ei_ext_array{1};
246 ei_ext.noof_extensions = this.noof_ei_extensions;
250 if this.Mmax_small > 0
252 ei_ext.minimum_residual = this.ei_minimum_residual;
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;
273 ei_greedy.
stop_epsilon = this.stop_epsilon * this.epsilon_M_by_N_r;
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);
IDetailedModel implementation for a non linear evolution problem.
reduced model for linear evolution problems as given by a LinEvol.DetailedModel.
function isbad = indicate_bad_basis_extension(IDetailedData detailed_data)
indicates whether the last basis extension was bad
refinement_mode
string specifying the method type for the adaptation of the parameter sampling. uniform or adaptive ...
val_train_ratio_seq_for_break
number of subsequent cases where the max_err_val_train_ratio is too high that is needed in order to b...
indicator_mode
string specifying which indicators shall be used by the error_indicators() method.
Mmax_small
number of collateral reduced of the initial collateral reduced basis.
Greedy.Plugin.Interface implementation that extends in each basis extension step, the reduced basis space and/or the collateral reduced basis space(s).
M_by_N_ratio
forced ratio between the sizes of the colletaral and the regular reduced basis space ...
max_refinement_level
maximum number of refinement levels in the refineable trainings parameter set
class generating the reduced basis space for the LinEvol problem with a Greedy algorithm.
Implementation of a SnapshotsGenerator.Cached for reduced basis generation. The generate() method ret...
default greedy basis generation class
stop_max_val_train_ratio
positive double value specifying the maximum ratio between the maximum error indicator over the valid...
refinement_theta
ratio of elements which are refined during an adaptive refinement step
Reduced basis implementation for linear evolution equations.
Struct with control fields for the reduced basis generation.
stop_epsilon
double specifying the maximum error indicator for which the basis generation shall be stopped...
stop_timeout
integer specifying the number of seconds after which the basis generation shall be stopped...
Specialization plugins for the greedy algorithm.
an interface specialization for detailed data objects used with the Greedy algorithm.
Interface classes to be implemented by the Greedy.Algorithm user.
Cacheable generators of detailed data snapshots.
Plugin for the Greedy.Algorithm class generating a collateral reduced basis space plus interpolation ...
Parameter sampling class producing randomly distributed parameter samples in sparameter space ...
greedy basis generation extension which adaptively refines the trainings parameter set...
stop_Mmax
maximum number of generated collateral reduced basis vectors.
Customizable implementation of an abstract greedy algorithm.