-
Notifications
You must be signed in to change notification settings - Fork 4
/
make_plots.m
236 lines (183 loc) · 7.55 KB
/
make_plots.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
% read in ensemble_size running times and precisions for each method, for each d.
%% check global variable set
if exist('ensemble')
fprintf(['ensemble = ',ensemble])
else
error('you must set the ensemble variable to either qp (quasi pure) or fr (full rank)')
end
if exist('drange')
fprintf(['drange = ',drange])
else
error('you must set the drange variable')
end
if exist('LIswitch')
fprintf(['LIswitch = ',LIswitch])
else
error('you must set the LIsiwtch variable (if 0 Linear Inversion is run, if 1 it is not)')
end
if exist('ensemble_size')
fprintf(['ensemble_size = ',ensemble_size])
else
error('you must set the ensemble_size variable')
end
%%
dmax = drange(end);
gdapB_times = zeros(ensemble_size,dmax);
gdapM_times = zeros(ensemble_size,dmax);
mosek_times = zeros(ensemble_size,dmax);
sdpt3_times = zeros(ensemble_size,dmax);
DIA_times = zeros(ensemble_size,dmax);
% sedumi_times = zeros(ensemble_size,dmax); % this fails
li_times = zeros(ensemble_size,dmax);
gdapB_errors = zeros(ensemble_size,dmax);
gdapM_errors = zeros(ensemble_size,dmax);
mosek_errors = zeros(ensemble_size,dmax);
sdpt3_errors = zeros(ensemble_size,dmax);
DIA_errors = zeros(ensemble_size,dmax);
li_errors = zeros(ensemble_size,dmax);
% sedumi_errors = zeros(ensemble_size,dmax);
for d=drange
d
for i=1:ensemble_size
dir = sprintf('./benchmarking_results/d%i',d);
clear choi_ground
load([dir,'/dataset',num2str(i)]);
clear choi_ml_vec
load([dir,'/DIA_results',num2str(i)]);
DIA_times(i,d) = elapsedTime;
choi_DIA = reshape(choi_ml_vec,[],d*d);
DIA_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_DIA/trace(choi_DIA));
clear choi_ml_vec
load([dir,'/gdapB_results',num2str(i)]);
gdapB_times(i,d) = elapsedTime;
choi_gdapB = reshape(choi_ml_vec,[],d*d);
gdapB_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_gdapB/trace(choi_gdapB));
clear choi_ml_vec
% load([dir,'/gdapM_results',num2str(i)]);
% gdapM_times(i,d) = elapsedTime;
% choi_gdapM = reshape(choi_ml_vec,[],d*d);
% gdapM_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_gdapM/trace(choi_gdapM));
%
% clear choi_ml_vec
load([dir,'/mosek_results',num2str(i)]);
mosek_times(i,d) = elapsedTime;
choi_mosek = reshape(choi_ml_vec,[],d*d);
mosek_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_mosek/trace(choi_mosek));
%
% load([dir,'/sdpt3_results',num2str(i)]);
% sdpt3_times(i,d) = elapsedTime;
% choi_sdpt3 = reshape(choi_ml_vec,[],d*d);
% sdpt3_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_sdpt3/trace(choi_sdpt3));
% clear choi_ml_vec
%
% load([dir,'/sedumi_results',num2str(i)]);
% sedumi_times(i,d) = elapsedTime;
% choi_sedumi = reshape(choi_ml_vec,[],d*d);
% sedumi_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_sedumi/trace(choi_sedumi));
if LIswitch
clear choi_ml_vec
load([dir,'/LinInversion_results',num2str(i)]);
li_times(i,d) = elapsedTime;
choi_li = reshape(choi_ml_vec,[],d*d);
li_errors(i,d) = trace_dist(choi_ground/trace(choi_ground),choi_li/trace(choi_li));
end
end
end
figure; hold on;
errorbar(2:dmax,nanmean(DIA_times(:,2:end)),nanstd(DIA_times(:,2:end)),'-d','LineWidth',2);
errorbar(2:dmax,nanmean(gdapB_times(:,2:end)),nanstd(gdapB_times(:,2:end)),'-*','LineWidth',2);
% errorbar(2:dmax,nanmean(gdapM_times(:,2:end)),nanstd(gdapB_times(:,2:end)),'-*','LineWidth',2);
errorbar(2:dmax,nanmean(mosek_times(:,2:end)),nanstd(mosek_times(:,2:end)),'-x','LineWidth',2);
% errorbar(2:dmax,nanmean(sdpt3_times(:,2:end)),nanstd(sdpt3_times(:,2:end)),'-x','LineWidth',2);
% errorbar(2:dmax,nanmean(sedumi_times(:,2:end)),nanstd(sedumi_times(:,2:end)),'-s','LineWidth',2);
if LIswitch
errorbar(2:dmax,nanmean(li_times(:,2:end)),nanstd(li_times(:,2:end)),'-x','LineWidth',2);
end
xlim([1.8,dmax+0.2])
xlabel 'Hilbert space dimension'
ylabel 'times taken (s)';
set(gca,'YScale','log');
legend('DIA','gdapB','mosek')
% legend('gdapB','mosek','sdpt3')
box on
grid on
set(gca,'fontsize',18)
saveas(gcf,'./plots/time.png')
saveas(gcf,'./plots/time.eps','epsc')
figure; hold on;
errorbar(2:dmax,nanmean(DIA_errors(:,2:end)),nanstd(DIA_errors(:,2:end)),'-d','LineWidth',2);
errorbar(2:dmax,nanmean(gdapB_errors(:,2:end)),nanstd(gdapB_errors(:,2:end)),'-*','LineWidth',2);
% errorbar(2:dmax,nanmean(gdapM_errors(:,2:end)),nanstd(gdapB_errors(:,2:end)),'-*','LineWidth',2);
errorbar(2:dmax,nanmean(mosek_errors(:,2:end)),nanstd(mosek_errors(:,2:end)),'-x','LineWidth',2);
% errorbar(2:dmax,nanmean(sdpt3_errors(:,2:end)),nanstd(sdpt3_errors(:,2:end)),'-x','LineWidth',2);
% errorbar(2:dmax,nanmean(sedumi_errors(:,2:end)),nanstd(sedumi_errors(:,2:end)),'-s','LineWidth',2);
if LIswitch
errorbar(2:dmax,nanmean(li_errors(:,2:end)),nanstd(li_errors(:,2:end)),'-x','LineWidth',2);
end
xlim([1.8,dmax+0.2])
ylim([0,1])
xlabel 'Hilbert space dimension'
ylabel 'J distance';
set(gca,'YScale','log')
legend('DIA','gdapB','mosek')
% legend('gdapB','mosek','sdpt3')
box on
grid on
set(gca,'fontsize',18)
saveas(gcf,'./plots/errors.png')
saveas(gcf,'./plots/errors.eps','epsc')
%%
figure('Position',[1 0 400 250]); hold on;
for d = 2:dmax
ax = gca;
ax.ColorOrderIndex = 1;
ax.YAxisLocation = 'right';
DIAx(d) = nanmean(DIA_errors(:,d));
DIAxbar(d) = nanstd(DIA_errors(:,d));
DIAy(d) = nanmean(DIA_times(:,d));
DIAybar(d) = nanstd(DIA_times(:,d));
errorbar(DIAx(d),DIAy(d),DIAybar(d),DIAybar(d),DIAxbar(d),DIAxbar(d),'LineWidth',2)
gdapBx(d) = nanmean(gdapB_errors(:,d));
gdapBxbar(d) = nanstd(gdapB_errors(:,d));
gdapBy(d) = nanmean(gdapB_times(:,d));
gdapBybar(d) = nanstd(gdapB_times(:,d));
errorbar(gdapBx(d),gdapBy(d),gdapBybar(d),gdapBybar(d),gdapBxbar(d),gdapBxbar(d),'LineWidth',2)
mosekx(d) = nanmean(mosek_errors(:,d));
mosekxbar(d) = nanstd(mosek_errors(:,d));
moseky(d) = nanmean(mosek_times(:,d));
mosekybar(d) = nanstd(mosek_times(:,d));
errorbar(mosekx(d),moseky(d),mosekybar(d),mosekybar(d),mosekxbar(d),mosekxbar(d),'LineWidth',2)
if LIswitch
lix(d) = nanmean(li_errors(:,d));
lixbar(d) = nanstd(li_errors(:,d));
liy(d) = nanmean(li_times(:,d));
liybar(d) = nanstd(li_times(:,d));
errorbar(lix(d),liy(d),liybar(d),liybar(d),lixbar(d),lixbar(d),'LineWidth',2)
end
%triangles
% plot([DIAx(d),gdapBx(d)],[DIAy(d),gdapBy(d)],'k')
% plot([DIAx,mosekx],[DIAy,moseky],'k')
% plot([mosekx(d),gdapBx(d)],[moseky(d),gdapBy(d)],'k')
end
ax = gca;
ax.ColorOrderIndex = 1;
plot(DIAx,DIAy,'LineWidth',2)
plot(gdapBx,gdapBy,'LineWidth',2)
plot(mosekx,moseky,'LineWidth',2)
if LIswitch
plot(lix,liy,'LineWidth',2)
end
set(gca,'xscale','log')
set(gca,'yscale','log')
xlabel 'error'
ylabel 'time (s)'
set(gca,'XTick',([1e-8,1e-7,1e-6,1e-5,1e-4,1e-3,1e-2,1e-1,1e0]))
% xlim([5e-5,5e-2])
ylim([1e-2,1e2])
box on
grid on
legend('DIA','pgdB','mosek','Location','northwest')
set(gca,'fontsize',12)
saveas(gcf,['./plots/',ensemble,'triangles.png'])
saveas(gcf,['./plots/',ensemble,'triangles.eps'],'epsc')
savefig(['./plots/',ensemble,'triangles'])