Skip to content

Commit

Permalink
Add simple example; mention trace distance
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson committed Sep 17, 2019
1 parent cb68fd5 commit 1cc203b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://ericphanson.github.io/SDPAFamily.jl/stable)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://ericphanson.github.io/SDPAFamily.jl/dev)


An interface to using SDPA-GMP, SDPA-DD, and SDPA-QD in Julia (<http://sdpa.sourceforge.net>). Call `SDPAFamily.Optimizer()` to use this wrapper via `MathOptInterface`, which is an intermediate layer between low-level solvers (such as SDPA-GMP, SDPA-QD, and SDPA-DD) and high level modelling languages, such as [JuMP.jl](https://github.com/JuliaOpt/JuMP.jl) and [Convex.jl](https://github.com/JuliaOpt/Convex.jl/).

JuMP currently only supports `Float64` numeric types, which means that problems can only be specified to 64-bits of precision, and results can only be recovered at that level of precision, when using JuMP. This is tracked in the issue [JuMP#2025](https://github.com/JuliaOpt/JuMP.jl/issues/2025).
Expand All @@ -18,8 +17,17 @@ Convex.jl does not yet officially support MathOptInterface; this issue is tracke

which can be used to solve problems with the solvers from this package.

## Quick Example

Here is a simple optimization problem formulated with Convex.jl:

### Quick Example
```julia
using SDPAFamily, LinearAlgebra
using Convex # ] add https://github.com/ericphanson/Convex.jl#MathOptInterface
y = Semidefinite(3)
p = maximize(lambdamin(y), tr(y) <= 5; numeric_type = BigFloat)
solve!(p, SDPAFamily.Optimizer(presolve=true))
@show p.optval
```

[todo]
See the documentation linked above for troubleshooting help and usage information.
17 changes: 14 additions & 3 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# Examples

## Optimal guessing probability for a pair of quantum states

```@setup 1
# This setup block is not shown in the final output
# Install the right branch of Convex
using Pkg
Pkg.add(PackageSpec(name="Convex", url="https://github.com/ericphanson/Convex.jl", rev="MathOptInterface"));
```

Here is a simple optimization problem formulated with Convex.jl:

```@example 1
using SDPAFamily, LinearAlgebra
using Convex # ] add https://github.com/ericphanson/Convex.jl#MathOptInterface
y = Semidefinite(3)
p = maximize(lambdamin(y), tr(y) <= 5; numeric_type = BigFloat)
solve!(p, SDPAFamily.Optimizer(presolve=true))
@show p.optval
```

## Optimal guessing probability for a pair of quantum states

In physics, a *state* represents a possible configuration of a physical system. In quantum mechanical systems with finitely many degrees of freedom, states are represented by *density matrices*, which are $d\times d$ matrices with complex entries that are positive semi-definite and have trace equal to one. States can be *measured*; mathematically, a measurement with $n$ possible outcomes is represented by a set of measurement operators $\{E_j\}_{j=1}^n$, where each $E_j$ is a $d\times d$ matrix. For example, imagine an experiment in which a charged particle is released in a magnetic field such that it will hit either a detector on the left or a detector on the right. This corresponds to a measurement of the particle with two outcomes, and hence two measurement operators $\{E_1, E_2\}$, which to the left and right detector.

In order for $\{E_j\}_{j=1}^n$ to be a valid set of measurement operators, each $E_j$ must be positive semi-definite, and the family $\{E_j\}_{j=1}^n$ must have the property that $\sum_{j=1}^n E_j = I_d$, the $d\times d$ identity matrix. If the state of the system is represented by $\rho$, and a measurement with measurement operators $\{E_j\}_{j=1}^n$ is performed, then outcome $j$ is obtained with probability $\operatorname{tr}[\rho E_j]$.
Expand All @@ -23,7 +34,7 @@ p_\text{guess}(E_1, E_2) = \frac{1}{2}\operatorname{tr}(\rho_1 E_1) + \frac{1}{

since there is a 50% chance of the system being in state $\rho_1$, in which case we guess correctly when we get outcome 1 (which occurs with probability $\operatorname{tr}(\rho_1 E_1)$), and a 50% chance of the system being in state $\rho_2$, in which case we guess correctly when we get outcome $2$.

Our goal now is to choose the optimal measurement operators to have the the best chance of guessing correctly. That is, we aim to maximize the above expression over all choices of $E_1$ and $E_2$ such that $\{E_1, E_2\}$ is a valid set of measurement operators. This is a semidefinite program, which can be solved e.g. with SDPAFamily.jl In this simple example, the problem can be solved analytically; in fact, this problem is Example 3.2.1 of the [edX Quantum Cryptography notes by Thomas Vidick](http://users.cms.caltech.edu/~vidick/teaching/120_qcrypto/LN_Week3.pdf), from which it can be seen that the correct answer is
Our goal now is to choose the optimal measurement operators to have the the best chance of guessing correctly. That is, we aim to maximize the above expression over all choices of $E_1$ and $E_2$ such that $\{E_1, E_2\}$ is a valid set of measurement operators. This is a semidefinite program, which can be solved e.g. with SDPAFamily.jl In this simple example with only two states to discriminate between, the problem can be solved analytically, and the solution is related to the trace distance between the two states. This problem specifically is Example 3.2.1 of the [edX Quantum Cryptography notes by Thomas Vidick](http://users.cms.caltech.edu/~vidick/teaching/120_qcrypto/LN_Week3.pdf). It can be seen that the optimal guessing probability is

```math
p_\text{guess} = \frac{1}{2} + \frac{1}{2 \sqrt{2}}
Expand Down

0 comments on commit 1cc203b

Please sign in to comment.