You have several syntax errors as well as optimization formulation problems.
Use cvx_begin and cvx_end. Use log_det (you can divide by log(2) if you want, but I won’t bother). Don’t use double.
The argument of log_det, namely diag((v)) * H * H' is not symmetric, so I think. is not a convex optimization problem. I will now guess that you intended H*diag(v)*H' to be that argument. Making all these changes, a problem which can be accepted by CVX can be entered (I also changed < 3 to <= 3, which is how it will be interpreted by CVX).
However, this problem is unbounded, as can be seen by making v(1) large and v(2) = -v(1), which will still meet the constraint 1 <= trace(diag(v)) <= 3.
If you add a constraint such as v >= 0, the problem will be bounded and have a finite solution. However, with sedumi, sdpt3, and scs, in CVX3.0beta build 1177, this problem incorrectly is reported as being unbounded (i.e., with constraint v >= 0 added) which appears to be a bug in CVX 3.0 beta build 1177, because CVX 's successive approximation method is not being used when scs is used.
Wow! Thanks a lot for your reply. I have two more questions.
When I solve this system, the result is not integer. I tried to add some if/else statement to round the variable but CVx does not allow it. Is there anyway to get the optimized variable in binary form?
Also, if its not possible to get the binary result, how should I rewrite the problem to get the integer form solution for the diagonal matrix? Thanks a lot.
I think you’re out of luck for solving a mixed integer version of this problem with CVX and current versions of solvers. If you have CVX Professional and MOSEK, there is an integer capability for MILP/MIQP/MISOCP, but not for MISDP. Note that although CVX will call MOSEK for mixed integer problems in which CVX"s successive approximation method is used, CVX’s successive approximation will not work correctly, and will return unreliable, quite possibly erroneous results.
Although I suggested using logdet, for your problem, you could maximize det_rootn instead. The argmax will be the same. This will not cause CVX"s successive approximation method to be invoked. The bad news is that I believe that would require making use of a mixed integer SDP capability, which MOSEK does not currently have (for problems which can not be expressed as mixed integer SOCP)…
I recommend using det_rootn instead of log_det fo rthe continuous variable version of the problem… Actually, you could solve the problem by brute force enumeration of all possible integer vectors v satisfying the constraints, and evaluating the objective function. Largest objective function wins.
I believe you want [Ro t;t' inv(Ro)]>=0; to be an LMI, in which case you either need to use cvx_begin sdp , or use [Ro t;t' inv(Ro)]==semidefinite(2), which both accomplish the same thing. Please read http://cvxr.com/cvx/doc/sdp.html .
Furthermore, if you want to obtain t = -1, then you need to get rid of the constraint t >= 0.
If you do these, you will get optimal t = -1 ((within tolerance of) as you thought it should be.
So either do
[Ro t;t' inv(Ro)]>=0;
[Ro t;t' inv(Ro)]==semidefinite(2);