Debian Codegraph @

packages/rol/example/PDE-OPT/stefan-boltzmann/plotstats.m

raw
1 dir = {'meanValue','riskAverse'};
2
3 adj = load([char(dir(1)),'/cell_to_node_quad.txt']) + 1; %% load node adjacency table, increment by 1 for 1-based indexing
4 nodes = load([char(dir(1)),'/nodes.txt']); %% load node coordinates
5
6 for i=1:length(dir)
7 data_obj = importdata([char(dir(i)),'/mean_state.txt'], ' ', 2); %% we need to skip the first two lines
8 state = data_obj.data;
9 figure(i)
10 trisurf(adj, nodes(:,1), nodes(:,2), state);
11 shading interp;
12 view(0,90)
13 axis equal
14 axis tight
15 end
16
17 control = [];
18 for i = 1:length(dir)
19 data_obj = importdata([char(dir(i)),'/control.txt'], ' ', 2); %% we need to skip the first two lines
20 control = [control, data_obj.data];
21 end
22 figure(length(dir)+1)
23 ind = find(nodes(:,2)==0);
24 plot(nodes(ind,1),control(ind,:),'linewidth',3)
25 legend(char(dir));
26 axis square
27
28 data = [];
29 for i = 1:length(dir)
30 A = load([char(dir(i)),'/obj_samples.txt']);
31 data = [data, A(:,end-1)];
32 end
33
34 M = 1000;
35 x = linspace(min(min(data))-50,max(max(data))+50,M).';
36 cdf = zeros(M,length(dir));
37 for i = 1:length(dir)
38 for j = 1:M
39 ind = find(data(:,i) <= x(j));
40 cdf(j,i) = length(ind)/length(data(:,i));
41 end
42 end
43 figure(length(dir)+2)
44 plot(x,cdf,'linewidth',3)
45 legend(char(dir))
46 axis square