Hi community,
I want to minimize tr(S^{-1}) + tr((A - S)^{-1}) such that S \succeq 0 and A - S \succeq 0 (S is the optimization matrix, A is some fixed positive definite matrix)
I tried using JuMP + Hypatia:
using Hypatia, JuMP
p = 5
x = randn(p, p)
A = Symmetric(x' * x)
# model and constraints constraints
model = Model(() -> Hypatia.Optimizer())
@variable(model, S[1:p, 1:p], Symmetric)
@constraint(model, S in PSDCone())
@constraint(model, A - S in PSDCone())
# objective
@NLobjective(model, Min, tr(inv(S)) + tr(inv(A - S)))
# solve and return
JuMP.optimize!(model)
which gives me the following error:
Unexpected array VariableRef[S[1,1] S[1,2] S[1,3] S[1,4] S[1,5]; S[1,2] S[2,2] S[2,3] S[2,4] S[2,5]; S[1,3] S[2,3] S[3,3] S[3,4] S[3,5]; S[1,4] S[2,4] S[3,4] S[4,4] S[4,5]; S[1,5] S[2,5] S[3,5] S[4,5] S[5,5]] in nonlinear expression. Nonlinear expressions may contain only scalar expressions.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] parse_expression(#unused#::MathOptInterface.Nonlinear.Model, expr::MathOptInterface.Nonlinear.Expression, x::Symmetric{VariableRef, Matrix{VariableRef}}, parent_index::Int64)
@ MathOptInterface.Nonlinear ~/.julia/packages/MathOptInterface/cl3eR/src/Nonlinear/parse.jl:235
[3] parse_expression(data::MathOptInterface.Nonlinear.Model, expr::MathOptInterface.Nonlinear.Expression, x::Expr, parent_index::Int64)
@ MathOptInterface.Nonlinear ~/.julia/packages/MathOptInterface/cl3eR/src/Nonlinear/parse.jl:52
[4] parse_expression
@ ~/.julia/packages/MathOptInterface/cl3eR/src/Nonlinear/parse.jl:14 [inlined]
[5] set_objective
@ ~/.julia/packages/MathOptInterface/cl3eR/src/Nonlinear/model.jl:43 [inlined]
[6] set_nonlinear_objective(model::Model, sense::MathOptInterface.OptimizationSense, x::Expr)
@ JuMP ~/.julia/packages/JuMP/puvTM/src/nlp.jl:163
[7] macro expansion
@ ~/.julia/packages/JuMP/puvTM/src/macros.jl:2332 [inlined]
[8] top-level scope
@ In[4]:12
[9] eval
@ ./boot.jl:373 [inlined]
[10] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
I also tried to define some variable t such that t \ge tr(S^{-1}), but there I get a no method matching VariableRef(::AffExpr)
error.
Seems like CVX supports trace_inv
, is there a similar alternative in JuMP or Convex.jl? I couldn’t find one.
Any help is highly appreciated.