How to formulate a complex JuMP variable array


I would like to create a complex jump array variable and I have been looking through the documentation for awhile and things are still not clear.

Lets say for a trivial example I want to minimize the trace of a DxD complex array. I might create something like:

using Ipopt
using LinearAlgebra
using JuMP

model = Model(with_optimizer(Ipopt.Optimizer))

function E(x::Vector)

     F = reshape(Complex.(x[1:2:2*D^2-1],x[2:2:2*D^2]),D,D)

     return e = tr(F)

F = @variable(model)
@objective(model, Min, e)


How would I reformat this to be correct?


Please search discourse for existing issues. This question has been asked.

JuMP cannot handle complex variables. You need to add two variables: one for the real and one for the imaginary part.

1 Like

Okay thank you, I’m sorry I didn’t see that.


No worries! Good luck.