-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHeuristicSearchBroadcastScript.m
331 lines (182 loc) · 8.45 KB
/
HeuristicSearchBroadcastScript.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
%Heuristic search in the broadcast scenario
rng('shuffle'); %Ensures that the Heuristic starts with different random seeds
%This code tries to find the smallest visibility 'v' such that v*rho + (1-v)*rhoNoise is
%broadcast nonlocal, where 'rho' is typically nonlocal while 'rhoNoise' is
%separable (see https://arxiv.org/abs/2007.16034)
%The variables can be set using script "PrepareAndRun_HeuristicSearchBroadcast.m
%Variables needed :
%'rho' is an arbitrary multipartite state, typically entangled/nonlocal
%'rhoNoise' is an arbitrary multipartite state of the same dimension as 'rho', 'rhoN' is typically separable and represents the noisy part of the state
%'WChois' sets the (initial) parties where one wants to apply a Choi map
%'dloc' sets the local dimensions of the final parties
%'nInputs' sets the number of inputs of each final party
%'nOutputs' sets the number of outputs of each final party
%'VerticesAllbutLast' sets the strategies of all parties, but the last (where no-signaling is already built-in)
%Less important degrees of freedom (already set in the script):
%'prec' sets the gap between two succesive visibilites at which the search stops (default: 10^-5)
%'limcount' sets the maximum number of tries to find a violation of the current best inequality (default: 5)
%One might also enter manually some of the initial parameters of the search
%(variables 'Meas' and 'Choi' in the first loop), or can set which Choi states/ which measurements to optimize the
%inequalities on (variables 'WhichChoi' and 'WhichMeas')
Nparties = length(dims); %number of initial parties
%Output dimensions of Choi states
dOut=zeros(1,Nparties);
for k=1:length(dloc)
dOut(k) = prod(dloc{k});
end
%Polytope last party
VerticesB=local_polytope(length(nInputs{Nparties}),nInputs{Nparties},nOutputs{Nparties}); %change only if other strategies than no-signaling polytope are required for last party
%local vertices are generated here, but one then take an arbitrary linear combination of them -instead of convex.
%This is equivalent to considering the set of all no-signaling strategies ((see e.g. Theorem 1 of https://arxiv.org/pdf/0804.4859.pdf)
%numbers of overall outputs for last party
outB=prod(nOutputs{Nparties});
%flat scenario
dlocvec = cell2mat(dloc);
nInputsflat = cell2mat(nInputs);
nOutputsflat = cell2mat(nOutputs);
%Search a point outside
%stores succesive values of visibility in a vector
Visibility_vector=0;
vis = 2;
while vis > 1
%Random (projective) Choi states
Choi=cell(1,length(dims));
for k=1:length(dims)
if ismember(k,WChoi)
Choi{k}=RandomChoi_proj(dims(k),dOut(k));
else
Choi{k}=ChoiId(dims(k));
end
end
%Random (projective) measurements
Meas=cell(1,length(nInputsflat));
for k=1:length(nInputsflat)
Meas{k}= rand_povms(dlocvec(k),nOutputsflat(k),nInputsflat(k),1);
end
%Enter here optional fixed initial Choi states/measurements
% Meas{1} = blah ;
%
% Choi{2} = blouh ;
%Final states
rhoFinal = ApplyManyChois(rho,Choi,dims);
rhoNoiseFinal = ApplyManyChois(rhoNoise,Choi,dims);
%Quantum behaviours
BroadcastBehaviourRhoFinal = MultipartiteBehaviour(rhoFinal,Meas);
BroadcastBehaviourRhoNoiseFinal = MultipartiteBehaviour(rhoNoiseFinal,Meas);
%add some uniform noise, for stability (not clear it's useful with
%InteriorPoint algorithm)
p=10^-5;
BroadcastBehaviourRhoNoiseFinal = (1-p)*BroadcastBehaviourRhoNoiseFinal + p*MaximallyMixedBehaviour(Nparties,nInputsflat,nOutputsflat);
%
%Visibility
[vis,~,~,~,lambda] = p_maxPConvexAffineabxy(BroadcastBehaviourRhoFinal',BroadcastBehaviourRhoNoiseFinal',VerticesAllbutLast,VerticesB,[outA,outB]);
vis = vis(1)
% %If bug in the linprog stops the loop
% if length(vis) > 1
% disp 'Error in linprog, flag is'
% disp(vis(2))
% return
% end
end
%Extract inequality
Inequality=-lambda.eqlin;
%Compute the local bound of the inequality
violc = Inequality'*(vis*BroadcastBehaviourRhoFinal'+(1-vis)*BroadcastBehaviourRhoNoiseFinal');
%Store the results
all_info_Heuristic = cell(1,5);
all_info_Heuristic{1,1}=vis; all_info_Heuristic{1,2}=Choi; all_info_Heuristic{1,3}=Meas;
all_info_Heuristic{1,4}=Inequality; all_info_Heuristic{1,5}=violc;
%Start the heuristic optimization (optimizes inequality, then computes
%visibility of resulting point and new inequality, and so on)
CurrentVis=vis;
%Store the succesives visibilites into a vector
Visibility_vector(1)=vis(1);
%Stop when two succesives visibilities are closer than 'prec'
prec=10^-5;
%Start the loop
gap=1; iteration = 2;
while gap > prec
%Current best state
rhoc=CurrentVis*rho+(1-CurrentVis)*rhoNoise;
%Seesaw of the current inequality over measurements and Chois
WhichParties = 1:length(dlocvec); %Which parties to optimize over
WhichChois = WChoi; %Which Choi states to optimize over
%Tries 'limcount' times to violate the current inequality, stops when succeeds
limcount=5;
viol=violc-1;
count=0;
while viol < violc+10^-5
%Tries using previous settings as starting point
if count == 2
f=SeeSawBroadcastIneq(Inequality,rhoc,dims,WhichParties,WhichChois,Choi,Meas);
g=f;
else
%Random initial points:
%Random (projective) Choi states
ChoiR=cell(1,length(dims));
for k=1:length(dims)
if ismember(k,WChoi)
ChoiR{k}=RandomChoi_proj(dims(k),dOut(k));
else
ChoiR{k}=ChoiId(dims(k));
end
end
%Random (projective) measurements
MeasR=cell(1,length(nInputsflat));
for k=1:length(nInputsflat)
MeasR{k}= rand_povms(dlocvec(k),nOutputsflat(k),nInputsflat(k),1);
end
f=SeeSawBroadcastIneq(Inequality,rhoc,dims,WhichParties,WhichChois,ChoiR,MeasR);
end
yalmip clear
%stores the current violation
viol=f{1};
count=count+1;
%stops after 'limcount' attempts and keep the run using previous
%settings
if count > limcount && viol <= violc+10^-5
f=g;
break
end
end
%Extract measurements and Choi states
Meas = f{2};
Choi = f{3};
%Make all measurements and Chois valid
for k=1:length(Meas)
Meas{k}=make_povms_valid(Meas{k});
end
for k=1:length(Choi)
Choi{k}=make_choi_valid(Choi{k},dims(k),dOut(k));
end
%Final states
rhoFinal = ApplyManyChois(rho,Choi,dims);
rhoNoiseFinal = ApplyManyChois(rhoNoise,Choi,dims);
%Quantum behaviours
BroadcastBehaviourRhoFinal = MultipartiteBehaviour(rhoFinal,Meas);
BroadcastBehaviourRhoNoiseFinal = MultipartiteBehaviour(rhoNoiseFinal,Meas);
%Visibility
%add some uniform noise, for stability (not clear it's useful with
%InteriorPoint algorithm)
p=10^-5;
BroadcastBehaviourRhoNoiseFinal = (1-p)*BroadcastBehaviourRhoNoiseFinal + p*MaximallyMixedBehaviour(Nparties,nInputsflat,nOutputsflat);
%
[vis,~,~,~,lambda] = p_maxPConvexAffineabxy(BroadcastBehaviourRhoFinal',BroadcastBehaviourRhoNoiseFinal',VerticesAllbutLast,VerticesB,[outA,outB]);
vis = vis(1);
% %If bug in the linprog stops the loop
% if length(vis) > 1
% disp 'Error in linprog, flag is'
% disp(vis(2))
% return
% end
Visibility_vector(iteration)=vis(1),
%New inequality and bound
Inequality=-lambda.eqlin;
violc = Inequality'*(vis*BroadcastBehaviourRhoFinal'+(1-vis)*BroadcastBehaviourRhoNoiseFinal');
%Store the results
all_info_Heuristic{iteration,1}=vis; all_info_Heuristic{iteration,2}=Choi; all_info_Heuristic{iteration,3}=Meas;
all_info_Heuristic{iteration,4}=Inequality; all_info_Heuristic{iteration,5}=violc;
gap=CurrentVis-vis;
CurrentVis=vis;
iteration = iteration + 1;
end