rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
rb_test_indicator.m
Go to the documentation of this file.
1 function test_err = rb_test_indicator(model,...
2  detailed_data,reduced_data,...
3  M_test,savepath)
4 %function test_err = rb_test_indicator(model,[detailed_data],[reduced_data]
5 % M_test,[savepath])
6 %
7 % function determining the test-error-indicators for the given set of
8 % vectors mu (columns in M_test) of the RB simulation with corresponding
9 % RB set. Either the true errors or the error-estimators are
10 % determined. If the true errors are wanted, these are produced
11 % into or read from the directory savepath. The offline_data is
12 % generated, if empty. The detailed data can be ommited if
13 % offline_data is available, and no true 'error' is wanted
14 %
15 % Required fields of model:
16 % RB_error_indicator: 'error' or 'estimator'
17 % error_algorithm : in case of 'error' mode, this algorithm
18 % is called for computing the error between a U and Uappr
19 
20 % Bernard Haasdonk 27.5.2007
21 
22 if isempty(reduced_data)
23  reduced_data = gen_reduced_data(model,detailed_data);
24 end;
25 
26 if ~isfield(model,'N')
27  if isfield(detailed_data,'N')
28  model.N=detailed_data.N;
29  else
30  model.N = size(model.get_rb_from_detailed_data(detailed_data),2);
31  end
32 end;
33 if isfield(model,'rb_problem_type')
34 if isequal(model.rb_problem_type,'nonlin_evol') ...
35  || isequal(model.rb_problem_type, 'richards')
36  if ~isfield(model,'M') || (model.M==-1)
37  model.M = max(cellfun(@(X)(size(X,2)), detailed_data.QM));
38  end;
39 end;
40 end;
41 
42 
43 reduced_data = model.reduced_data_subset(model, reduced_data);
44 
45 
46 switch model.RB_error_indicator
47  case 'error'
48  test_err = rb_test_error(model,...
49  detailed_data, reduced_data, M_test, ...
50  savepath);
51  case 'projection-error'
52  test_err = rb_test_projection_error(model,...
53  detailed_data, reduced_data, M_test, ...
54  savepath);
55 
56  case 'estimator'
57  test_err = rb_test_estimator(model,...
58  reduced_data,M_test);
59 
60  case 'estimator_parallel'
61  test_err = rb_test_estimator_parallel(model,...
62  reduced_data,M_test);
63 
64 
65  case 'ei_estimator_test'
66  tic;
67  test_err.estimator = rb_test_estimator(model, ...
68  reduced_data,M_test);
69  t1 = toc;
70  tic;
71  test_err.error = rb_test_error(model, ...
72  detailed_data, reduced_data, M_test, ...
73  savepath);
74  t2 = toc;
75  lambda = test_err.estimator ./ test_err.error;
76  disp(['Evaluation of the reliability lambda=Delta_est/Delta_err of a ',...
77  'posteriori estimator (min, max, mean):']);
78  disp(['min(lambda)=',num2str(min(lambda)), ...
79  ' max(lambda)=',num2str(max(lambda)), ...
80  ' mean(lambda)=', num2str(mean(lambda))]);
81  disp('Evaluation of the runtime gain of posteriori estimator');
82  disp(['t_post=',num2str(t1),' t_err=',num2str(t2)]);
83  if(any(test_err.estimator < test_err.error))
84  disp('Error: a posteriori estimator underestimates the real error');
85  keyboard;
86  end
87  otherwise
88  error('error indicator type unknown');
89 end;
90 
function test_err = rb_test_indicator(model, detailed_data, reduced_data, M_test, savepath)
M_test,[savepath])