4 % method which produces reduced_data, which is the data, that will be passed to
5 % an online-algorithm. Therefore, no quantities dependent on the high-dimension
6 % H may be included here. Neither may online-data include parameter-dependent
7 % mu-quantities. So no complete grid or detailed solutions or reduced basis
8 % vectors may be stored here. So online data is produced in the offline stage,
9 % but may be used in online-stages. So the computation time may depend on H,
10 % but the results may not depend on
this complexity.
12 % allowed dependency of generated data: Nmax
13 % not allowed dependency of data: H
14 % allowed dependency of computation: Nmax, H
15 % Unknown at
this stage: mu, N
17 % Bernard Haasdonk 16.5.2007
19 % extended to primal/dual formulaton by Dominik Garmatter:
21 % the following cases are possible:
22 % - model.want_improved_output = 0 and model.want_dual = 1 or 0:
24 % detailed_data including the primal or dual detailed data. Simply produced
25 % reduced_data for a primal or a dual problem. In the dual case a
26 % functional has to be specified via model.name_output_functional.
28 %- model.want_improved_output = 1 and model.want_dual = 0:
30 % detailed_data including both the primal and dual detailed_data!
35 % In all the cases it is possible to enable the SCM via model.use_scm = 1 to
36 % compute scm_offline_data for a lower bound to the infsup or a coercivity
37 % constant in the rb_simulation. Only makes sense in the above second case
38 % or if you set model.error_norm = 'energy' for the future rb_simulation.
39 % See
scm_offline for a description on the required scm quantities.
41 % special Note: in the european_option_pricing model a functional named
42 % 'theta' includes a partial timederivative and therefore produces a
43 % slightly different dual problem. Therefore the 'theta'-case is sometimes
44 % treated differently. Don't care about this case if you don't use the
45 % european_option_pricing model.
47 % Dominik Garmatter 20.07 2012
49 if ~isfield(model, 'want_dual')
52 if ~isfield(model, 'want_improved_output')
53 model.want_improved_output = 0;
55 if ~isfield(model, 'use_scm')
59 model.decomp_mode = 1; % always components
61 if model.want_dual % dual
62 if strcmp(model.name_output_functional, 'theta') == 1 % theta
63 if model.use_scm % with scm
64 [reduced_data.LL_I, reduced_data.LL_E, reduced_data.bb, ...
65 reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
66 reduced_data.m_I, reduced_data.m_E, reduced_data.m, reduced_data.K_IdId, reduced_data.K_IdE, ~, ~, ~, reduced_data.scm_offline_data] = rb_operators(model, detailed_data);
68 [reduced_data.LL_I, reduced_data.LL_E, reduced_data.bb, ...
69 reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
70 reduced_data.m_I, reduced_data.m_E, reduced_data.m, reduced_data.K_IdId, reduced_data.K_IdE, ~, ~, ~] = rb_operators(model, detailed_data);
72 else % dual without theta
73 if model.use_scm % with scm
74 [reduced_data.LL_I, reduced_data.LL_E, ~, ...
75 reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
76 ~, ~, ~, reduced_data.K_IdId, reduced_data.K_IdE, ~, ~, ~, reduced_data.scm_offline_data] = rb_operators(model, detailed_data);
78 [reduced_data.LL_I, reduced_data.LL_E, ~, ...
79 reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
80 ~, ~, ~, reduced_data.K_IdId, reduced_data.K_IdE, ~, ~, ~] = rb_operators(model, detailed_data);
83 elseif model.want_improved_output && model.want_dual == 0 % primal with improved output
84 if model.use_scm % with scm
85 [reduced_data.LL_I, reduced_data.LL_E, reduced_data.bb, reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
86 reduced_data.m_I, reduced_data.m_E, reduced_data.m, ~, ~, reduced_data.LL_I_correct, reduced_data.LL_E_correct, ...
87 reduced_data.bb_correct, reduced_data.scm_offline_data] = rb_operators(model, detailed_data);
89 [reduced_data.LL_I, reduced_data.LL_E, reduced_data.bb, ...
90 reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
91 reduced_data.m_I, reduced_data.m_E, reduced_data.m, ~, ~, ...
92 reduced_data.LL_I_correct, reduced_data.LL_E_correct, reduced_data.bb_correct] = rb_operators(model, detailed_data);
94 else % primal without improved output
95 if model.use_scm % with scm
96 [reduced_data.LL_I, reduced_data.LL_E, reduced_data.bb, reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
97 reduced_data.m_I, reduced_data.m_E, reduced_data.m, ~, ~, ~, ~, ~, reduced_data.scm_offline_data] = rb_operators(model, detailed_data);
99 [reduced_data.LL_I, reduced_data.LL_E, reduced_data.bb, ...
100 reduced_data.K_II, reduced_data.K_IE, reduced_data.K_EE, ...
101 reduced_data.m_I, reduced_data.m_E, reduced_data.m, ~, ~, ~, ~, ~] = rb_operators(model, detailed_data);
104 % Note by Dominik Garmatter 20.09 2012 regarding a problem with this
106 % It makes sense to compute the scm_offline_data in gen_reduced_data, but
107 % when generating a reduced basis there might be a call of gen_reduced_data
108 % in every step of the basis generation. This will result in multiple
109 % generations of scm_offline_data but scm_offline_data is not dependant on
110 % the reduced basis and therefore it would be sufficient to compute it only
111 % once. But there is no real solution to this problem yet, because one
112 % might need the SCM while basis generation (i.e. to compute the error
113 % indicators). Otherwise one could disable the SCM while basis generation
114 % (model.use_scm = 0) and enable it after basis generation.
116 reduced_data.N = model.get_rb_size(model, detailed_data);
117 reduced_data.a0 = rb_init_values(model, detailed_data);
119 % only in the primal case an output makes sense
120 if isfield(model,'name_output_functional') && model.want_dual == 0
121 % initialise s_RB = v'*\Phi, with \Phi being the reduced basis
122 % later in the rb_simulation it will be s_N = s_RB * a, with a being the rb_coefficients.
123 s_RB = zeros(1,size(detailed_data.RB,2));
124 % get v the riesz-representant and l the continuousity constant of the respective functional
125 if model.want_improved_output % no l is required here
126 [v,~] = model.operators_output(model,detailed_data);
128 [v, l] = model.operators_output(model,detailed_data);
129 reduced_data.s_l2norm = l;
131 for n = 1 : size(detailed_data.RB,2)
132 s_RB(1,n) = (v(:)')*detailed_data.RB(:,n);
134 reduced_data.s_RB = s_RB;
function reduced_data = lin_evol_gen_reduced_data_primal_dual(model, detailed_data)
reduced_data = lin_evol_gen_reduced_data_primal_dual(model, detailed_data)
function reduced_data = lin_evol_primal_dual_gen_reduced_data(model, detailed_data)
reduced_data = lin_evol_primal_dual_gen_reduced_data(model, detailed_data)
function simulation_data = lin_evol_primal_dual_rb_simulation(model, reduced_data)
simulation_data = lin_evol_primal_dual_rb_simulation(model, reduced_data)
function scm_offline_data = scm_offline(model, detailed_data, M_train, D_train)
scm_offline_data = scm_offline(model, detailed_data, M_train, D_train)
function detailed_data = lin_evol_primal_dual_gen_detailed_data(model, model_data)
detailed_data = lin_evol_primal_dual_gen_detailed_data(model, model_data)