Skip to content

Commit 7cde84a

Browse files
committed
Cumulative update.
- Various documentation changes for function descriptions. - decoyAnalysisIndependentLP: - forceSep now defaults to True. This will help ensure bounds don't cross over each other. - Minor update to sdp formatting. - yields are now clipped to the range [0,1] to reduce effects from cvx precision. - Frank wolfe 2 step solver: - An improved method for perturbing the objective function was found that does not require a continuity bound. - mustFollowPerturbationTheorem was removed and various functions were updated for this analysis. - Appendix B of the software manual was updated to describe this new method. - minor changes to the step 1 solver's cvx problem formatting. - updated ind2subPlus to fix compatibility with Matlab version 2024b after ind2sub was updated.
1 parent 69343f5 commit 7cde84a

File tree

12 files changed

+60
-58
lines changed

12 files changed

+60
-58
lines changed

BasicProtocols/BasicBB84WCPDecoy/decoyAnalysisIndependentLP.m

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
function [conExpL,conExpU] = decoyAnalysisIndependentLP(conExp,decoys,options)
22
% decoyAnalysisIndependentLP: A decoy analysis module for assymptotic data.
33
% Returns the upper and lower bounds on the expectations condition on
4-
% single photons being sent. This function assumes that the source uses a
5-
% weak coherent pulsed laser to generate signals.
4+
% single photons being sent and signal choice. This function assumes that
5+
% the source uses a weak coherent pulsed laser to generate signals.
66
%
77
% Input:
88
% * conExp: A table of expectation values of Bob's measurement result
99
% (columns) conditioned on Alice's measurement result (rows) and decoy
1010
% intensity used (pages deep / third array dimension). Each row must be
11-
% non-negative and sum to 1. Values of conditioned on intensity.
11+
% non-negative and sum to 1 (ie. values are conditioned on intensity and
12+
% signal sent by Alice). The first page is the key generating intensity.
1213
% * decoys: vector of intensities used for each page in conExp. Ordered by
1314
% the page number. The intensities must be non-negative. Warning: an
1415
% intensity of 0 is rather unstabe in numerical decoy analysis. We
1516
% recommend you try something slightly above.
17+
%
1618
% Name-value pair options:
1719
% * decoyTolerance (1e-12): A small extra tolerance term to loosen the
1820
% linear constraints by when solving.
1921
% * decoySolver ("SDPT3"): The solver you want CVX to use.
2022
% * decoyPrecision ("high"): The precision you want CVX to use.
2123
% * photonCutOff (10): The photon number cut off you want the decoy
2224
% analysis to solve up to.
23-
% * forceSep (false): For each expectation value, the single photon lower
25+
% * forceSep (true): For each expectation value, the single photon lower
2426
% bound shouldn't be higher than the upper bound. Sometimes CVX does not
2527
% satisfy this trivial bound. If set to true, an extra constraint will be
2628
% added to force the single photon components to respect the bound.
29+
%
30+
% Output:
31+
% * conExpL: Lower bound on the probability of Bob's measurment outcomes
32+
% (rows) conditioned on Alice's signal choice (columns) and single photon
33+
% sent.
34+
% * conExpU: Upper bound on the probability of Bob's measurment outcomes
35+
% (rows) conditioned on Alice's signal choice (columns) and single photon
36+
% sent.
2737
%
2838
% Reviewed by Devashish Tupkary 2023/09/23
2939
arguments
@@ -33,7 +43,7 @@
3343
options.decoySolver (1,1) string = "SDPT3";
3444
options.decoyPrecision (1,1) string = "high";
3545
options.photonCutOff (1,1) double {mustBeInteger,mustBePositive} = 10;
36-
options.forceSep (1,1) logical = false;
46+
options.forceSep (1,1) logical = true;
3747
end
3848

3949

@@ -114,17 +124,18 @@
114124
cvx_solver(convertStringsToChars(decoySolver));
115125
cvx_precision(convertStringsToChars(decoyPrecision));
116126

117-
variables yieldsL(numPhotons,numOutcomes) yieldsU(numPhotons,numOutcomes)
127+
yieldsL = variable('yieldsL(numPhotons,numOutcomes)','nonnegative');
128+
yieldsU = variable('yieldsU(numPhotons,numOutcomes)','nonnegative');
118129

119130
minimize(sum(yieldsL(2,:) - yieldsU(2,:))) % 2 corresponds to single-photon yields
120131
subject to
121132

122-
0 <= yieldsL <= 1;
133+
yieldsL <= 1;
123134

124135
poissonCache*yieldsL <= conExp +decoyTolerance;
125136
poissonCache*yieldsL >= conExp -probRemaining -decoyTolerance;
126137

127-
0 <= yieldsU <= 1;
138+
yieldsU <= 1;
128139

129140
poissonCache*yieldsU <= conExp +decoyTolerance;
130141
poissonCache*yieldsU >= conExp -probRemaining -decoyTolerance;
@@ -141,8 +152,10 @@ variables yieldsL(numPhotons,numOutcomes) yieldsU(numPhotons,numOutcomes)
141152
throwAsCaller(exception);
142153
end
143154

144-
conExpLowerBound = yieldsL(2,:);
145-
conExpUpperBound = yieldsU(2,:);
155+
%read out single photons from the yields and clip between 0 and 1 to remove
156+
%numerical errors.
157+
conExpLowerBound = min(max(yieldsL(2,:),0),1);
158+
conExpUpperBound = min(max(yieldsU(2,:),0),1);
146159

147160
end
148161

MathSolverModules/OQCTFrankWolfe2StepSolver/FW2StepSolver.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
% more details (the second argument, x1, in the function).
6969
% * linearConstraintTolerance (1e-10): constraint tolerance on the
7070
% equalityConstraints, inequalityConstraints, vectorOneNormConstraints
71-
% and matrixOneNormConstraints. A bit broader than the name suggests.
71+
% and matrixOneNormConstraints for step 1 of the solver. This is to help
72+
% the solver find feasible points during step 1 and play no role in step
73+
% 2.
7274
% * initMethod (1): Integer selected from {1,2,3}. For the Frank Wolfe
7375
% algorithm, the initial point must satisfy the constraints. This selects
7476
% which technique is used, from 3 choices:

MathSolverModules/OQCTFrankWolfe2StepSolver/HelperFunctions/mustFollowPerturbationTheorem.m

Lines changed: 0 additions & 19 deletions
This file was deleted.

MathSolverModules/OQCTFrankWolfe2StepSolver/HelperFunctions/perturbationChannelEpsilon.m

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@
4242
end
4343

4444
epsilon = dim*(minEigenvalue-eigMin)/(real(trace(rho))-eigMin*dim);
45-
try
46-
%check
47-
if options.perturbationCheck
48-
mustFollowPerturbationTheorem(epsilon,rho);
49-
end
50-
catch ME
51-
rethrow(ME)
45+
%check
46+
if options.perturbationCheck && (epsilon < 0 || epsilon > 1)
47+
throw(MException("perturbationCHannelEpsilon:UnphysicalPerturbation", ...
48+
"The perturbation parameter calculated was not in the range [0,1]."))
5249
end
5350
end
5451

MathSolverModules/OQCTFrankWolfe2StepSolver/HelperFunctions/primalDfep.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
% * Dfval: The value of the gradient at the given value of rho. This uses
1616
% numerator convention.
1717
%
18-
% See also primalDf, primalfep, FW2StepSolver, perturbationChannelEpsilon
18+
% See also primalDf, primalfep, FW2StepSolver
1919
arguments
2020
%minimial checks just to make sure cells are formatted in the correct
2121
%orientation.
22-
perturbation (1,1) double
23-
rho (:,:) double {mustBeHermitian,mustFollowPerturbationTheorem(perturbation,rho)}
22+
perturbation (1,1) double {mustBeInRange(perturbation,0,1)}
23+
rho (:,:) double {mustBeHermitian}
2424
keyProj (:,1) cell %checks are too complex for this.
2525
krausOperators (:,1) cell %checks are too complex for this.
2626
safeCutOff (1,1) double {mustBePositive} = 1e-14;

MathSolverModules/OQCTFrankWolfe2StepSolver/HelperFunctions/primalfep.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
% * realEpsilon: The epsilon value that was used to compute fval. Must be
1818
% between 0 and 1.
1919
%
20-
% See also primalf, primalDfep, FW2StepSolver, perturbationChannelEpsilon
20+
% See also primalf, primalDfep, FW2StepSolver
2121
arguments
2222
%minimial checks just to make sure cells are formatted in the correct
2323
%orientation.
24-
perturbation (1,1) double
25-
rho (:,:) double {mustBeHermitian, mustFollowPerturbationTheorem(perturbation,rho)}
24+
perturbation (1,1) double {mustBeInRange(perturbation,0,1)}
25+
rho (:,:) double {mustBeHermitian}
2626
keyProj (:,1) cell
2727
krausOperators (:,1) cell
2828
safeCutOff (1,1) double {mustBePositive} = 1e-14;

MathSolverModules/OQCTFrankWolfe2StepSolver/HelperFunctions/step1Solver.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@
157157
variable(convertStringsToChars(rhoStrings(index)),'hermitian','semidefinite')
158158
end
159159
% Get a single cell array to capture those variables.
160-
rhoBlocks = eval("{"+strjoin(compose("rho%d",1:numel(newDims)),",")+"}");
160+
rhoBlocksString = "{"+strjoin(compose("rho%d",1:numel(newDims)),",")+"}";
161+
rhoBlocks = eval(rhoBlocksString);
161162

162163

163164
% there is a bug in cvx's blkdiag override that messes up some times.
@@ -192,6 +193,7 @@ minimize norm(rho0-rho)
192193
% reconstruct rho from blocks incase it didn't get filled in by CVX
193194
if options.blockDiagonal
194195
rho = zeros(dim);
196+
rhoBlocks = eval(rhoBlocksString);
195197
rho = directSumWorkArround(rho, rhoBlocks);
196198
rho = P'*rho*P;
197199
end
@@ -227,7 +229,8 @@ minimize norm(rho0-rho)
227229
variable(convertStringsToChars(deltaRhoStrings(index)),'hermitian') %NOT semidefinite
228230
end
229231
% Get a single cell array to capture those variables.
230-
deltaRhoBlocks = eval("{"+strjoin(compose("deltaRho%d",1:numel(newDims)),",")+"}");
232+
deltaRhoBlocksString = "{"+strjoin(compose("deltaRho%d",1:numel(newDims)),",")+"}";
233+
deltaRhoBlocks = eval(deltaRhoBlocksString);
231234

232235

233236
% there is a bug in cvx's blkdiag override that messes up some times.
@@ -255,6 +258,7 @@ minimize real(trace(gradf*deltaRho)) % numerator form
255258
% reconstruct rho from blocks incase it didn't get filled in by CVX
256259
if options.blockDiagonal
257260
deltaRho = zeros(dim);
261+
deltaRhoBlocks = eval(deltaRhoBlocksString);
258262
deltaRho = directSumWorkArround(deltaRho, deltaRhoBlocks);
259263
deltaRho = P'*deltaRho*P;
260264
end

MathSolverModules/OQCTFrankWolfe2StepSolver/HelperFunctions/step2Solver.m

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[perturbation,safeCutOff] = computePerturbationEpsilon(rho, krausOps, keyProj);
2121
debugInfo.storeInfo("perturbationValue",perturbation);
2222

23-
% 2. Calculate f_epsilon_p(rho) and gradftranspose of that
23+
% 2. Calculate f_epsilon_p(rho) and its gradient at the same point.
2424
fval = primalfep(perturbation, rho, keyProj, krausOps,safeCutOff);
2525
debugInfo.storeInfo("relEntStep2Linearization",fval/log(2));
2626

@@ -37,16 +37,12 @@
3737
% compute key rate lower bound from the result of step 2
3838
beta = dualSolution + fval - real(trace(gradf*rho)); %real() deals with small numerical instability
3939

40-
% We compute the penalty zetaEp due to pertubation
41-
if perturbation == 0
42-
zetaEp = 0; %limit as perturbation -> 0
43-
else
44-
dimOut = size(krausOps{1},1);
45-
zetaEp = 2 * 2*perturbation*(dimOut-1)/dimOut...
46-
*log(dimOut^2/(2*perturbation*(dimOut-1)));
47-
end
40+
% Because f(maxMixed) = 0, we can use convex arguments to get
41+
% f_\epsilon(\rho)/(1-\epsilon) \leq f(\rho)$. This is way cleaner than
42+
% other perturbation bounds
43+
4844

49-
lowerBound = beta - zetaEp;
45+
lowerBound = beta/(1-perturbation);
5046
end
5147

5248
%% Other Functions
-11.5 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Our software requires *at least version 2020b* for full functionality, but insta
3939
Our software has the following dependencies for its default settings:
4040

4141
- [CVX](https://cvxr.com/cvx/download/) v2.2, a library for solving convex optimization problems in MATLAB.
42-
- [QETLAB](https://github.com/nathanieljohnston/QETLAB) *above* v0.9, a MATLAB toolbox for operations involving quantum channels and entanglement. Note that you cannot use the version from their website as it has a bugs associated with implementing Choi matrices. *You must use their latest copy on GitHub*. At the time of writing, this means downloading their code with the green "code" button and *not* the v0.9 release.
42+
- [QETLAB](https://github.com/nathanieljohnston/QETLAB) *above* v0.9, a MATLAB toolbox for operations involving quantum channels and entanglement. Note that you cannot use the version from their website as it has a bugs associated with implementing Choi matrices. *You must use their latest copy on Github*. At the time of writing, this means downloading their code with the green "code" button and *not* the v0.9 release.
4343
- [ZGNQKD](https://www.math.uwaterloo.ca/~hwolkowi/henry/reports/ZGNQKDmainsolverUSEDforPUBLCNJuly31/) solver (optional), an alternative to our Frank-Wolfe solver for quantum relative entropy. Currently, it only supports equality constraints. Download the zip and the "Solver" folder and sub-folders to your path.
4444
- [MOSEK](https://www.mosek.com/) (optional), a more advanced semidefinite programming (SDP) solver than the default (SDPT3) used in CVX. Note that the MOSEK solver can be downloaded together with CVX, but requires a separate license to use. See [this page](https://cvxr.com/cvx/doc/mosek.html) for more information.
4545

0 commit comments

Comments
 (0)