How to invert variables in the objective of an optimization model

The optimization problem is:
minimize log detP^−1
subject to ||Pu+ buro||\2≤ 1,
where P is a semidefinite matrix, buro is Variable, u is known.
The code is:

using Convex, SCS, LinearAlgebra
if VERSION < v"1.2.0-DEV.0"
     LinearAlgebra.diagm(v::AbstractVector) = diagm(0 => v)
end

    u=rand(3,1)
    buro=Variable(3,1)
    P = Semidefinite(3)#定义一个半正定矩阵
    objective = logdet(inv(P))
    problem = minimize(objective,norm(P*u+buro)<=1)
    solve!(problem, () -> SCS.Optimizer())
    computed_fidelity = evaluate(objective)
    value_P = evaluate(P)

But error happen in objective = logdet(inv(P)):
ERROR: LoadError: MethodError: no method matching inv(::Variable)
Closest candidates are:
inv(::Missing) at missing.jl:100
inv(::Complex{Float64}) at complex.jl:439
inv(::BigFloat) at mpfr.jl:464

Stacktrace:
[1] top-level scope at untitled-36f70f3d81c9a751a6967ac32d0812fd:9
[2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088
in expression starting at untitled-36f70f3d81c9a751a6967ac32d0812fd:9

How could I modify it?
Thank you very much in advance!

1 Like

\log(\det(A^{-1})) = \log(\frac{1}{\det(A)}) = -\log(\det(A)) :slight_smile:

3 Likes

thank you~

1 Like