How to formulate this in CVX?

Hi all,
I have n matrices (p\times p) as variables that need to be PSD and I need to minimize this objective function over the matrices A_i.
S_i is known and \lambda is the regularizer. Thanks

minimize \sum_{i=1}^n (-\log\det A_i + trace(S_i A_i) ) + \lambda \sum_{i=1}^ n \|A_i\|_1

Have you tried reading the CVX User’s Guide? You can specify this in CVX almost exactly as written. Declare all your Ai to be psd. Use log_det for log det. You can specify 1 norm. You can sum all the terms and use that for your objective function, and you’re done. I would note that although you can solve this as one optimization problem as written, you appear to have n uncoupled problems, so alternatively you could formulate and solve your n problems separately.

How to define n p by p matrices?

Yes, it would have helped if you had been more specific about where you were stuck. I would declare them this way:

variable A(p,p,n) symmetric

Then your objective will need a for loop.

The OP said that the Ai are psd, so should have

variable A(p,p,n) semidefinite

instead of

variable A(p,p,n) symmetric

which eliminates the need for the additional line

A == semidefinite([p,p,n])

See mcg’s answer in Creating Dynamic Variables with Constraints (avoid for loop) .

Ah, but there is no need for the semidefinite constraint here, as log_det will include it.

Good point, but subtle enough that it would have warranted pointing out in your1st post of this thread.

But actually, log_det also constrains its argument to be symmetric, so it would seem that specifying symmetric wouldn’t be needed either, unless it is somehow needed due to the extra (3rd) dimension on A.

Due to the other terms in the objective I would not trust CVX to eliminate all of the redundancies if you didn’t declare A to be symmetric.

Thanks everyone. It was helpful.