-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdual.jl
48 lines (30 loc) · 1.32 KB
/
dual.jl
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
using Convex, SCS
using LinearAlgebra
using QuantumInformation
include("sdpcomb.jl")
include("sdp.jl")
swap = [1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1]
permutation23 = I(2) ⊗ swap ⊗ I(2)
permutation12 = swap ⊗ I(4)
permutation34 = I(4) ⊗ swap
const MOI = Convex.MOI
# W \in AI ⊗ A0 ⊗ BI ⊗ B0, where we assume that dimension of all spaces A0, AI, B0, BI equals d
function sdp_dual(W0, W1)
""" SDP calculating the probability of correct discrimination between W0 and W1 - dual problem. """
d = Int(size(W0)[1]^(1/4))
Y0 = ComplexVariable(d^3,d^3)
Y1 = ComplexVariable(d^3, d^3)
alpha = Variable()
constraints = [Y0 == Y0']
constraints += [Y1 == Y1']
constraints += [permutation12 * (I(d) ⊗ Y0) * permutation12' - I(d^2)/d ⊗ partialtrace(Y0,1,fill(d,3)) + Y1 ⊗ I(d) - partialtrace(Y1, 3,fill(d,3)) ⊗ I(d^2)/d + alpha * I(d^4) - 1/2 * W0 in :SDP]
constraints += [permutation12 * (I(d) ⊗ Y0) * permutation12' - I(d^2)/d ⊗ partialtrace(Y0,1,fill(d,3)) + Y1 ⊗ I(d) - partialtrace(Y1, 3,fill(d,3)) ⊗ I(d^2)/d + alpha * I(d^4) - 1/2 * W1 in :SDP]
f = real(alpha * d^2)
problem = minimize(f, constraints)
solve!(
problem,
MOI.OptimizerWithAttributes(SCS.Optimizer, "eps_abs" => 1e-5);
silent_solver = true
)
return problem.optval
end