rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
Interface.m
1 classdef Interface < handle
2  % %Interface class for extension algorithms which define the basis extension
3  % routines used by the abstract Greedy algorithm class Greedy.Algorithm
4  %
5  % Here, we usually assume, that we have
6  % - @em detailed algorithms producing high dimensional solutions
7  % `v_h(t^k;\mu) \in {\cal W}_h` and
8  % - @em reduced algorithms producing corresponding low dimensional
9  % solutions `v_{\text{red}}(t^k;\mu) \in {\cal W}_{\text{red}} \subset {\cal W}_h`.
10  %
11  % By enriching the subspace `{\cal W}_{\text{red}}`, we can improve the
12  % reduced algorithms.
13  %
14  % Most prominent examples of Interface implementations are the classes
16 
17  properties(SetAccess = private, Dependent)
18  % a string identifying the basis extension algorithm, should be unique over
19  % all instances of Interface implementations.
20  id;
21  end
22 
23  properties(Abstract)
24  % boolean flag specifying whether we want to use the relative error for
25  % error_indicators() and compute_error() methods.
26  relative_error;
27 
28  % string specifying which indicators shall be used by the
29  % error_indicators() method.
30  %
31  % Possible values are:
32  % 'error' for an error between the detailed and the reduced computation.
33  % 'estimator' for an a posteriori error estimator
34  indicator_mode;
35  end
36 
37  properties(Abstract, Dependent)
38 
39  % boolean indicating whether the prepare_reduced_data() method needs to be
40  % computed before error_indicators can be computed.
41  needs_preparation;
42  end
43 
44  properties(Abstract, Constant)
45  % @copybrief GreedyInterfacegenerated_basis_type
46  %
47  % @copydetails GreedyInterfacegenerated_basis_type
48  generated_basis_type;
49  end
50 
51  properties
52 
53  % an object of type SnapshotsGenerator.Cached generating possible (high dimension)
54  % basis functions
55  generator;
56  end
57 
58  methods
59  function gei = Interface(generator)
60  % function gei = Interface(generator)
61  % constructor for a greedy extension object
62  %
63  % Parameters:
64  % generator: object of type SnapshotsGenerator.Cached generating the (high
65  % dimensional) basis functions
66 
67  gei.generator = generator;
68  end
69 
70  function id = get.id(this)
71  id = this.generator.id;
72  end
73 
74  end
75 
76  methods(Abstract)
77  % function detailed_data = init_basis(this, rmodel, model_data, M_train);
78  % creates an initial detailed data node storing an initial reduced basis
79  %
80  % Parameters:
81  % rmodel: an object of type ::GreedyUser::IReducedModel specifying the
82  % basis generation process.
83  % M_train: an object of type ParameterSampling.Interface specifying the parameter
84  % vector set `{\cal M}_{\text{train}}` from which the basis
85  % functions are obtained.
86  %
87  % Return values:
88  % detailed_data: an object of type Greedy.DataTree.Detailed.INode storing the initial
89  % reduced basis vectors.
90  detailed_data = init_basis(this, rmodel, model_data, M_train);
91 
92  % function prepare_reduced_data(this, rmodel, detailed_data);
93  % prepares reduced data that is necessary for the execution of other
94  % methods if indicated by needs_preparation.
95  %
96  % Methods that might depend on the execution of this method are:
97  % - compute_error()
98  % - generate_reduced()
100  %
101  % Parameters:
102  % rmodel: an object of type .Greedy.User.IReducedModel specifying the
103  % basis generation process.
104  % detailed_data: of type .Greedy.User.IDetailedData
105  prepare_reduced_data(this, rmodel, detailed_data);
106 
107  % function [max_errs, max_err_sequence, max_mu_index] = error_indicators(this, rmodel, detailed_data, parameter_set, reuse_reduced_data);
108  % computes error indicators for the reduced simulations for every parameter
109  % vector from a given parameter set `{\cal M}_{\text{train}}`.
110  %
111  % An error indicator estimates an error
112  % ``\eta^k(\mu) \geq \| v_h(t^k;\mu) - v_{\text{red}}(t^k;\mu) \|``
113  % for every time step `0\leq t^0, \ldots, t^K = T` and every parameter `\mu
114  % \in {\cal M}`. The norm is a problem specific norm determined by the
115  % options in 'rmodel'.
116  %
117  % This function's main use is to find a parameter vector
118  % ``\mu_{\max} = \arg \sup_{\mu \in {\cal M}_{\text{train}} } \max_{k=0,\ldots,K} \eta^k(\mu)``.
119  %
120  % Parameters:
121  % rmodel: an object of type .Greedy.User.IReducedModel specifying the
122  % basis generation process.
123  % detailed_data: of type .Greedy.User.IDetailedData
124  % parameter_set: a set of parameter vectors `{\cal M}_{\text{train}}` as
125  % returned by ParameterSampling.Interface.space .
126  % reuse_reduced_data: optional flag indicating whether the reduced data needed for
127  % reduced simulations or computation of error estimators is
128  % still valid since its last generation. (default = 'false')
129  %
130  % Return values:
131  % max_errs: a matrix of size 'n_parameters x model.nt+1' storing the
132  % error indicator `\eta^k(\mu)` for every `k=0,\ldots,K` and
133  % `\mu \in {\cal M}_{\text{train}}`.
134  % max_err_sequence: a sequence of error indicators `\eta^k(\mu_{\max})`
135  % for every `k=0,\ldots,K`.
136  % max_mu_index: the index of the parameter vector `\mu_{\max}` in the
137  % 'parameter_set' matrix.
138  %
139  [max_errs, max_err_sequence, max_mu_index] = error_indicators(this, rmodel, detailed_data, parameter_set, reuse_reduced_data);
140 
141  % function errs = compute_error(this, rmodel, detailed_data);
142  % computes the "true" error between a reduced and a detailed function `\|
143  % v_h(t^k;\mu) - v_{\text{red}}(t^k;\mu) \|`.
144  %
145  % @note This function might depend on a previous execution of prepare_reduced_data().
146  %
147  % Parameters:
148  % rmodel: an object of type .Greedy.User.IReducedModel specifying the
149  % basis generation process. The parameter `\mu` for which the
150  % error shall be computed must be set by 'set_mu(rmodel, mu)'
151  % before.
152  % reduced_data: of type .Greedy.User.ReducedData
153  % detailed_data: of type .Greedy.User.IDetailedData
154  %
155  % Return values:
156  % errs: a sequence of errors at every time step `k=0,\ldots,K`.
157  errs = compute_error(this, rmodel, reduced_data, detailed_data);
158 
159  % function Uapprox = generate_reduced(this, rmodel, reduced_data, detailed_data, U);
160  % generates a reduced function `v_{\text{red}}(\mu)`.
161  %
162  % @note This function might depend on a previous execution of prepare_reduced_data().
163  %
164  % Parameters:
165  % rmodel: an object of type .Greedy.User.IReducedModel specifying the basis
166  % generation process. The parameter `\mu` for which the error
167  % shall be computed must be set by 'set_mu(rmodel, mu)' before.
168  % reduced_data: an object of type .Greedy.User.ReducedData storing all
169  % (low-dimensional) reduced matrices and vectors needed for
170  % reduced simulations.
171  % detailed_data: of type .Greedy.User.IDetailedData
172  % U: optional DOF vector, for example operator evaluations.
173  %
174  % Return values:
175  % Uapprox: A sequence of Dof vectors of the functions
176  % `v_{\text{red}}(\cdot;t^k,\mu)`.
177  Uapprox = generate_reduced(this, rmodel, reduced_data, detailed_data, U);
178 
179  % function [breakloop, reason] = pre_check_for_end(this, rmodel, detailed_data);
180  % checks whether the basis generation process has come to an end.
181  %
182  % Global break conditions (error_tolerance, timeout and validation ratio)
183  % are handled by Greedy.Algorithm .
184  %
185  % Parameters:
186  % rmodel: of type .Greedy.User.IReducedModel
187  % detailed_data: of type .Greedy.User.IDetailedData
188  %
189  % Return values:
190  % breakloop: boolean flag indicating whether the basis generation process
191  % is finished for this reduced basis space.
192  % reason: descriptive text telling about the reasons why, the
193  % extension process needs to break.
194  [breakloop, reason] = pre_check_for_end(this, rmodel, detailed_data);
195 
196 % breakloop = post_check_for_end(this, detailed_data);
197 
198  % function detailed_data = basis_extension(this, rmodel, detailed_data, max_err_seq, mu);
199  % extends the reduced basis space from a given function `v_{h}(\mu)`.
200  %
201  % This generates a new basis function `\varphi_{n+1} \in {\cal W}_h` from
202  % the sequence of detailed functions `v_h(t^k,\mu)` for `k=0,\ldots,K` as
203  % returned by the SnapshotsGenerator.Cached generator.
204  %
205  % Parameters:
206  % rmodel: an object of type .Greedy.User.IReducedModel specifying the
207  % basis generation process.
208  % detailed_data: of type .Greedy.User.IDetailedData
209  % max_err_seq: sequence of error indicators as returned as second return
210  % argument of error_indicators()
211  % mu: paramter vector `\mu`.
212  %
213  % Return values:
214  % detailed_data: updated data tree node of type Greedy.DataTree.Detailed.INode .
215  detailed_data = basis_extension(this, rmodel, detailed_data, max_err_seq, mu);
216 
217  % function detailed_data = finalize(this, rmodel, detailed_data);
218  % function called after the last extension process
219  %
220  % Parameters:
221  % rmodel: an object of type .Greedy.User.IReducedModel specifying the
222  % basis generation process.
223  % detailed_data: of type .Greedy.User.IDetailedData
224  %
225  % Return values:
226  % detailed_data: updated data tree node of type Greedy.DataTree.Detailed.INode .
227  detailed_data = finalize(this, rmodel, detailed_data);
228 
229  end
230 end
Interface class for extension algorithms which define the basis extension routines used by the abstra...
Definition: Interface.m:19
Parameter sampling sets.
Definition: Interface.m:1
extension class implementing the POD-greedy algorithm extension routines
Definition: POD.m:19
Specialization plugins for the greedy algorithm.
Definition: Default.m:2
Cacheable generators of detailed data snapshots.
Definition: Cached.m:1
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
Plugin for the Greedy.Algorithm class generating a collateral reduced basis space plus interpolation ...
Definition: EI.m:19
virtual function [ max_errs , max_err_sequence , max_mu_index ] = error_estimators(Greedy.User.IReducedModel rmodel,Greedy.User.IDetailedData detailed_data, M_train)
computes a posteriori error estimators for the reduced simulations for every parameter vector from a ...
Default implementation of a Greedy.Plugin.Interface interface class.
Definition: Default.m:19
Interface class for general data tree nodes storing detailed data returned by Greedy.Interface.gen_detailed_data()
Definition: INode.m:20
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1