# Issue with ConvexOptimization over Matrices with Mathematica 12.2

With Mathematica 12.2, ConvexOptimization was introduced, which, as its name suggests, can solve arbitrary convex optimization problems over matrices [Language Reference]. Using ConvexOptimization can help me get around reformulating my problem into SemidefiniteOptimization, a step that is cumbersome but otherwise works fine.

Hence, to get started, I'm attempting to solve a trial optimization problem with ConvexOptimization.

The following code works as intended.

A = RandomVariate[NormalDistribution[], {4, 4}]
ConvexOptimization[-Log[Det[A.X.Transpose[A]]], {Tr[X] <= 1, VectorGreaterEqual[{X,  0}, {"SemidefiniteCone", 4}]}, {X \[Element] Matrices[{4, 4}, Complexes]}]


However, when I replace the objective function -Log[Det[A.X.Transpose[A]]] with -Log[Det[IdentityMatrix + A.X.Transpose[A]]] to obtain the following optimization problem:

A = RandomVariate[NormalDistribution[], {4, 4}]
ConvexOptimization[-Log[Det[IdentityMatrix + A.X.Transpose[A]]], {Tr[X] <= 1, VectorGreaterEqual[{X,  0}, {"SemidefiniteCone", 4}]}, {X \[Element] Matrices[{4, 4}, Complexes]}]


and evaluate it, Mathematica produces the following error: The argument [...] should not be scalar valued.

I interpret the resulting stack trace on my PC to mean that Mathematica is likely (erroneously) considering the argument to Det a scalar. However, I'm stuck with debugging here.

Would anyone know what might be going wrong? Any suggestions for solving the second optimization problem with ConvexOptimization will be very helpful.

(Too long for a comment)

The basic issue is that evaluating Plus does automatic threading when given an explicit matrix (for example, IdentityMatrix + expr).

One way to work around the threading behavior for this particular case would be something like

A = RandomVariate[NormalDistribution[], {4, 4}];

ConvexOptimization[-Log[Det[B + A . X . Transpose[A]]],
{Tr[X] <= 1, VectorGreaterEqual[{X, 0}, {"SemidefiniteCone", 4}],
B == IdentityMatrix},
{X \[Element] Matrices[{4, 4}, Complexes], B \[Element] Matrices[{4, 4}]}]


The above will work in the currently released versions. In a future release, it will be possible to take the more general approach of using Inactive[Plus], that is

ConvexOptimization[
-Log[Det[Inactive[Plus][IdentityMatrix, A . X . Transpose[A]]]], ...}

• It's too bad Inactive[Plus][IdentityMatrix, -Log[Det[B + A . X . Transpose[A]]]] didn't work. Oct 21, 2021 at 19:12
• Right, I think this may be improved. Oct 21, 2021 at 19:23
• Thank you for the explanation; the provided workaround solves the posted problem. I will update this Q&A once this problem is completely resolved by Mathematica. Oct 22, 2021 at 8:42