rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_evol_gen_reduced_data_primal_dual.m
Go to the documentation of this file.
1 function reduced_data = lin_evol_gen_reduced_data_primal_dual(model, detailed_data)
2 %reduced_data = lin_evol_gen_reduced_data_primal_dual(model, detailed_data)
3 %
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.
11 %
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
16 %
17 % Bernard Haasdonk 16.5.2007
18 %
19 % extended to primal/dual formulaton by Dominik Garmatter:
20 %
21 % the following cases are possible:
22 % - model.want_improved_output = 0 and model.want_dual = 1 or 0:
23 % => lin_evol_gen_reduced_data_primal_dual(model, detailed_data) with
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.
27 %
28 %- model.want_improved_output = 1 and model.want_dual = 0:
29 % => lin_evol_gen_reduced_data_primal_dual(model, detailed_data) with
30 % detailed_data including both the primal and dual detailed_data!
34 %
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.
40 %
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.
46 
47 % Dominik Garmatter 20.07 2012
48 
49 if ~isfield(model, 'want_dual')
50  model.want_dual = 0;
51 end
52 if ~isfield(model, 'want_improved_output')
53  model.want_improved_output = 0;
54 end
55 if ~isfield(model, 'use_scm')
56  model.use_scm = 0;
57 end
58 
59 model.decomp_mode = 1; % always components
60 
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);
67  else % without scm
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);
71  end
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);
77  else % without scm
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);
81  end
82  end
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);
88  else % without scm
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);
93  end
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);
98  else % without scm
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);
102  end
103 end
104 % Note by Dominik Garmatter 20.09 2012 regarding a problem with this
105 % implementation:
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.
115 
116 reduced_data.N = model.get_rb_size(model, detailed_data);
117 reduced_data.a0 = rb_init_values(model, detailed_data);
118 
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);
127  else
128  [v, l] = model.operators_output(model,detailed_data);
129  reduced_data.s_l2norm = l;
130  end
131  for n = 1 : size(detailed_data.RB,2)
132  s_RB(1,n) = (v(:)')*detailed_data.RB(:,n);
133  end
134  reduced_data.s_RB = s_RB;
135 end
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)
Definition: scm_offline.m:17
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)