1 function [max_test_errs, max_mu_index, ...
3 %
function [max_test_errs, max_mu_index,min_test_errs, min_mu_index] =
6 %
function determining the maximum and minimum test-error (linfty-l2 or
7 % estimator)
for the given set of vectors mu (columns in
8 % detailed_data.RB_info.M_test) of the RB simulation with corresponding
9 % RB set. A convergence test is
10 % performed by performing
this maximum and minimum
11 % detection
for all numbers of RB from 1 to the complete set.
12 % the output is max_test_errs(i): the maximum test-quantity on the given
13 % mu-subset for reduced basis RB(:,1:i). The number of the mu, which
14 % incurs this maximum error is returned in
15 % max_mu_index(i). Similarly for min_test_errs and min_mu_index.
17 % Required fields of model:
18 % RB_error_indicator:
'error' or
'estimator'
19 % RB_detailed_test_savepath : in case of
'error' this path
20 % either contains the test-samples or they are
22 % error_algorithm : algorithm computing the true error in
23 % case of
'error' mode
24 % test_N_samples : (optional) number of N samples, which are tested,
25 % i.e. value 11 for a basis of size N=21 will give 11
26 % test-results for the values N = 1,3,5,7,9,11,13,15,17,19,21
27 % an equidistant sampling of the N-interval is
28 % realized. If not specified, all numbers 1:N are tested
30 % Bernard Haasdonk 2.8.2006
32 nmus = size(detailed_data.RB_info.M_test,2);
34 nRBs = size(detailed_data.RB,2);
36 max_test_errs = NaN(nRBs,1);
37 max_mu_index = NaN(nRBs,1);
38 min_test_errs = NaN(nRBs,1);
39 min_mu_index = NaN(nRBs,1);
41 % compute offline data once
for complete RB set
43 offline_data = rb_offline_prep(detailed_data,model);
45 if isequal(model.RB_error_indicator,
'error')
46 savepath = model.RB_detailed_test_savepath;
49 error('savepath must be provided in case of error as target value!');
53 detailed_data.grid,...
57 if ~isfield(model,'test_N_samples') || ...
58 isempty(model.test_N_samples) % default: all numbers from N to 1
59 Nsamples = (nRBs:-1:1);
60 else % compute equidistributed sample-number
61 Nsamples = ceil((0:(model.test_N_samples-1))*...
62 (nRBs-1)/(model.test_N_samples-1)+ 0.5);
63 Nsamples = Nsamples(end:-1:1);
68 disp(['testing for nrb = ',num2str(nRB)]);
70 reduced_data = rb_online_prep(offline_data,model);
73 model = model.set_mu(detailed_data.RB_info.M_test(:,i),model);
74 simulation_data = rb_simulation(reduced_data,model);
76 if isequal(model.RB_error_indicator,'error')
81 Uappr = rb_reconstruction(detailed_data,simulation_data);
82 errs = feval(model.error_algorithm,U,Uappr,detailed_data.grid,model);
85 elseif isequal(model.RB_error_indicator, 'estimator')
86 err = simulation_data.Delta(end);
88 error('error indicator type unknown');
93 [max_test_errs(nRB), max_mu_index(nRB)] = max(test_err);
94 [min_test_errs(nRB), min_mu_index(nRB)] = min(test_err);
function [ sim_data , tictoc ] = load_detailed_simulation(m, savepath, params)
load single trajectory of previously saved results.
function save_detailed_simulations(model, model_data, M, savepath)
perform loop over detailed simulations and save results or check consistency with existing saved resu...
function [ max_test_errs , max_mu_index , min_test_errs , min_mu_index ] = rb_test_convergence(detailed_data, model)
rb_test_convergence(detailed_data,model)