# 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

## 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

## 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.

R2(i) = 2*real( trace(W_(:,:,i)'GW(:,:,i)) ) - real( trace(W_(:,:,i)'GW_(:,:,i)));

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.