Error!The Optimal value (cvx_optval) is NaN

I am trying to solve a non-convex QCQP problem. After I transformed the non-convex constraint trace(W(:,:,i)'*G*W(:,:,i)) to 2*real( trace(W_(:,:,i)'*G*W(:,:,i)) ) - real( trace(W_(:,:,i)'*G*W_(:,:,i))) by its first order Taylor expansion(SCA). The whole problem turned to be convex, and it can be solved.
the main cvx codes are as follow

[W_,Pow1] = feasible_check_CRSWIPT_W(phi,Gr,Gd,Lr,Ld,Hr,Hd,HSI,Pbs,PE,gammaI,KI,KE,N,Nt,d,eta);%Initialize W_
 cvx_begin 
          variable W(Nt,d,KI) complex  
          expression rate(1,KI)
          expression R1(1,KI)
          expression R2(1,KI)
          expression R3(1,KI)
          for i=1:KI    
              
              R1(i) = square_pos(norm(W(:,:,i),'fro')) ;
          
              R2(i) = 2*real(  trace(W_(:,:,i)'*G*W(:,:,i)) ) - real(  trace(W_(:,:,i)'*G*W_(:,:,i)));
                     %real(  trace(W_(:,:,i)'*G*W_(:,:,i))) ;
               
              R3(i) = square_pos(norm(L*W(:,:,i),'fro'))  ; 

              rate(i) = square_pos(norm(sqrtm(A)*W(:,:,i), 'fro')) - real(trace(V(:,:,i)*U(:,:,i)'*H(:,:,i)*W(:,:,i))) - ...
              - real(trace(V(:,:,i)*W(:,:,i)'*H(:,:,i)'*U(:,:,i))) ;

          end
          minimize sum(rate)
          subject to

         sum(R1) <= Pbs;
         sum(R2) >= PE;
         sum(R3) <= gammaI;

      cvx_end
      W_=W;

However, On multiple solvings, it appears solved and Infeasible
`Calling SDPT3 4.0: 119 variables, 56 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.

num. of constraints = 56
dim. of sdp var = 12, num. of sdp blk = 6
dim. of socp var = 86, num. of socp blk = 6
dim. of linear var = 15


SDPT3: Infeasible path-following algorithms


version predcorr gam expon scale_data
HKM 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime

0|0.000|0.000|1.0e+01|4.5e+00|2.9e+03| 1.599988e+02 0.000000e+00| 0:0:00| chol 1 1
1|0.944|0.891|5.6e-01|5.3e-01|4.2e+02| 1.183601e+02 -1.751913e+01| 0:0:00| chol 1 1
2|0.996|0.956|2.1e-03|2.8e-02|4.7e+01| 3.281637e+01 -5.518912e+00| 0:0:00| chol 1 1
3|0.631|0.721|7.6e-04|8.6e-03|1.7e+01| 1.199092e+01 -2.292362e+00| 0:0:00| chol 1 1
4|0.862|0.818|1.0e-04|1.7e-03|5.8e+00| 4.149299e+00 -1.135535e+00| 0:0:00| chol 1 1
5|0.977|0.814|2.0e-06|3.5e-04|9.1e-01| 5.736147e-01 -2.148289e-01| 0:0:00| chol 1 1
6|0.873|0.801|7.6e-07|7.0e-05|1.8e-01| 1.128499e-01 -4.462882e-02| 0:0:00| chol 1 1
7|0.155|0.226|6.9e-07|5.5e-05|1.5e-01| 8.313636e-02 -3.488725e-02| 0:0:00| chol 1 1
8|0.766|0.704|1.5e-06|1.6e-05|7.4e-02| 5.259658e-02 -1.219627e-02| 0:0:00| chol 1 1
9|0.909|0.729|1.8e-07|4.6e-06|1.7e-02| 9.991184e-03 -4.220891e-03| 0:0:00| chol 1 1
10|0.946|0.809|9.8e-09|9.2e-07|3.6e-03| 2.281850e-03 -7.457146e-04| 0:0:00| chol 1 1
11|0.855|0.754|1.4e-09|2.3e-07|1.0e-03| 6.077833e-04 -2.473913e-04| 0:0:00| chol 1 1
12|0.575|0.717|6.1e-10|6.5e-08|4.4e-04| 3.078596e-04 -6.889579e-05| 0:0:00| chol 1 1
13|0.873|0.726|7.7e-11|1.8e-08|1.2e-04| 7.541492e-05 -2.950484e-05| 0:0:00| chol 1 1
14|0.482|0.633|4.0e-11|6.6e-09|6.2e-05| 4.165849e-05 -1.095190e-05| 0:0:00| chol 1 1
15|0.953|0.755|2.2e-12|1.6e-09|1.4e-05| 8.311853e-06 -3.351163e-06| 0:0:00| chol 1 1
16|0.589|0.794|9.1e-13|3.3e-10|5.3e-06| 3.985647e-06 -7.348241e-07| 0:0:00| chol 1 1
17|0.768|0.644|2.0e-12|1.2e-10|1.9e-06| 1.289131e-06 -3.624735e-07| 0:0:00| chol 1 1
18|0.742|0.696|4.3e-11|3.7e-11|7.3e-07| 5.091846e-07 -1.428442e-07| 0:0:00| chol 1 1
19|0.792|0.815|2.4e-10|8.4e-12|2.3e-07| 1.744262e-07 -3.710626e-08| 0:0:00| chol 1 1
20|0.923|0.926|1.3e-09|2.9e-12|3.9e-08| 3.170933e-08 -5.804187e-09| 0:0:00| chol 1 1
21|0.559|0.940|5.2e-10|3.5e-12|1.9e-08| 1.671464e-08 -1.220916e-09| 0:0:00| chol 1 2
22|0.553|1.000|2.3e-10|5.1e-12|1.0e-08| 8.410690e-09 -1.286924e-09| 0:0:00|
stop: max(relative gap, infeasibilities) < 1.49e-08

number of iterations = 22
primal objective value = 8.41068951e-09
dual objective value = -1.28692368e-09
gap := trace(XZ) = 1.04e-08
relative gap = 1.04e-08
actual relative gap = 9.70e-09
rel. primal infeas (scaled problem) = 2.32e-10
rel. dual " " " = 5.06e-12
rel. primal infeas (unscaled problem) = 0.00e+00
rel. dual " " " = 0.00e+00
norm(X), norm(y), norm(Z) = 3.9e+01, 4.2e+00, 1.1e+01
norm(A), norm(b), norm(C) = 1.0e+01, 2.4e+00, 1.1e+01
Total CPU time (secs) = 0.25
CPU time per iteration = 0.01
termination code = 0
DIMACS: 2.8e-10 0.0e+00 5.2e-12 0.0e+00 9.7e-09 1.0e-08


Status: Solved
Optimal value (cvx_optval): +1.28692e-09

B:2.8572,N=10,i=1

Calling SDPT3 4.0: 119 variables, 56 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.

num. of constraints = 56
dim. of sdp var = 12, num. of sdp blk = 6
dim. of socp var = 86, num. of socp blk = 6
dim. of linear var = 15


SDPT3: Infeasible path-following algorithms


version predcorr gam expon scale_data
HKM 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime

0|0.000|0.000|1.0e+01|4.5e+00|2.9e+03| 1.599924e+02 0.000000e+00| 0:0:00| chol 1 1
1|0.944|0.891|5.6e-01|5.3e-01|4.2e+02| 1.183537e+02 -1.751913e+01| 0:0:00| chol 1 1
2|0.996|0.956|2.1e-03|2.8e-02|4.7e+01| 3.281004e+01 -5.518878e+00| 0:0:00| chol 1 1
3|0.631|0.721|7.6e-04|8.6e-03|1.7e+01| 1.198340e+01 -2.292230e+00| 0:0:00| chol 1 1
4|0.862|0.818|1.0e-04|1.7e-03|5.8e+00| 4.138322e+00 -1.135349e+00| 0:0:00| chol 1 1
5|0.977|0.763|2.0e-06|4.4e-04|9.8e-01| 5.508167e-01 -2.721736e-01| 0:0:00| chol 1 1
6|0.307|0.212|1.4e-06|3.5e-04|7.5e-01| 2.321599e-01 -2.162958e-01| 0:0:00| chol 1 1
7|0.054|0.135|1.7e-06|3.0e-04|7.5e-01| 4.439979e-01 -2.010968e-01| 0:0:00| chol 1 1
8|0.352|0.229|1.2e-06|2.3e-04|5.4e-01| 1.244197e-01 -1.599566e-01| 0:0:00| chol 1 1
9|0.162|0.130|9.6e-07|2.0e-04|5.6e-01| 4.603739e-02 -1.513972e-01| 0:0:00| chol 1 1
10|0.205|0.271|7.7e-07|1.5e-04|4.8e-01|-2.124683e-01 -1.656733e-01| 0:0:00| chol 1 1
11|0.373|0.298|4.8e-07|1.0e-04|4.0e-01|-5.095561e-01 -2.345840e-01| 0:0:00| chol 1 1
12|0.246|0.371|3.6e-07|6.5e-05|3.1e-01|-7.266383e-01 -3.784295e-01| 0:0:00| chol 1 1
13|0.161|0.297|3.0e-07|4.6e-05|2.5e-01|-1.041371e+00 -5.178662e-01| 0:0:00| chol 1 1
14|0.110|0.067|2.7e-07|4.3e-05|3.8e-01|-3.084617e+00 -5.380080e-01| 0:0:00| chol 1 1
15|0.095|0.056|2.4e-07|4.0e-05|1.3e+00|-1.821468e+01 -6.498375e-01| 0:0:00| chol 1 1
16|0.071|0.019|2.3e-07|4.0e-05|1.7e+01|-3.998179e+02 -6.276742e-01| 0:0:00| chol 1 1
17|0.226|0.014|1.8e-07|3.9e-05|1.6e+03|-5.769192e+04 -6.471920e-01| 0:0:00| chol 1 1
18|0.022|0.007|1.9e-07|3.9e-05|3.8e+04|-1.798012e+06 -8.136691e-01| 0:0:00| chol 1 2
19|0.001|0.000|2.2e-07|3.9e-05|1.3e+05|-5.840521e+06 -1.012137e+00| 0:0:00| chol 1 2
20|0.001|0.001|4.4e-07|3.9e-05|3.2e+05|-1.456278e+07 -2.615521e+00| 0:0:00| chol 1 2
21|0.001|0.000|2.3e-07|3.9e-05|1.2e+06|-5.126138e+07 -2.436381e+00| 0:0:00| chol 2 2
22|0.000|0.001|2.7e-07|3.9e-05|1.7e+06|-7.071828e+07 -2.451217e+01| 0:0:00| chol 2 2
23|0.001|0.001|1.0e-06|3.9e-05|5.4e+06|-2.256808e+08 -3.873058e+01| 0:0:00| chol 2 2
24|0.000|0.002|2.2e-06|3.9e-05|1.0e+07|-4.190257e+08 -2.907500e+02| 0:0:00| chol 2 2
25|0.001|0.001|2.1e-06|3.9e-05|3.2e+07|-1.302667e+09 -3.184763e+02| 0:0:00| chol 2 2
26|0.000|0.001|5.2e-06|3.9e-05|4.9e+07|-1.841980e+09 -1.224612e+03| 0:0:00| chol 2 2
27|0.001|0.001|1.0e-05|3.9e-05|1.3e+08|-4.723567e+09 -4.095421e+03| 0:0:00| chol 2 2
28|0.002|0.001|5.0e-05|3.9e-05|5.0e+08|-1.692562e+10 -8.588283e+03| 0:0:00| chol 2 2
29|0.004|0.001|3.6e-04|3.9e-05|3.3e+09|-1.037590e+11 -4.058290e+04| 0:0:00| chol 2 2
30|0.001|0.002|3.4e-04|3.9e-05|7.7e+09|-2.337326e+11 -1.673485e+05| 0:0:00| chol 2 2
31|0.001|0.002|2.9e-04|4.0e-05|1.4e+10|-4.088695e+11 -8.069310e+05| 0:0:00|
sqlp stop: dual problem is suspected of being infeasible

number of iterations = 31
residual of dual infeasibility
certificate X = 3.46e-12
reldist to infeas. <= 3.06e-17
Total CPU time (secs) = 0.41
CPU time per iteration = 0.01
termination code = 2
DIMACS: 3.6e-04 0.0e+00 4.1e-05 0.0e+00 -1.0e+00 3.4e-02


Status: Infeasible
Optimal value (cvx_optval): +Inf

错误使用 *
Disciplined convex programming error:
Invalid numeric values (NaNs) may not be used in CVX expressions.

出错 sheepB (第 40 行)
R2(i) = 2*real( trace(W_(:,:,i)'GW(:,:,i)) ) - real( trace(W_(:,:,i)'GW_(:,:,i)));

出错 mia2n_test (第 37 行)
parfor i=1:LL`

Thanks!Can the Gurobi solver solve such problems equivalently,or better use the Yalmip solver?

Non-convex QCQP is within scope of Gurobi, but not under CVX, which does not allow problems whose continuous relaxation is not convex. Gurobi can be used as solver under YALMIP for non-convex QCQP, and will at least attempt to solve it, although it may or may not succeed (with a small gap) within a time frame acceptable to you. You can also try using YALMIP"s BMIBNB solver, which you shouldn’t expect to be as fast as Gurobi, although it might be on some specific problem.