# Why the result is NAN?

%CVX
cvx_begin quiet
cvx_solver SDPT3
variables X(N,K);
variables Kao(N,K);
variables Smax(1,1);%目标
variables f(N,K);%频率
variables fuav(N,K);
expression Ec(1,K);
expression Eget(1,K);
expression Schuan(1,K);
expression Sjisuan(1,K);
expression Ecu(1,K);
expression Euav(1,1);

maximize(Smax)
subject to:
%频率约束
0<=f<=fk; %√
0<=fuav<=fu; %√
%散射系数约束
0<=Kao<=1; %√
%收集能量和本地计算约束
for k=1:K
Ec(1,k)=0;
Eget(1,k)=0;
for n=1:N
Ec(1,k)=gamacpow_pos(f(n,k),3)delta_t+Ec(1,k);%√
Eget(1,k)=yita
Ar(n,k)
(1-Kao(n,k))*Pk(n,k)*delta_t+Eget(1,k);%√
Ec(1,k)<=Eget(1,k);%√
end
end
%上传数据和计算量约束
for k=1:K
Schuan(1,k)=0;%√
Sjisuan(1,k)=0;%√
for n=1:N
Schuan(1,k)=Ar(n,k)log(1 + (Pk(n,k)Kao(n,k)dB2dec(beta0)) ./ (dBm2dec(sigma_2) * norm(Qr(:,n)-u(:,k))^(alpha/2)) )/log(2)+Schuan(1,k);%要泰勒展开%√
Sjisuan(1,k)=fuav(n,k)/C+Sjisuan(1,k);%√
Schuan(1,k)>=Sjisuan(1,k);%√
end
end
%目标
for k=1:K
Ecu(1,k)=0;%√
for n=1:N
Ecu(1,k)=Ecu(1,k)+delta_t
f(n,k)/C+delta_t
fuav(n,k)/C;%√
end
Ecu(1,k)>=Smax;%√
end
%无人机能耗约束
Euav=0;
for k=1:K
for n=1:N
Euav=gamac
pow_pos(fuav(n,k),3)*delta_t+Euav;
end
end
Ef+Euav<=E0;
cvx_end

The first thing to do is not use `quiet`, and look at the solver and CVX output and see what they say.

## Calling Mosek 9.1.9: 14349 variables, 5847 equality constraints For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 710: #2 (nearly) zero elements are specified in sparse col ‘’ (3841) of matrix ‘A’.
MOSEK warning 710: #3 (nearly) zero elements are specified in sparse col ‘’ (3843) of matrix ‘A’.
MOSEK warning 710: #4 (nearly) zero elements are specified in sparse col ‘’ (3845) of matrix ‘A’.
MOSEK warning 710: #5 (nearly) zero elements are specified in sparse col ‘’ (3847) of matrix ‘A’.
MOSEK warning 710: #6 (nearly) zero elements are specified in sparse col ‘’ (3849) of matrix ‘A’.
MOSEK warning 710: #7 (nearly) zero elements are specified in sparse col ‘’ (3851) of matrix ‘A’.
MOSEK warning 710: #8 (nearly) zero elements are specified in sparse col ‘’ (3853) of matrix ‘A’.
MOSEK warning 710: #9 (nearly) zero elements are specified in sparse col ‘’ (3855) of matrix ‘A’.
MOSEK warning 710: #10 (nearly) zero elements are specified in sparse col ‘’ (3857) of matrix ‘A’.
MOSEK warning 710: #11 (nearly) zero elements are specified in sparse col ‘’ (3859) of matrix ‘A’.
Warning number 710 is disabled.
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (0).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (80).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (160).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (240).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (320).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (400).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (480).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (560).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (641).
MOSEK warning 57: A large value of 5.0e+08 has been specified in c for variable ‘’ (642).
Warning number 57 is disabled.
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 5847
Cones : 2647
Scalar variables : 14349
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries : 2 time : 0.00
Lin. dep. - tries : 1 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.09
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 5847
Cones : 2647
Scalar variables : 14349
Matrix variables : 0
Integer variables : 0

Optimizer - threads : 4
Optimizer - solved problem : the primal
Optimizer - Constraints : 3772
Optimizer - Cones : 2647
Optimizer - Scalar variables : 11876 conic : 7941
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.03 dense det. time : 0.00
Factor - ML order time : 0.02 GP order time : 0.00
Factor - nonzeros before factor : 8.18e+04 after factor : 8.18e+04
Factor - dense dim. : 0 flops : 7.89e+06
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.3e+00 1.6e+10 4.0e+09 0.00e+00 4.000001390e+09 0.000000000e+00 1.0e+00 0.22
1 3.1e-01 3.9e+09 2.0e+09 -1.00e+00 3.988502108e+09 -3.049890571e+00 2.5e-01 0.58
2 9.9e-02 1.2e+09 1.9e+09 -1.00e+00 6.967254340e+09 -1.196889212e+01 7.7e-02 0.61
3 3.9e-02 4.9e+08 1.2e+09 -1.00e+00 6.650135644e+09 -3.164152909e+01 3.1e-02 0.64
4 7.4e-03 9.2e+07 5.4e+08 -1.00e+00 7.071437627e+09 -1.726978112e+02 5.8e-03 0.67
5 1.2e-03 1.5e+07 2.2e+08 -1.00e+00 7.052805006e+09 -1.044974751e+03 9.6e-04 0.70
6 3.8e-04 4.7e+06 1.2e+08 -1.00e+00 7.060246811e+09 -3.417089508e+03 2.9e-04 0.73
7 1.2e-04 1.4e+06 6.7e+07 -1.00e+00 7.060873736e+09 -1.104649497e+04 9.1e-05 0.77
8 2.8e-05 3.5e+05 3.3e+07 -1.00e+00 7.060040724e+09 -4.590128619e+04 2.2e-05 0.78
9 1.4e-05 1.7e+05 2.3e+07 -1.00e+00 7.059837637e+09 -9.303272459e+04 1.1e-05 0.81
10 4.9e-06 6.1e+04 1.4e+07 -1.00e+00 7.059218695e+09 -2.603713774e+05 3.8e-06 0.83
11 2.9e-06 3.7e+04 1.1e+07 -1.00e+00 7.058642447e+09 -4.370731912e+05 2.3e-06 0.83
12 1.2e-06 1.5e+04 6.9e+06 -1.00e+00 7.056576391e+09 -1.060774935e+06 9.4e-07 0.84
13 4.0e-07 5.0e+03 3.9e+06 -1.00e+00 7.049414272e+09 -3.215673944e+06 3.1e-07 0.86
14 2.6e-07 3.2e+03 3.1e+06 -9.99e-01 7.043429739e+09 -5.026231231e+06 2.0e-07 0.88
15 5.4e-08 6.8e+02 1.4e+06 -9.98e-01 6.982299941e+09 -2.345060657e+07 4.2e-08 0.89
16 2.2e-08 2.8e+02 9.2e+05 -9.91e-01 6.869342973e+09 -5.711157159e+07 1.7e-08 0.91
17 6.9e-09 8.6e+01 5.0e+05 -9.77e-01 6.449367443e+09 -1.789090319e+08 5.4e-09 0.92
18 3.3e-09 4.2e+01 3.3e+05 -9.16e-01 5.795748943e+09 -3.484381354e+08 2.6e-09 0.92
19 1.3e-09 1.7e+01 1.8e+05 -7.84e-01 4.096665792e+09 -7.082088434e+08 1.0e-09 0.95
20 3.6e-10 4.5e+00 4.3e+04 -3.06e-01 8.888061436e+08 -1.094199697e+09 2.8e-10 0.98
21 5.3e-12 6.6e-02 1.8e+02 4.96e-01 -8.617543525e+08 -8.721558308e+08 4.1e-12 1.00
Optimizer terminated. Time: 1.06

Interior-point solution summary
Problem status : DUAL_INFEASIBLE
Solution status : DUAL_INFEASIBLE_CER
Primal. obj: -5.3028642846e-01 nrm: 4e-01 Viol. con: 9e-06 var: 1e-11 cones: 2e-12
Optimizer summary
Optimizer - time: 1.06
Interior-point - iterations : 21 time: 1.01
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00

Status: Infeasible
Optimal value (cvx_optval): -Inf

Look for input data in your program which is close to zero or which is very large in magnitude. Then re-scale the problem so that all input data is within a small number of orders of magnitude of one.

Then re-run. If all the Mosek warnings haven been eliminated and it is still reported as infeasible, then follow the directions at https://yalmip.github.io/debugginginfeasible, all of which also apply to CVX, except for section 1.