Minimize Multiple norms using JuMP

Hi,

I need to minimize an objective function that has multiple norms in it.
Here is a minimal example:
A is a variable of dimension d by n.
x is a known constant matrix of dimension n by 1 and b_t (dimension d by 1) is the data gathered with iterations. A0 is a known constant matrix of dimension d by n
The objective function is: Σ_{s=1}^{t}norm(A*x-b_t)^2+norm(A-A0)^2. Σ_{s=1}^{t} means sum from s =1 to s = t.
Suppose t is 3 and we know b_1,b_2,b_3.
We need the find the A that minimizes the objective function.
How should we construct the model using JuMP?
Here is the code i have:

using Ipopt
using JuMP
model = Model(Ipopt.Optimizer)
@variable(model, A[1:d, 1:n])
objective = 0.0
for s = 1:t
    objective = objective + norm(A*x-b[t])^2+norm(A-A0)^2
end
@NLobjective(model, Min, objective)
JuMP.optimize!(model)

You can add second order cone constraints as

model = Model()
@variable(model, t)
@variable(model, x[1:4])
@constraint(model, [t; x] in SecondOrderCone())

If you want the squared norm, you can just write out

d = 2
n = 3
T = 2
x = rand(n)
b = [rand(d) for t = 1:2]
A0 = rand(d, n)
model = Model()
@variable(model, A[1:d, 1:n])
@objective(
    model, 
    Min, 
    sum(sum((A * x .- b[t]).^2) for t = 1:T) + sum((A .- A0).^2),
)
2 Likes