# How to include PSD constraint in TFOCS

Hi there!

I’m solving \min_{\mathbf{B}\succeq 0} \text{Trace}(\mathbf{B}) subject to \|\mathcal{A}(\mathbf{B}) - \mathbf{y}\|_2 \leq \epsilon where \mathcal{A}:\mathbb{R}^{L\times L} \to \mathbb{R}^m is a linear operator, \mathbf{B}\in \mathbb{R}^{L\times L} is a matrix, and \mathbf{y}\in \mathbb{R}^m is a vector.

I wrote a functioning programme using tfocs_scd for this problem without the PSD constraint, but didn’t know how to include the PSD constraint. Could you please advise me on this?

Many thanks,
Shirley

Do you really wish to use TFCOs as opposed to CVX?

Unfortunately, I don;t believe any of the TFOCS developers are still active on this forum, and doubt there are many or any advanced users of TFOCS still active here. So you may have to figure things out on your own.

Nevertheless, a quick search shows these 2 posts from @Stephen_Becker one of the TFOCS developers, which might help you.

You can also see all posts on this forum categorized as TFOCS at http://ask.cvxr.com/c/tfocs/6 .

Thanks Mark. I’m going through these posts now. CVX works but it’s extremely slow, so my colleagues have advised that I try TFOCS. Is there any way that I can speed up CVX?

You haven’t shown us the PSD constraint (so I don;t know whether there is an opportunity to speed up things in the CVX formulation. But if your CVX code doesn’t have any for loops, there likely isn’t much or any opportunity to speed up the problem formulation by improved coding. But dualizing the problem might potentially speed up the solver (or could slow it down). If you need to solve a structurally same problem many times, but with different input data, then you can reduce problem formulation time by using YALMIP with its optimizer capability.

Here’s my code for the problem above:

cvx_begin quiet
variable B(L, L) semidefinite % a real symmetric PSD matrix
minimize(trace(B))
subject to
norm(bahmani_Woperator(B, W) - y, 2) <= epsilon
cvx_end
Did you mean that I should use YALMIP instead of CVX?

Thanks,
Shirley

bahmani_Woperator is a linear operator which I coded up in a separate script.

Don;t use quiet. That way you will see the solver and CVX output.
Is CVX formulation taking too long, or the solver once it starts taking too long? What are the problem dimensions?

I presume the mysterious bahmani_Woperator function is an affine function of its first argument?
If you re-run withoutquiet’, and post the CVX and solver output, maybe one of the forum readers can provide an assessment.

Hi Mark, I think I figured out how to use TFOCS for this problem! Instead of using prox_nuclear as my objective function, I should use prox_trace to impose the PSD constraint. This is because the proximity operator of trace is a combination of the proximity operator of trace and the indicator set of positive semi-definite matrices. So we do not need to explicitly include the positive semi-definite constraint.

Thanks for your help! - Shirley

Great. Please let us know the speed comparison on pertinent problem sizes.

I trust you will compare optimal objective values between TFOCS and CVX (perhaps TFOCS default solver tolerance is not as tight as CVX)), and verify that TFOCS solutions satisfy all intended constraints to within feasibility tolerance.