<p>The new SDP that you obtain by replacing minimize by maximize is not necessarily closely related to the first one. Right now the value is infinity, and if you replaced 0 by $Q_a$ on the right side of the constraint, the value is always going to be 0 or infinity (if it's not 0, you can just multiply any solution with positive value by an arbitrary constant, and increase the value).</p>

<p>The way I went about this general issue when solving these SDPs was just implementing the partial trace, and then coding the dual and primal problem separately. The implementation of the partial trace is at <a href="https://cs.uwaterloo.ca/~amolinap/prtrace.m">https://cs.uwaterloo.ca/~amolinap/prtrace.m</a>, hope it is useful!</p>

CC BY-SA 3.0
2012-10-15T13:47:17.973Z
Thanks very much for the swift reply, Abel! That clears up my question very well. Thanks again!
Vincent Russo
CC BY-SA 4.0
2021-04-24T18:51:58.863Z
Hi Abel, did you by any chance saved the m file somewhere else? The original link is no longer functional. Thanks!
Bohan  Lu
CC BY-SA 4.0
2021-07-20T01:54:41.090Z
Hi, sorry for the late reply. I recommend that you use more modern approaches like QETLAB instead, and I cannot guarantee that it will work, but I think this might be it: https://pastebin.com/FUeL2wW8
Abel Molina
CC BY-SA 3.0
2012-10-15T01:41:52.683Z
2012-10-15T01:41:52.683Z
Abel Molina
<p>I'm attempting to formulate the semidefinite programs used in the paper "<a href="http://arxiv.org/abs/1104.1140" rel="nofollow">Hedging Bets with Correlated Quantum Strategies</a>" (specifically those on page 7) into <a href="http://orion.math.uwaterloo.ca/~hwolkowi/henry/teaching/w11/367.w11/367miscfiles/cvx_usrguide.pdf" rel="nofollow">CVX</a> so that I can play around with the values of the SDPs. The CVX package seems to be very straightforward to get up and running, but I'm a bit unsure in how to convert the SDPs in this scenario and how to interpret the results. For completeness and to try to be a bit helpful, the primal and dual problems for the maximization constraint are replicated from the paper below.  </p>

<p><strong>Primal Problem:</strong> </p>

<p>maximize: $\langle Q_a, X \rangle$</p>

<p>subject to: $Tr_{\mathcal{Y}}(X) = \mathcal{I}_{\mathcal{X}},$</p>

<p>$\qquad \qquad X \in Pos(\mathcal{Y} \otimes \mathcal{X})$</p>

<p><strong>Dual Problem:</strong></p>

<p>minimize: $Tr(Y)$</p>

<p>subject to: $\mathcal{I}_{\mathcal{Y}} \otimes Y \geq Q_a,$</p>

<p>$\qquad \qquad Y \in Herm(\mathcal{X})$</p>

<p>In this case, these are the SDPs which correspond to Bob's maximum probability for winning some quantum protocol between two parties (more information is in the paper, but if you're going to take the time to help me, by all means ask if I can clarify something in a bit more detail). The variables $Q_a$ and $X$ correspond to the Choi-Jamiolkowski representation of the channel for Alice and Bob respectively. My attempt at putting this into MATLAB is as follows:</p>

<pre><code>n = 3;
cvx_begin sdp
    variable Y(n,n) hermitian;
    dual variable X;
    maximize ( trace ( Y ) );
    subject to
       X : kron(eye(n), Y) &gt;= 0;
cvx_end
</code></pre>

<p>Since I don't have a partial trace operation, I'm essentially flipping the roles of the primal and dual functions by swapping the maximization and minimization constraints. This may not be the right way to go about it though, so any feedback would certainly be helpful.  Basically my understanding is that if you provide the primal problem, CVX is smart enough to solve the corresponding dual (<a href="http://orion.math.uwaterloo.ca/~hwolkowi/henry/teaching/w11/367.w11/367miscfiles/cvx_usrguide.pdf" rel="nofollow">Section 3.7</a> of the CVX manual).</p>

<p>Running the above works, but yields a status failed result, leading me to think that there is something I'm most likely missing here:</p>

<pre><code>Status: Failed
Optimal value (cvx_optval): NaN
</code></pre>

CC BY-SA 3.0
2012-10-15T00:39:57.733Z
I have pinged [Abel Molina](http://cstheory.stackexchange.com/users/1632/abel-molina). Hopefully he will have the time to respond.
Artem Kaznatcheev
CC BY-SA 3.0
2012-10-15T01:25:00.847Z
Thank you very much Artem, I sincerely appreciate the effort.
Vincent Russo
CC BY-SA 3.0
2012-10-15T01:36:55.123Z
It seems to me that this question is asking for how to use a software (MathLab) which I think makes it off-topic for cstheory.
Kaveh
CC BY-SA 3.0
2012-10-15T01:42:23.127Z
@Kaveh I completely disagree, this is asking how to use a very specialized package of matlab which is heavily used by theorists in quantum info. For instance, see the comments on [Abel's answer to Scott's quantum money Q](http://cstheory.stackexchange.com/a/11365/1037), where he includes code from this package to solve a theory question. That answer is one of the most notable contributions to TP.SE (and now cstheory) that I am aware of.
Artem Kaznatcheev
CC BY-SA 3.0
2012-10-15T01:46:07.333Z
I also disagree. I think this question is better suited here compared to one where the focus is on programming languages. I say this because the question is directly related to a research question in cs theory. Users here are also more likely to know how cvx relates to other aspects of operator theory / quantum information etc. In addition, I'm also inquiring on aspects on the problem directly related to the theory, and not anything related to the code.
Vincent Russo
CC BY-SA 3.0
2012-10-16T04:00:26.923Z
@Kaveh MathLab? that one made me smile :)
Sasho Nikolov
CC BY-SA 3.0
2012-10-16T04:13:25.400Z
@Sasho, well, according to Artem it is asking "how to use a very specialized package of matlab" so it seems to me that "It *seems* to me that this question is asking for how to use a software (MathLab)" is not that outlandish. :) (My general point is that cstheory is not a software help Q&A even if the software is very specialized and used a lot in TCS. If the question is a TCS question it should be written in way that doesn't require prior knowledge of the particular software. Otherwise the question seems better suited for a mailing list/site dedicated for the particular software.)
Kaveh
CC BY-SA 3.0
2012-10-16T06:23:37.227Z
i was just referring to matlab vs. mathlab :). it's one of those typos that actually make sense. in any case, just CVX being specialized and used by theorists (i am a fan myself) might not be a good reason for a question to be ontopic. but there is a reasonable convex programming question here.
Sasho Nikolov
<quantum-computing><quantum-information><semidefinite-programming>
Using MATLAB's CVX Package for Semidefinite Programming in Quantum Information
Vincent Russo
# Using MATLAB's CVX Package for Semidefinite Programming in Quantum Information

(Asked by: username_0 on 2012-10-14)

I'm attempting to formulate the semidefinite programs used in the paper "Hedging Bets with Correlated Quantum Strategies" (specifically those on page 7) into CVX so that I can play around with the values of the SDPs. The CVX package seems to be very straightforward to get up and running, but I'm a bit unsure in how to convert the SDPs in this scenario and how to interpret the results. For completeness and to try to be a bit helpful, the primal and dual problems for the maximization constraint are replicated from the paper below.  
Primal Problem: 
maximize: $\langle Q_a, X \rangle$
subject to: $Tr_{\mathcal{Y}}(X) = \mathcal{I}_{\mathcal{X}},$
$\qquad \qquad X \in Pos(\mathcal{Y} \otimes \mathcal{X})$
Dual Problem:
minimize: $Tr(Y)$
subject to: $\mathcal{I}_{\mathcal{Y}} \otimes Y \geq Q_a,$
$\qquad \qquad Y \in Herm(\mathcal{X})$
In this case, these are the SDPs which correspond to Bob's maximum probability for winning some quantum protocol between two parties (more information is in the paper, but if you're going to take the time to help me, by all means ask if I can clarify something in a bit more detail). The variables $Q_a$ and $X$ correspond to the Choi-Jamiolkowski representation of the channel for Alice and Bob respectively. My attempt at putting this into MATLAB is as follows:
n = 3;
cvx_begin sdp
    variable Y(n,n) hermitian;
    dual variable X;
    maximize ( trace ( Y ) );
    subject to
       X : kron(eye(n), Y) >= 0;
cvx_end

Since I don't have a partial trace operation, I'm essentially flipping the roles of the primal and dual functions by swapping the maximization and minimization constraints. This may not be the right way to go about it though, so any feedback would certainly be helpful.  Basically my understanding is that if you provide the primal problem, CVX is smart enough to solve the corresponding dual (Section 3.7 of the CVX manual).
Running the above works, but yields a status failed result, leading me to think that there is something I'm most likely missing here:
Status: Failed
Optimal value (cvx_optval): NaN

**Tags:** quantum-computing, quantum-information, semidefinite-programming

> **Comments:**
> **username_1**: I have pinged [username_4](http://cstheory.stackexchange.com/users/1632/abel-molina). Hopefully he will have the time to respond.  
> **username_0**: Thank you very much Artem, I sincerely appreciate the effort.  
> **username_2**: It seems to me that this question is asking for how to use a software (MathLab) which I think makes it off-topic for cstheory.  
> **username_1**: @username_2 I completely disagree, this is asking how to use a very specialized package of matlab which is heavily used by theorists in quantum info. For instance, see the comments on [Abel's answer to Scott's quantum money Q](http://cstheory.stackexchange.com/a/11365/1037), where he includes code from this package to solve a theory question. That answer is one of the most notable contributions to TP.SE (and now cstheory) that I am aware of.  
> **username_0**: I also disagree. I think this question is better suited here compared to one where the focus is on programming languages. I say this because the question is directly related to a research question in cs theory. Users here are also more likely to know how cvx relates to other aspects of operator theory / quantum information etc. In addition, I'm also inquiring on aspects on the problem directly related to the theory, and not anything related to the code.  
> **username_3**: @username_2 MathLab? that one made me smile :)  
> **username_2**: @Sasho, well, according to Artem it is asking "how to use a very specialized package of matlab" so it seems to me that "It *seems* to me that this question is asking for how to use a software (MathLab)" is not that outlandish. :) (My general point is that cstheory is not a software help Q&A even if the software is very specialized and used a lot in TCS. If the question is a TCS question it should be written in way that doesn't require prior knowledge of the particular software. Otherwise the question seems better suited for a mailing list/site dedicated for the particular software.)  
> **username_3**: i was just referring to matlab vs. mathlab :). it's one of those typos that actually make sense. in any case, just CVX being specialized and used by theorists (i am a fan myself) might not be a good reason for a question to be ontopic. but there is a reasonable convex programming question here.  

---

## 1 answers

### Answer by username_4 on 2012-10-15. Score: 5 | Accepted answer

The new SDP that you obtain by replacing minimize by maximize is not necessarily closely related to the first one. Right now the value is infinity, and if you replaced 0 by $Q\_a$ on the right side of the constraint, the value is always going to be 0 or infinity (if it's not 0, you can just multiply any solution with positive value by an arbitrary constant, and increase the value).

The way I went about this general issue when solving these SDPs was just implementing the partial trace, and then coding the dual and primal problem separately. The implementation of the partial trace is at <https://cs.uwaterloo.ca/~amolinap/prtrace.m>, hope it is useful!

> **Comments:**
> **username_0**: Thanks very much for the swift reply, Abel! That clears up my question very well. Thanks again!  
> **username_5**: Hi Abel, did you by any chance saved the m file somewhere else? The original link is no longer functional. Thanks!  
> **username_4**: Hi, sorry for the late reply. I recommend that you use more modern approaches like QETLAB instead, and I cannot guarantee that it will work, but I think this might be it: https://pastebin.com/FUeL2wW8  

---

