I have a question use CVX to get the projection on a set

Hi, I have use the folling code, but the result is negative? why? I used CVX 2.0, matlab R2010b

dd = [1 1 1 1 1 1 1 1 1 1 1]; 
cvx_begin 
variable y(11) 
minimize( norm(y - old_avg_pi , 2 )) 
subject to 
dd * y == 1 
-y <= 0 
cvx_end 

old_avg_pi =

1.0e+006 *

0.7696
1.3818
0.6645
5.8412
0.0000
0.4283
0.6691
3.9130
0.7088
1.4975
1.1092

y = 0.0011 -0.0212 0.0046 1.1923 0.0016 0.0012 0.0094 -0.0084 -0.0285 0.0071 -0.0279

Thank you for anyone for asking the question?

EDIT by mcg: Adding the SDPT3 output from your duplicate post:

Calling SDPT3 4.0: 23 variables, 12 equality constraints
------------------------------------------------------------

 num. of constraints = 12
 dim. of socp   var  = 12,   num. of socp blk  =  1
 dim. of linear var  = 11
*******************************************************************
   SDPT3: Infeasible path-following algorithms
*******************************************************************
 version  predcorr  gam  expon  scale_data
    NT      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      prim-obj      dual-obj    cputime
-------------------------------------------------------------------
 0|0.000|0.000|9.8e+000|1.7e+001|6.3e+009| 1.362889e+007  0.000000e+000| 0:0:00| chol  1  1 
 1|0.972|0.968|2.7e-001|1.0e+000|1.8e+008| 9.062942e+006  9.803218e+006| 0:0:00| chol  1  1 
 2|0.983|1.000|4.7e-003|2.5e-001|3.1e+006| 7.640643e+006  8.613915e+006| 0:0:00| chol  1  1 
 3|0.989|0.993|5.3e-005|1.3e-001|3.5e+004| 7.549734e+006  8.096859e+006| 0:0:00| chol  2  2 
 4|0.942|1.000|3.1e-006|6.2e-002|2.0e+003| 7.548582e+006  7.820884e+006| 0:0:00| chol  2  2 
 5|0.899|1.000|3.1e-007|3.1e-002|2.6e+002| 7.548596e+006  7.684752e+006| 0:0:00| chol  3  3 
 6|0.961|1.000|1.2e-008|6.2e-008|1.9e+001| 7.548579e+006  7.548568e+006| 0:0:00| chol 11  7 
 7|1.000|1.000|4.0e-008|2.4e-009|1.8e+000| 7.548578e+006  7.548577e+006| 0:0:00| chol 20 30 
 8|1.000|0.524|1.5e-005|4.7e-009|8.6e-001| 7.548694e+006  7.548578e+006| 0:0:00| chol 15  8 
 9|0.617|1.000|5.9e-006|5.4e-009|4.1e-001| 7.548622e+006  7.548578e+006| 0:0:00| chol  7 10 
10|0.998|0.848|7.6e-009|1.3e-009|2.5e-002| 7.548578e+006  7.548578e+006| 0:0:00|
  stop: max(relative gap, infeasibilities) < 1.49e-008
-------------------------------------------------------------------
 number of iterations   = 10
 primal objective value =  7.54857799e+006
 dual   objective value =  7.54857813e+006
 gap := trace(XZ)       = 2.46e-002
 relative gap           = 1.63e-009
 actual relative gap    = -8.70e-009
 rel. primal infeas     = 7.62e-009
 rel. dual   infeas     = 1.33e-009
 norm(X), norm(y), norm(Z) = 1.1e+007, 2.2e+000, 2.5e+000
 norm(A), norm(b), norm(C) = 6.7e+000, 1.9e+007, 2.0e+000
 Total CPU time (secs)  = 0.13  
 CPU time per iteration = 0.01  
 termination code       =  0
 DIMACS: 8.3e-009  0.0e+000  1.3e-009  0.0e+000  -8.7e-009  1.6e-009
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +7.54858e+006

I suspect it’s a scaling issue. Frankly, the magnitudes of those negative numbers are very small compared to old_avg_pi. They are within typical numerical error.

EDIT: No, I’m wrong. When I run the same model here, I do not have any scaling issues. The answer I get is

[ 0.1415 0.1521 0.1260 0.0070 0.1002 0.1047 0.0883 0.1858 0.1096 0.1132 0.1574 ]

Furthermore, it looks like SDPT3 is performing the same calculations here. So the problem seems to be that the variable y is not being updated with the answer correctly for you. Please submit a full bug report to http://support.cvxr.com, with as much detail about your installation as possible.

I use the matlab CVX2.0 2010b, and when I use the matlab 2012, it give a diffierent wrong answer.
why happen this ? and sum(your anwser) = 1.2858; I thought it should be sum(y)=1

That’s what I’m saying, you have a very strange error. SDPT3 is computing the right answer, but for some reason it is not being transmitted to the variable y. Please submit a bug report as I instructed below.