Frobenius Norm objective with JuMP

I am looking to use the frobenius norm of a matrix as an objective. Here is the setup:

nkrauss = 4

model = Model(Ipopt.Optimizer)

# Krauss operator variables
nKelems = nkrauss * dims^2
Kelems = [@variable(model, set = ComplexPlane()) for i in 1:nKelems]
Ks = reshape(Kelems, (dims, dims, nkrauss))

constraints = [@constraint(model, K' * K .== I) for K in eachslice(Ks, dims=3)]

approx = sum(Array([K * r * K' for K in eachslice(Ks, dims=3)]))

@NLobjective(model, Min, sum((approx - rprime) .^ 2))

I see the following error:

ERROR: Unrecognized function “.^” used in nonlinear expression.

Where am I going wrong? Is there a better way to implement a Frobenius norm objective?

Thank you!

The ComplexPlane support in JuMP is very new, and it doesn’t work well with the nonlinear objective functions, and the nonlinear interface doesn’t support vector-valued expressions. (We’re working one improving this though.) In the near term, you’ll have to write out the scalar version of the norm:

model = Model()
A = [@variable(model, set = ComplexPlane()) for i in 1:2, j in 1:2]
# @NLobjective(model, Min, sqrt(sum(abs2(A[i, j]) for i in 1:2, j in 1:2)))
# since sqrt is monotonic, equivalent to:
@NLobjective(model, Min, sum(abs2(A[i, j]) for i in 1:2, j in 1:2))

Makes sense, thanks for the reply!

1 Like