|
| 1 | +clear |
| 2 | + |
| 3 | +addpath('graphs', 'performance') |
| 4 | + |
| 5 | +%% Set up the problem |
| 6 | +kappa = 0.1; |
| 7 | +sysD = ss(1, 1, 1, 0); |
| 8 | +sysC = ss(-kappa, 0, 0, 0); |
| 9 | + |
| 10 | +% Grid the probability axis. Higher density where larger changes are |
| 11 | +% expected |
| 12 | +p = [0, 1e-6, 1e-5, 1e-4, 1e-3:1e-3:9e-3, 0.01:0.01:0.29, 0.3:0.025:1]; |
| 13 | + |
| 14 | +% Calculate the norms for two examples, large and small networks |
| 15 | +h = [4, 50]; |
| 16 | +N = h.*(h+1)/2; |
| 17 | + |
| 18 | +%% |
| 19 | +[H, P] = meshgrid(h, p); |
| 20 | +sz = size(H); |
| 21 | + |
| 22 | +% Pre-allocate storage |
| 23 | +norm_mean = NaN(length(p),length(h)); |
| 24 | +norm_enum = NaN(length(p),length(h)); |
| 25 | +norm_decom = NaN(length(p),length(h)); |
| 26 | + |
| 27 | +tic |
| 28 | +parfor i = 1:length(h)*length(p) |
| 29 | + L = full(laplace_matrix(triangle_graph(H(i)))); |
| 30 | + |
| 31 | + norm_mean(i) = performance_mean(sysD, sysC, L, P(i)); |
| 32 | + norm_decom(i) = performance_decomposed(sysD, sysC, L, P(i)); |
| 33 | + |
| 34 | + % The enumerated norm is only calculated for the small network, since |
| 35 | + % its scalling exponentially and thus infeasible to calculate for the |
| 36 | + % large network. |
| 37 | + [~, j] = ind2sub(sz, i); |
| 38 | + if j == 1 |
| 39 | + norm_enum(i) = performance_enumerated(sysD, sysC, L, P(i), true); |
| 40 | + end |
| 41 | +end |
| 42 | +toc |
| 43 | + |
| 44 | +%% Plot data like in the paper |
| 45 | +figure(1) |
| 46 | +plot(p, norm_mean(:,1), 'k-.', p, norm_enum(:,1), 'k-', p, norm_decom(:,1), 'k--') |
| 47 | +ylim([0, 44]) |
| 48 | +title('Small Network Performance') |
| 49 | +xlabel('Probability p') |
| 50 | +ylabel('H_2-norm') |
| 51 | +legend('Mean', 'Enumerated', 'Decomposed') |
| 52 | + |
| 53 | +figure(2) |
| 54 | +semilogy(p, norm_mean(:,2), 'k-.', p, norm_decom(:,2), 'k--') |
| 55 | +ylim([3e1, 2e4]) |
| 56 | +title('Large Network Performance') |
| 57 | +xlabel('Probability p') |
| 58 | +ylabel('H_2-norm') |
| 59 | +legend('Mean', 'Decomposed') |
| 60 | + |
| 61 | +%% CSV Export |
| 62 | +p = p'; |
| 63 | +small_mean = norm_mean(:,1); |
| 64 | +small_enum = norm_enum(:,1); |
| 65 | +small_decom = norm_decom(:,1); |
| 66 | +small_table = table(p, small_mean, small_enum, small_decom); |
| 67 | + |
| 68 | +large_mean = norm_mean(:,2); |
| 69 | +large_decom = norm_decom(:,2); |
| 70 | +large_table = table(p, large_mean, large_decom); |
| 71 | + |
| 72 | +name = sprintf('conservatism_small_%d.csv', uint32(posixtime(datetime()))); |
| 73 | +writetable(small_table, name) |
| 74 | +name = sprintf('conservatism_large_%d.csv', uint32(posixtime(datetime()))); |
| 75 | +writetable(large_table, name) |
0 commit comments