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

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; silent_solver = true)
evaluate(U)
20×20 Matrix{ComplexF64}:
        1.0+1.17772e-18im  …  -0.504648-0.863327im
   0.162026+0.986788im         0.770152-0.63786im
  -0.882302+0.470687im         0.851607+0.524182im
   0.501735+0.865023im         0.493597-0.869691im
   0.915661+0.401953im        -0.115069-0.993357im
   0.140736+0.990048im     …   0.783711-0.621126im
 -0.0639068+0.997957im         0.893811-0.448444im
  -0.834062+0.551672im         0.897179+0.441667im
   0.975719-0.219034im        -0.681491-0.731827im
   -0.80756+0.589788im         0.916711+0.399552im
   0.944061+0.329774im     …  -0.191715-0.981451im
  -0.745915+0.666042im         0.951434+0.307851im
 -0.0858896+0.996306im          0.90348-0.428632im
   0.767064+0.641572im         0.166788-0.985992im
  -0.614321+0.789057im         0.991228+0.132164im
  -0.336963+0.941519im     …   0.982884-0.184226im
   0.725339+0.688394im         0.228267-0.973599im
  -0.269198+0.963086im         0.967306-0.253613im
   0.988531+0.151026im        -0.368474-0.929638im
  -0.504648+0.863327im              1.0-1.28089e-17im

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)])
1

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])
end
u
20-element Vector{ComplexF64}:
                  1.0 + 0.0im
 -0.09321751711582545 - 0.9956457675814028im
   0.8914006935215294 - 0.45321606722327956im
 -0.40944623481712145 - 0.9123342483947879im
   -0.912617502490476 - 0.4088144984562632im
  -0.3281693267280607 - 0.9446189141631939im
 -0.06195667104760572 - 0.9980788400285314im
   0.8346404781698487 - 0.5507951272482412im
  -0.9757316730960294 + 0.21896963743227818im
   0.8440476661488214 - 0.5362681579850959im
   -0.933226412715302 - 0.3592888289531539im
     0.78794248072546 - 0.6157488506430265im
  0.14870221819473498 - 0.9888820204169784im
   0.6972905025777185 + 0.716788640405882im
   0.5173854676178119 - 0.8557524629809126im
 -0.23573643437927766 + 0.9718170267628287im
   -0.888067446002504 - 0.45971318379027337im
  0.26481592948305865 - 0.9642989803437644im
  -0.9838104234262074 - 0.17921230637974223im
   0.5374892984782067 - 0.8432705698774298im

This page was generated using Literate.jl.