-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_results_4.m
77 lines (66 loc) · 2.22 KB
/
plot_results_4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function plot_results_4
close all; clear; clc;
% hyper-params
idName= 'Histogram_convergence';
N0=1;
N_iter=50;
dir='/home/mahdi/ETHZ/GBO/code/data_driven_controller/tmp/server_runs_ver_3';
tmp=[];
for m=1:4
load(append(dir,'/InitobjectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_1_tmp=InitobjectiveData_all;
objectiveData_all_server_1_tmp=reshape(objectiveData_all_server_1_tmp(1:end),[50,20]);
tmp=[tmp, objectiveData_all_server_1_tmp];
end
objectiveData_all_server_1=tmp;
tmp=[];
for m=17:20
load(append(dir,'/InitobjectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_surrogate_tmp=InitobjectiveData_all;
objectiveData_all_server_surrogate_tmp=reshape(objectiveData_all_server_surrogate_tmp(1:end),[50,20]);
tmp=[tmp, objectiveData_all_server_surrogate_tmp];
end
objectiveData_all_server_surrogate=tmp;
for i=1:1000
for j=1:50
objectiveData_all_server_1(j,i)=nanmin(objectiveData_all_server_1(1:j,i));
objectiveData_all_server_surrogate(j,i)=nanmin(objectiveData_all_server_surrogate(1:j,i));
end
end
true_objective=0.1243; %with ts=0.1
th_opt_ratio=1.2;
aa=objectiveData_all_server_1/true_objective;
aa=aa>th_opt_ratio;
bb=objectiveData_all_server_surrogate/true_objective;
bb=bb>th_opt_ratio;
[~, columns] = size(aa);
AA = zeros(1, columns);
BB = zeros(1, columns);
for col = 1 : size(aa, 2)
if sum(aa(:, col))>0
AA(1, col) = find(aa(:, col), 1, 'last')+1;
end
if sum(bb(:, col))>0
BB(1, col) = find(bb(:, col), 1, 'last')+1;
end
end
f2=figure(2);hold on
f2.Position=[200 0 1600 800];
edges = [0:5:N0+N_iter];
h=histogram(AA, edges, 'FaceColor', [0 0 1], 'Normalization','probability');
h_surrogate=histogram(BB, edges, 'FaceColor', [1 0 0], 'Normalization','probability');
ytix = get(gca, 'YTick');
set(gca, 'YTick',ytix, 'YTickLabel',ytix*100)
legend([h_surrogate h],{'Guided BO','BO'}, 'Location', 'best')
grid on
xlabel('Total Number of Data')
ylabel('Percentage')
title(append('Covergence Histogram to Optimality Ratio ', th_opt_ratio))
set(gca, 'DefaultAxesFontName', 'Times')
figName=append(dir, '_server_', idName,'.png');
saveas(gcf,figName)
figName=append(dir, '_server_', idName,'.fig');
saveas(gcf,figName)
pause;
close all;
end