All of the examples can be found in Jupyter notebook form here.

Phase recovery using MaxCut

In this example, we relax the phase retrieval problem similar to the classical MaxCut semidefinite program and recover the phase of the signal given the magnitude of the linear measurements.

Phase recovery has wide applications such as in X-ray and crystallography imaging, diffraction imaging or microscopy and audio signal processing. In all these applications, the detectors cannot measure the phase of the incoming wave and only record its amplitude i.e complex measurements of a signal $x \in \mathbb{C}^p$ are obtained from a linear injective operator $A$, but we can only measure the magnitude vector $Ax$, not the phase of $Ax$.

Recovering the phase of $Ax$ from $|Ax|$ is a nonconvex optimization problem. Using results from this paper, the problem can be relaxed to a (complex) semidefinite program (complex SDP).

The original reprsentation of the problem is as follows:

\[\begin{array}{ll} \text{find} & x \in \mathbb{C}^p \\ \text{subject to} & |Ax| = b \end{array}\]

where $A \in \mathbb{C}^{n \times p}$ and $b \in \mathbb{R}^n$.

In this example, the problem is to find the phase of $Ax$ given the value $|Ax|$. Given a linear operator $A$ and a vector $b= |Ax|$ of measured amplitudes, in the noiseless case, we can write $Ax = \text{diag}(b)u$ where $u \in \mathbb{C}^n$ is a phase vector, satisfying $|\mathbb{u}_i| = 1$ for $i = 1,\ldots, n$.

We relax this problem as Complex Semidefinite Programming.

Relaxed Problem similar to MaxCut

Define the positive semidefinite hermitian matrix $M = \text{diag}(b) (I - A A^*) \text{diag}(b)$. The problem is:

\[\begin{array}{ll} \text{minimize} & \langle U, M \rangle \\ \text{subject to} & \text{diag}(U) = 1\\ & U \succeq 0 \end{array}\]

Here the variable $U$ must be hermitian ($U \in \mathbb{H}_n $), and we have a solution to the phase recovery problem if $U = u u^*$ has rank one. Otherwise, the leading singular vector of $U$ can be used to approximate the solution.

using Convex, SCS, LinearAlgebra
if VERSION < v"1.2.0-DEV.0"
    (I::UniformScaling)(n::Integer) = Diagonal(fill(I.λ, n))
     LinearAlgebra.diagm(v::AbstractVector) = diagm(0 => v)

n = 20
p = 2
A = rand(n,p) + im*randn(n,p)
x = rand(p) + im*randn(p)
b = abs.(A*x) + rand(n)

M = diagm(b)*(I(n)-A*A')*diagm(b)
U = ComplexVariable(n,n)
objective = inner_product(U,M)
c1 = diag(U) == 1
c2 = U in :SDP
p = minimize(objective,c1,c2)
solve!(p, () -> SCS.Optimizer(verbose=0))
20×20 Array{Complex{Float64},2}:
       1.0+5.46652e-9im    0.956308-0.292362im    …  -0.998328-0.0578206im 
  0.956308+0.292362im           1.0+3.43146e-9im     -0.937804-0.347168im  
  0.594865+0.803826im      0.803883+0.594789im       -0.547392-0.836877im  
  0.482367+0.87597im       0.717392+0.696671im       -0.430911-0.902395im  
  0.990596+0.136828im      0.987318-0.158763im       -0.981027-0.193876im  
 -0.767394+0.641177im     -0.546409+0.83752im     …   0.803183-0.595734im  
 -0.360777+0.932653im    -0.0723418+0.997381im          0.4141-0.910232im  
 -0.934116+0.356972im     -0.788937+0.614475im        0.953194-0.302363im  
  0.958387-0.285476im       0.83305-0.553199im        -0.97329+0.229584im  
  0.984728+0.174104im      0.992604-0.121401im       -0.973014-0.23075im   
 -0.971015+0.239022im     -0.858708+0.512467im    …   0.983211-0.182478im  
  0.764413+0.644728im      0.919508+0.393073im       -0.725856-0.687848im  
 -0.368794+0.929512im    -0.0809259+0.996721im        0.421921-0.906633im  
  0.982542+0.186044im      0.994005-0.109343im       -0.970141-0.242544im  
  0.999265-0.0383639im     0.944388-0.328835im       -0.999811-0.0194783im 
 -0.543259+0.839566im     -0.274066+0.961712im    …   0.590894-0.80675im   
 -0.793749+0.608247im     -0.581239+0.813734im         0.82759-0.561335im  
  0.962797+0.270228im      0.999735-0.0230644im      -0.945562-0.325445im  
  0.915074+0.403287im      0.992999+0.118133im       -0.890225-0.455522im  
 -0.998328+0.0578206im    -0.937804+0.347168im             1.0-1.10663e-8im

Verify if the rank of $U$ is 1:

B, C = eigen(evaluate(U));
length([e for e in B if(abs(real(e))>1e-4)])

Decompose $U = uu^*$ where $u$ is the phase of $Ax$

u = C[:,1];
for i in 1:n
    u[i] = u[i]/abs(u[i])
20-element Array{Complex{Float64},1}:
   0.9563076689513763 - 0.2923621765974264im  
                  1.0 + 0.0im                 
   0.8038820913899796 + 0.5947886878064111im  
   0.7173911156477751 + 0.6966706447021006im  
   0.9873166954152198 - 0.15876316623943415im 
   -0.546408144611337 + 0.8375190382925013im  
 -0.07234175335730267 + 0.997379902906205im   
  -0.7889366523570753 + 0.6144745385836677im  
    0.833049692760444 - 0.5531981646677164im  
    0.992603601394243 - 0.12140053747483519im 
  -0.8587073038644084 + 0.5124663562517237im  
   0.9195074932820849 + 0.39307247397661527im 
 -0.08092580588241265 + 0.9967201281916014im  
   0.9940041263645314 - 0.10934256614093428im 
    0.944387537387439 - 0.3288345772988124im  
   -0.274065318860866 + 0.9617110797935583im  
  -0.5812388036098962 + 0.8137330355701042im  
   0.9997339815195978 - 0.023064392360791712im
   0.9929977710909638 + 0.11813308854160184im 
  -0.9378032303573409 + 0.34716725238901264im 

This page was generated using Literate.jl.