-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_results_2.m
181 lines (163 loc) · 9.25 KB
/
plot_results_2.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
function plot_results_2
% hyper-params
N_iter=50;
repeat_experiment=250;
withSurrogate=false;
N_real_repeat=25;
Nsample=10;
np2=2;
withPerturbed=false;
num_perturbed_model=4;
% =========================================================================
dir='/home/mahdi/PhD application/ETH/Rupenyan/code/results/server_runs_ver_3';
tmp_N01=[];
tmp_N03=[];
tmp_N05=[];
tmp_N010=[];
tmp_N020=[];
for m=1:4
load(append(dir,'/InitobjectiveData_all_',num2str(m+32),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N01_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N01_tmp=reshape(objectiveData_all_server_N01_tmp(1:end),[50,250]);
tmp_N01=[tmp_N01, objectiveData_all_server_N01_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N03_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N03_tmp=reshape(objectiveData_all_server_N03_tmp(1:end),[50,250]);
tmp_N03=[tmp_N03, objectiveData_all_server_N03_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m+4),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N05_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N05_tmp=reshape(objectiveData_all_server_N05_tmp(1:end),[50,250]);
tmp_N05=[tmp_N05, objectiveData_all_server_N05_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m+8),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N010_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N010_tmp=reshape(objectiveData_all_server_N010_tmp(1:end),[50,250]);
tmp_N010=[tmp_N010, objectiveData_all_server_N010_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m+12),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N020_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N020_tmp=reshape(objectiveData_all_server_N020_tmp(1:end),[50,250]);
tmp_N020=[tmp_N020, objectiveData_all_server_N020_tmp];
end
objectiveData_all_server_N01=tmp_N01;
objectiveData_all_server_N03=tmp_N03;
objectiveData_all_server_N05=tmp_N05;
objectiveData_all_server_N010=tmp_N010;
objectiveData_all_server_N020=tmp_N020;
for i=1:1000
for j=1:50
objectiveData_all_server_N01(j,i)=nanmin(objectiveData_all_server_N01(1:j,i));
objectiveData_all_server_N03(j,i)=nanmin(objectiveData_all_server_N03(1:j,i));
objectiveData_all_server_N05(j,i)=nanmin(objectiveData_all_server_N05(1:j,i));
objectiveData_all_server_N010(j,i)=nanmin(objectiveData_all_server_N010(1:j,i));
objectiveData_all_server_N020(j,i)=nanmin(objectiveData_all_server_N020(1:j,i));
% objectiveData_all_server_surrogate(j,i)=nanmin(objectiveData_all_server_surrogate(1:j,i));
end
end
mean_objectiveData_all_server_N01=mean(objectiveData_all_server_N01,2,'omitnan');
mean_objectiveData_all_server_N03=mean(objectiveData_all_server_N03,2,'omitnan');
mean_objectiveData_all_server_N05=mean(objectiveData_all_server_N05,2,'omitnan');
mean_objectiveData_all_server_N010=mean(objectiveData_all_server_N010,2,'omitnan');
mean_objectiveData_all_server_N020=mean(objectiveData_all_server_N020,2,'omitnan');
% =========================================================================
dir='/home/mahdi/PhD application/ETH/Rupenyan/code/results/server_runs_ver_3';
tmp_N01=[];
tmp_N03=[];
tmp_N05=[];
tmp_N010=[];
tmp_N020=[];
for m=17:20
load(append(dir,'/InitobjectiveData_all_',num2str(m-16+36),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N01_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N01_tmp=reshape(objectiveData_all_server_N01_tmp(1:end),[50,250]);
tmp_N01=[tmp_N01, objectiveData_all_server_N01_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N03_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N03_tmp=reshape(objectiveData_all_server_N03_tmp(1:end),[50,250]);
tmp_N03=[tmp_N03, objectiveData_all_server_N03_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m+4),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N05_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N05_tmp=reshape(objectiveData_all_server_N05_tmp(1:end),[50,250]);
tmp_N05=[tmp_N05, objectiveData_all_server_N05_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m+8),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N010_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N010_tmp=reshape(objectiveData_all_server_N010_tmp(1:end),[50,250]);
tmp_N010=[tmp_N010, objectiveData_all_server_N010_tmp];
load(append(dir,'/InitobjectiveData_all_',num2str(m+12),'.mat'))
% load(append(dir,'/objectiveData_all_',num2str(m),'.mat'))
objectiveData_all_server_N020_tmp=InitobjectiveData_all;
% objectiveData_all_server_1_tmp=objectiveData_all;
objectiveData_all_server_N020_tmp=reshape(objectiveData_all_server_N020_tmp(1:end),[50,250]);
tmp_N020=[tmp_N020, objectiveData_all_server_N020_tmp];
end
objectiveData_all_server_N01=tmp_N01;
objectiveData_all_server_N03=tmp_N03;
objectiveData_all_server_N05=tmp_N05;
objectiveData_all_server_N010=tmp_N010;
objectiveData_all_server_N020=tmp_N020;
for i=1:1000
for j=1:50
objectiveData_all_server_N01(j,i)=nanmin(objectiveData_all_server_N01(1:j,i));
objectiveData_all_server_N03(j,i)=nanmin(objectiveData_all_server_N03(1:j,i));
objectiveData_all_server_N05(j,i)=nanmin(objectiveData_all_server_N05(1:j,i));
objectiveData_all_server_N010(j,i)=nanmin(objectiveData_all_server_N010(1:j,i));
objectiveData_all_server_N020(j,i)=nanmin(objectiveData_all_server_N020(1:j,i));
% objectiveData_all_server_surrogate(j,i)=nanmin(objectiveData_all_server_surrogate(1:j,i));
end
end
mean_objectiveData_all_server_N01_GBO=mean(objectiveData_all_server_N01,2,'omitnan');
mean_objectiveData_all_server_N03_GBO=mean(objectiveData_all_server_N03,2,'omitnan');
mean_objectiveData_all_server_N05_GBO=mean(objectiveData_all_server_N05,2,'omitnan');
mean_objectiveData_all_server_N010_GBO=mean(objectiveData_all_server_N010,2,'omitnan');
mean_objectiveData_all_server_N020_GBO=mean(objectiveData_all_server_N020,2,'omitnan');
% =========================================================================
% true_objective=0.1882; %with ts=1
true_objective=0.1243; %with ts=0.1
f2=figure(2);hold on
f2.Position=[200 0 1000 600];
hmean_N01=semilogy(mean_objectiveData_all_server_N01./true_objective, '--', 'LineWidth', 1, 'DisplayName','BO');
hmean_N03=semilogy(mean_objectiveData_all_server_N03./true_objective, '--', 'LineWidth', 1, 'DisplayName','BO');
hmean_N05=semilogy(mean_objectiveData_all_server_N05./true_objective, '--', 'LineWidth', 1, 'DisplayName','BO');
hmean_N010=semilogy(mean_objectiveData_all_server_N010./true_objective, '--', 'LineWidth', 1, 'DisplayName','BO');
hmean_N020=semilogy(mean_objectiveData_all_server_N020./true_objective, '--', 'LineWidth', 1, 'DisplayName','BO');
true_objective=0.1243; %with ts=0.1
hmean_N01_GBO=semilogy(mean_objectiveData_all_server_N01_GBO./true_objective, 'LineWidth', 1, 'DisplayName','GBO');
hmean_N03_GBO=semilogy(mean_objectiveData_all_server_N03_GBO./true_objective, 'LineWidth', 1, 'DisplayName','GBO');
hmean_N05_GBO=semilogy(mean_objectiveData_all_server_N05_GBO./true_objective, 'LineWidth', 1, 'DisplayName','GBO');
hmean_N010_GBO=semilogy(mean_objectiveData_all_server_N010_GBO./true_objective, 'LineWidth', 1, 'DisplayName','GBO');
hmean_N020_GBO=semilogy(mean_objectiveData_all_server_N020_GBO./true_objective, 'LineWidth', 1, 'DisplayName','GBO');
% hmean_surrogate=semilogy(mean_objectiveData_all_server_surrogate./true_objective, 'r', 'LineWidth', 4, 'DisplayName','BO');
legend([hmean_N01, hmean_N03, hmean_N05, hmean_N010, hmean_N020, hmean_N01_GBO, hmean_N03_GBO, hmean_N05_GBO, hmean_N010_GBO, hmean_N020_GBO],{'BO, N0=1','BO, N0=3','BO, N0=5', 'BO, N0=10', 'BO, N0=20','Guided BO, N0=1', 'Guided BO, N0=3','Guided BO, N0=5', 'Guided BO, N0=10', 'Guided BO, N0=20'}, 'Location', 'best')
grid on
% ylim([0.1 0.3])
ylim([1 2])
xlabel('Iteration')
ylabel('Optimality Ratio')
title(append('Minimum Observed Objective vs Iterations over Real Plant for BO and Guided BO'))
set(gca, 'DefaultAxesFontName', 'Times')
set(gca,'yscale','log')
% figName=append(dir, 'objectiveData_all.png');
figName=append(dir, 'server_', 'ALL_means_ts01','.png');
saveas(gcf,figName)
% figName=append(dir, 'objectiveData_all.fig');
figName=append(dir, 'server_', 'ALL_means_ts01','.fig');
saveas(gcf,figName)
pause;
close all;
end