Thomas
1
Does anyone know why? Thanks!
using LinearAlgebra, Convex, MosekTools
rho = HermitianSemidefinite(4)
add_constraint!(rho, tr(rho) == 1)
p = satisfy(tr(rho) == 1)
solve!(p, Mosek.Optimizer)
p.status
rho_opt = round.(evaluate(rho))
tr(rho_opt) # should be 1
eigen(rho_opt)
round
rounds to the nearest integer, so you’re just rounding rho
away to the zero matrix. With SCS (I do not have a Mosek license), I get
julia> evaluate(rho)
4×4 Matrix{ComplexF64}:
0.25+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.25+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.25+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.25+0.0im
julia> tr(evaluate(rho))
0.999999966223076 + 0.0im
Thomas
3
Thank you. What an embarrassing mistake.
No worries! I’ve certainly made simpler mistakes