Convex optimisation over complex variables

Hello Everyone, I’ve just installed Julia and Convex.jl (package for convex optimisation) and things work fine as long as my variables are real, e.g.

using Convex
using SCS
x = Variable()

And then I can optimise. However, I want to deal with complex variables. According to http://convexjl.readthedocs.io/en/latest/complex-domain_optimization.html

this should just work if I type

x = ComplexVariable()

Unfortunately, what I get is:

ERROR: UndefVarError: ComplexVariable not defined

I guess I must be missing a package or something… Could anyone help me to figure this out? Thanks a lot.

In case this matters:

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753* (2016-09-19 18:14 UTC)
Platform Info:
System: Linux (x86_64-suse-linux)
CPU: Intel(R) Core™ i3-2350M CPU @ 2.30GHz
WORD_SIZE: 64
BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas_openmp.so.0
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, sandybridge)

julia> Pkg.installed()
Dict{String,VersionNumber} with 24 entries:
“NaNMath” => v"0.2.2"
“ForwardDiff” => v"0.3.3"
“Optim” => v"0.7.4"
“JuMP” => v"0.15.0"
“Conda” => v"0.4.0"
“LineSearches” => v"0.1.3"
“DiffBase” => v"0.0.2"
“SHA” => v"0.3.0"
“Lazy” => v"0.11.4"
“ReverseDiffSparse” => v"0.6.0"
“ZMQ” => v"0.4.0"
“JSON” => v"0.8.0"
“DataStructures” => v"0.5.1"
“Compat” => v"0.11.0"
“IJulia” => v"1.3.3"
“SCS” => v"0.2.7"
“Calculus” => v"0.1.15"
“MathProgBase” => v"0.5.8"
“MacroTools” => v"0.3.4"
“BinDeps” => v"0.4.5"
“Convex” => v"0.4.0"
“PositiveFactorizations” => v"0.0.3"
“Nettle” => v"0.2.4"
“URIParser” => v"0.1.6"

I don’t think your Convex is new enough. The docs you are linking to are “latest”, and in the docs for 0.4.0, this feature isn’t available. It doesn’t look like there is a release that supports this, but you can checkout the master version to try it.

2 Likes

Great, thanks a lot :slight_smile: !
Pulling the master branch did the trick. Below a small working example with complex variables:

using Convex
using SCS
X = [0 1; 1 0]
Y = [0 -im; im 0]
Z = [1 0; 0 -1]
rho = ComplexVariable(2, 2)
prob = maximize(real(trace(rho * X)))
prob.constraints += [rho in :SDP]
prob.constraints += [trace(rho) == 1]
prob.constraints += [trace(rho * Y) == 1/sqrt(2)]
prob.constraints += [trace(rho * Z) == 0.5]
solve!(prob, SCSSolver(verbose=0))

@Jedrek I am glad that you got your problem solved. Do let us know how you are using Convex.jl. We are trying to keep the record of the people who are using Convex.jl in their work.

Also, support for complex numbers is in it’s initial stages. Any pull request regarding it’s application would be appreciated :slight_smile: