How to define matrix objectives in JuMP models

Hi,
How do I declare a matrix objective in JuMP? That is, how do I declare @objective(m, Min, ⋅ ) with a matrix?

Thank you for any help.

Details

I am trying to translate the Python code below to Julia. However, the following piece of Julia code returns ERROR: MethodError: no method matching *(::LinearAlgebra.Adjoint{Int64,Array{Int64,1}}, ::VariableRef). What

Julia

using JuMP
using DSDP

obj_vec = [0; 1; 2]
m = Model(with_optimizer(DSDP.Optimizer))
@variable(m, X)
@objective(m, Min, obj_vec'*X)

Python

from cvxopt import matrix, solvers

obj_vec = matrix(range(3), (3, 1), 'd')
__sym_grams = [[0, 0, -0.5, 0, 0, 1, 0, 0, -0.5, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, -0.5, 0, 0, 1, 0, 0, -0.5, 0, 0]]
sym_grams = matrix(__sym_grams)
Gs = [-sym_grams]
hs = [matrix([[10, 10, -1.50, 0],
              [10, 0, 0, 0.5],
              [-1.50, 0, 0, 0],
              [0, 0.5, 0, 100]])]

sol = solvers.sdp(c=obj_vec, Gs=Gs, hs=hs, solver='dsdp')
print(sol) # {'status': 'optimal', 'x': <3x1 matrix, tc='d'>, 'sl': <0x1 matrix, tc='d'>, 'ss': [<4x4 matrix, tc='d'>], 'y': <0x1 matrix, tc='d'>, 'zl': <0x1 matrix, tc='d'>, 'zs': [<4x4 matrix, tc='d'>], 'primal objective': 2.8327595103035703, 'dual objective': 2.832759388228712, 'gap': 1.221152672314929e-07, 'relative gap': 4.310823846844613e-08, 'primal infeasibility': 0.0, 'dual infeasibility': 1.7091586164057182e-12, 'residual as primal infeasibility certificate': None, 'residual as dual infeasibility certificate': None, 'primal slack': 5.425580955940478e-09, 'dual slack': 2.857198533975067e-10}

@variable(m, X) declares a scalar valued variable.
To declare a vector of variables, use @variable(model, x[1:3]).

You probably want something like:

c = [0, 1, 2]
Gs = [
    0 0 -0.5  0 0 1 0    0 -0.5 0 0 0  0    0 0 0;
    0 0    0 -1 0 0 1    0    0 1 0 0 -1    0 0 0;
    0 0    0  0 0 0 0 -0.5    0 0 1 0  0 -0.5 0 0;
]

Hs = [
      10  10 -1.5   0;
      10   0    0 0.5;
    -1.5   0    0   0;
       0 0.5    0 100
]

using JuMP, SCS
model = Model(with_optimizer(SCS.Optimizer))
@variable(model, x[1:3])
@variable(model, s[1:4, 1:4], PSD)
@objective(model, Min, c' * x)
@constraint(model, -Gs' * x + vec(s) .== vec(Hs))
optimize!(model)
objective_value(model)

Here’s the JuMP documentation. It’s a good place to start reading: https://www.juliaopt.org/JuMP.jl/v0.20.0/quickstart/