Hello everyone, I really need your help. Why does NaN appear in my results? I really want to know. Thank you all

clc;
clear all;
close all;
cvx_solver mosek
%轨迹初始化
T = 120; %mission period
delta = T/120; %elemental length
N = T/delta; %number of time slot
K=6;

% 用户在移动
% 用户一的初始轨迹
xw1 = 700;%圆心
yw1 = 100;
rw1 = 200;%radius
theta = 0:2pi/(N-1):2pi;
qw11 = xw1 + rw1cos(theta);
qw21 = yw1 + rw1
sin(theta);
qw11 = qw11’;
qw21 = qw21’;
w1 = [qw11,qw21];
%用户二的初始轨迹
xw2 = 200;%圆心
yw2 = 450;
rw2 = 100;%radius
theta = 0:2pi/(N-1):2pi;
qw12 = xw2 + rw2cos(theta);
qw22 = yw2 + rw2
sin(theta);
qw12 = qw12’;
qw22 = qw22’;
w2 = [qw12,qw22];
% w1 = [700ones(N,1),100ones(N,1)];
% w2 = [200ones(N,1),450ones(N,1)];
w3 = [-300ones(N,1),450ones(N,1)];
w4 = [-600ones(N,1),200ones(N,1)];
w5 = [-450ones(N,1),-450ones(N,1)];
w6 = [400ones(N,1),-500ones(N,1)];

% 恶意干扰在移动
% 干扰点的初始轨迹
% Jx1 =0 ;%圆心
% Jy1 = 0;
% Jw1 = 200;%radius
% theta = 0:2pi/(N-1):2pi;
% J11 = Jx1 + Jw1cos(theta);
% J21 = Jy1 + Jw1
sin(theta);
% J11 = J11’;
% J21 = J21’;
% J = [J11,J21];
J = [0ones(N,1),0ones(N,1)];%恶意干扰信号位置

p1=10;
p2=1;
p3=1;
p4=1;
p5=1;
p6=1;
x1=0.1;
x2=0.1;
x3=0.1;
x4=0.1;
x5=0.1;
x6=0.1;

pm=0.00001;%干扰功率
pmax=10;
B=10^6;
vmax = 200; %maximum speed
beta_db =-60; %单位距离下信道增益 dB
sigma_db = -148; %噪声强度dB
beta = 10^(beta_db/10);
sigma = 10^(sigma_db/10);
H = 100; %无人机高度
%初始轨迹
x11 = 0;%圆心
y11 = 0;
r1 = 800;%radius
theta = 0:2pi/(N-1):2pi;
% 无人机轨迹
% q11 = x11 + r1cos(theta);
% q21 = y11 + r1
sin(theta);
% q11 = q11’;
% q21 = q21’;
% q1 = [q11,q21];
q1=[38ones(N,1),5ones(N,1)];
q1s = q1;
for cntTra =1:1:2
d11 = H^2+(q1s(:,1)-w1(:,1)).^2+(q1s(:,2)-w1(:,2)).^2;
d12 = H^2+(q1s(:,1)-w2(:,1)).^2+(q1s(:,2)-w2(:,2)).^2;
d13 = H^2+(q1s(:,1)-w3(:,1)).^2+(q1s(:,2)-w3(:,2)).^2;
d14 = H^2+(q1s(:,1)-w4(:,1)).^2+(q1s(:,2)-w4(:,2)).^2;
d15 = H^2+(q1s(:,1)-w5(:,1)).^2+(q1s(:,2)-w5(:,2)).^2;
d16 = H^2+(q1s(:,1)-w6(:,1)).^2+(q1s(:,2)-w6(:,2)).^2;
d= H^2+(q1s(:,1)-J(:,1)).^2+(q1s(:,2)-J(:,2)).^2;

Is=sigma+(beta.*pm)./d;%初始可行解
Ls1=d11./(beta.*p1);
Ls2=d12./(beta.*p2);
Ls3=d13./(beta.*p3);
Ls4=d14./(beta.*p4);
Ls5=d15./(beta.*p5);
Ls6=d16./(beta.*p6);

A1=-(x1.*B)./(Ls1+(x1.*B).*Ls1.^2.*Is);%泰勒展开系数
A2=-(x2.*B)./(Ls2+(x2.*B).*Ls2.^2.*Is);
A3=-(x3.*B)./(Ls3+(x3.*B).*Ls3.^2.*Is);
A4=-(x4.*B)./(Ls4+(x4.*B).*Ls4.^2.*Is);
A5=-(x5.*B)./(Ls5+(x5.*B).*Ls5.^2.*Is);
A6=-(x6.*B)./(Ls6+(x6.*B).*Ls6.^2.*Is);

C1=-(x1.*B)./(Is+(x1.*B).*Is.^2.*Ls1);%泰勒展开系数
C2=-(x2.*B)./(Is+(x2.*B).*Is.^2.*Ls2);
C3=-(x3.*B)./(Is+(x3.*B).*Is.^2.*Ls3);
C4=-(x4.*B)./(Is+(x4.*B).*Is.^2.*Ls4);
C5=-(x5.*B)./(Is+(x5.*B).*Is.^2.*Ls5);
C6=-(x6.*B)./(Is+(x6.*B).*Is.^2.*Ls6);

cvx_begin
cvx_precision default

variable q1(N,2)
variable L1(N)
variable L2(N)
variable L3(N)
variable L4(N)
variable L5(N)
variable L6(N)
variable I(N)

variable eta
variable m(N)
expression qu1(N,1)

maximize eta

subject to
sum((x1.*B).*log(1+1./((x1.*B).Ls1(:).Is(:)))-abs(A1).(L1(:)-Ls1(:))-abs(C1).(I(:)-Is(:)))>=eta;%(1-1)
sum((x2.*B).*log(1+1./((x2.*B).Ls2(:).Is(:)))-abs(A2).(L2(:)-Ls2(:))-abs(C2).(I(:)-Is(:)))>=eta;
sum((x3.*B).*log(1+1./((x3.*B).Ls3(:).Is(:)))-abs(A3).(L3(:)-Ls3(:))-abs(C3).(I(:)-Is(:)))>=eta;
sum((x4.*B).*log(1+1./((x4.*B).Ls4(:).Is(:)))-abs(A4).(L4(:)-Ls4(:))-abs(C4).(I(:)-Is(:)))>=eta;
sum((x5.*B).*log(1+1./((x5.*B).Ls5(:).Is(:)))-abs(A5).(L5(:)-Ls5(:))-abs(C5).(I(:)-Is(:)))>=eta;
sum((x6.*B).*log(1+1./((x6.*B).Ls6(:).Is(:)))-abs(A6).(L6(:)-Ls6(:))-abs(C6).(I(:)-Is(:)))>=eta;

for i=1:1:N

H^2+sum_square_abs(q1(i,:)-w1(i,:))<=beta.*p1.*L1(i)%(1-2)
H^2+sum_square_abs(q1(i,:)-w2(i,:))<=beta.*p2.*L2(i);
H^2+sum_square_abs(q1(i,:)-w3(i,:))<=beta.*p3.*L3(i);
H^2+sum_square_abs(q1(i,:)-w4(i,:))<=beta.*p4.*L4(i);
H^2+sum_square_abs(q1(i,:)-w5(i,:))<=beta.*p5.*L5(i);
H^2+sum_square_abs(q1(i,:)-w6(i,:))<=beta.*p6.*L6(i);

pm*beta.*inv_pos(m(i))+sigma<=I(i)%(1-3)

end

for i=1:1:N
qu1(i)=2*q1s(i,1)q1(i,1)-q1s(i,1)^2+J(i,1)^2-2J(i,1)q1(i,1)+2q1s(i,2)q1(i,2)-q1s(i,2)^2+J(i,2)^2-2J(i,2)*q1(i,2)+H^2;%一阶泰勒
end

m<=qu1;%1-4
m>=0;%(1-5)
% q1(1,:slight_smile: == [-500,0];
% q1(N,:slight_smile: == [-500,0];
for i = 1:1:N-1
norm(q1(i+1,:)-q1(i,:))<=vmax*delta;
end

cvx_end
q1s = q1;
end

Calling Mosek 8.0.0.60: 4802 variables, 2160 equality constraints
For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (714) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (715) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (716) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (717) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (718) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (719) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (720) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (721) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (722) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.1e+018 in constraint ‘’ (723) at variable ‘’ (0).
Warning number 62 is disabled.
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2160
Cones : 959
Scalar variables : 4802
Matrix variables : 0
Integer variables : 0

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator - tries : 0 time : 0.00
Lin. dep. - tries : 1 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.00
Optimizer - threads : 8
Optimizer - solved problem : the primal
Optimizer - Constraints : 1915
Optimizer - Cones : 959
Optimizer - Scalar variables : 4557 conic : 3597
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.01 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 1.44e+005 after factor : 3.16e+005
Factor - dense dim. : 0 flops : 1.38e+008
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.0e+000 5.0e+004 5.5e+004 0.00e+000 -2.269339532e+008 0.000000000e+000 1.0e+000 0.03
1 7.1e-003 3.6e+002 4.5e+001 -9.89e-001 -1.354411559e+008 4.582620517e+003 7.1e-003 0.08
2 6.8e-004 3.4e+001 2.5e+000 -4.97e-001 -5.995987528e+007 1.483798382e+004 6.8e-004 0.09
3 7.4e-005 3.7e+000 2.6e-001 -1.57e-001 -1.841148405e+007 3.760487286e+004 7.4e-005 0.09
4 1.8e-005 9.0e-001 7.5e-002 1.36e-001 -7.620906828e+006 3.386253035e+005 1.8e-005 0.11
5 1.5e-005 7.5e-001 6.5e-002 3.81e-001 -3.739780799e+006 3.550548461e+006 1.5e-005 0.11
6 1.0e-005 5.2e-001 3.2e-002 1.58e-001 1.224693510e+008 1.326886992e+008 1.0e-005 0.13
7 5.3e-006 2.6e-001 2.1e-002 -8.78e-002 6.808304265e+007 7.432414518e+007 5.3e-006 0.13
8 1.2e-006 5.9e-002 1.2e-002 6.21e-001 1.339755818e+007 1.473216089e+007 1.2e-006 0.14
9 4.1e-007 2.0e-002 7.1e-003 1.07e+000 5.589691092e+006 6.039676485e+006 4.1e-007 0.16
10 1.9e-007 9.7e-003 4.4e-003 1.05e+000 4.514110268e+006 4.751893598e+006 1.9e-007 0.16
11 1.3e-007 6.5e-003 3.5e-003 2.02e-001 3.310418128e+006 3.485795864e+006 1.3e-007 0.17
12 2.0e-008 9.9e-004 1.3e-003 8.19e-001 9.318700121e+005 9.623730350e+005 2.0e-008 0.17
13 3.0e-009 1.5e-004 9.3e-004 1.25e+000 9.008428196e+004 9.338626568e+004 3.0e-009 0.19
14 1.7e-010 8.6e-006 7.3e-004 1.66e+000 1.126276910e+005 1.127596754e+005 1.7e-010 0.19
15 9.1e-011 4.5e-006 2.9e-004 1.12e+000 1.094805036e+005 1.095480052e+005 9.1e-011 0.20
16 1.2e-011 5.8e-007 6.0e-005 1.06e+000 1.071205891e+005 1.071293201e+005 1.2e-011 0.20
17 1.1e-012 5.5e-008 1.9e-005 1.00e+000 1.069139513e+005 1.069147872e+005 1.1e-012 0.22
18 3.9e-013 1.4e-010 9.9e-011 1.00e+000 1.068917357e+005 1.068917370e+005 1.8e-015 0.22
Interior-point optimizer terminated. Time: 0.22.

Optimizer terminated. Time: 0.27

Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: 1.0689173567e+005 nrm: 4e+017 Viol. con: 4e+011 var: 0e+000 cones: 7e-010
Dual. obj: 1.0689173699e+005 nrm: 6e+011 Viol. con: 0e+000 var: 3e-005 cones: 0e+000
Optimizer summary
Optimizer - time: 0.27
Interior-point - iterations : 18 time: 0.22
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: Solved
Optimal value (cvx_optval): +106892

Calling Mosek 8.0.0.60: 4802 variables, 2160 equality constraints
For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (714) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (715) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (716) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (717) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (718) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (719) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (720) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (721) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (722) at variable ‘’ (0).
MOSEK warning 62: The A matrix contains a large value of -2.0e+018 in constraint ‘’ (723) at variable ‘’ (0).
Warning number 62 is disabled.
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2160
Cones : 959
Scalar variables : 4802
Matrix variables : 0
Integer variables : 0

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator - tries : 0 time : 0.00
Lin. dep. - tries : 1 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.02
Optimizer - threads : 8
Optimizer - solved problem : the primal
Optimizer - Constraints : 1915
Optimizer - Cones : 959
Optimizer - Scalar variables : 4557 conic : 3597
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.01 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 1.44e+005 after factor : 3.16e+005
Factor - dense dim. : 0 flops : 1.38e+008
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.0e+000 4.9e+004 5.5e+004 0.00e+000 -2.269339532e+008 0.000000000e+000 1.0e+000 0.05
1 7.4e-003 3.6e+002 4.7e+001 -9.88e-001 -1.372020095e+008 4.560622210e+003 7.4e-003 0.11
2 7.3e-004 3.5e+001 2.8e+000 -5.02e-001 -6.106752310e+007 1.461883779e+004 7.3e-004 0.11
3 7.8e-005 3.8e+000 2.8e-001 -1.60e-001 -1.873387513e+007 3.758070991e+004 7.8e-005 0.13
4 1.8e-005 8.8e-001 8.3e-002 1.31e-001 -6.331646268e+006 1.235036703e+006 1.8e-005 0.14
5 3.3e-006 1.6e-001 2.2e-002 3.98e-001 1.697492781e+007 1.942929444e+007 3.7e-006 0.14
6 2.9e-006 1.4e-001 2.1e-002 4.93e-001 1.402719986e+007 1.620577593e+007 3.2e-006 0.16
7 1.6e-006 7.6e-002 1.6e-002 6.77e-001 8.969813605e+006 1.024357620e+007 1.8e-006 0.16
8 1.0e-006 5.0e-002 1.3e-002 8.33e-001 6.217072891e+006 7.078546650e+006 1.2e-006 0.17
9 7.1e-007 3.5e-002 1.0e-002 9.59e-001 4.882448887e+006 5.496436446e+006 8.7e-007 0.17
10 4.6e-007 2.2e-002 8.4e-003 9.96e-001 3.540563135e+006 3.943738506e+006 5.6e-007 0.19
11 3.1e-007 1.5e-002 6.7e-003 1.00e+000 2.857356579e+006 3.132061543e+006 3.8e-007 0.19
12 1.9e-007 9.3e-003 4.8e-003 9.12e-001 3.061538766e+006 3.253755417e+006 2.4e-007 0.20
13 1.3e-007 5.4e-003 3.4e-003 7.75e-001 2.749800637e+006 2.877265333e+006 1.4e-007 0.20
14 1.1e-007 4.7e-003 3.1e-003 4.47e-001 2.566413472e+006 2.681926748e+006 1.2e-007 0.22
15 8.6e-008 1.4e-003 1.8e-003 8.90e-001 8.159637404e+005 8.499089910e+005 3.7e-008 0.23
16 6.3e-008 8.2e-004 1.6e-003 1.33e+000 3.975897475e+005 4.146601891e+005 2.2e-008 0.23
17 3.1e-008 2.7e-004 1.9e-003 1.62e+000 9.771690229e+004 1.011381172e+005 6.8e-009 0.25
18 2.0e-008 1.3e-004 1.3e-003 2.51e+000 1.029033347e+005 1.039205263e+005 4.0e-009 0.25
19 2.0e-008 1.3e-004 1.3e-003 1.92e+000 1.029033347e+005 1.039205263e+005 4.0e-009 0.27
Interior-point optimizer terminated. Time: 0.27.

Optimizer terminated. Time: 0.30

Interior-point solution summary
Problem status : ILL_POSED
Solution status : DUAL_ILLPOSED_CER
Primal. obj: 6.3349227852e+001 nrm: 2e+014 Viol. con: 4e+012 var: 8e-009 cones: 0e+000
Optimizer summary
Optimizer - time: 0.30
Interior-point - iterations : 20 time: 0.27
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: Failed
Optimal value (cvx_optval): NaN

When the solver fails, CVX populates CVX variables with NaN.

Mosek issues warnings about extremely large input data values. Perhaps you should consider the scaling 9unit choice) of input data, as well as whether the input data makes any sense.

Even the problem which Mosek solved has a very large optimal objective value, which is generally not a good thing.

Fix the scaling of your problem and also I would recommend the latest Mosek 9.3.

clc;
clear all;
close all;
cvx_solver mosek
%轨迹初始化
T = 120; %mission period
delta = T/120; %elemental length
N = T/delta; %number of time slot
K=6;
% 用户在移动
% 用户一的初始轨迹
% xw1 = 700;%圆心
% yw1 = 100;
% rw1 = 200;%radius
% theta = 0:2pi/(N-1):2pi;
% qw11 = xw1 + rw1cos(theta);
% qw21 = yw1 + rw1
sin(theta);
% qw11 = qw11’;
% qw21 = qw21’;
% w1 = [qw11,qw21];
%用户二的初始估计
% xw2 = 200;%圆心
% yw2 = 450;
% rw2 = 100;%radius
% theta = 0:2pi/(N-1):2pi;
% qw12 = xw2 + rw2cos(theta);
% qw22 = yw2 + rw2
sin(theta);
% qw12 = qw12’;
% qw22 = qw22’;
% w2 = [qw12,qw22];
w1 = [700ones(N,1),100ones(N,1)];
w2 = [200ones(N,1),450ones(N,1)];
w3 = [-300ones(N,1),450ones(N,1)];
w4 = [-600ones(N,1),200ones(N,1)];
w5 = [-450ones(N,1),-450ones(N,1)];
w6 = [400ones(N,1),-500ones(N,1)];

% 恶意干扰在移动
% 干扰点的初始轨迹
Jx1 =0 ;%圆心
Jy1 = 0;
Jw1 = 200;%radius
theta = 0:2pi/(N-1):2pi;
J11 = Jx1 + Jw1cos(theta);
J21 = Jy1 + Jw1
sin(theta);
J11 = J11’;
J21 = J21’;
J = [J11,J21];
% J = [0ones(N,1),0ones(N,1)];%恶意干扰信号位置

pm=0.001;%干扰功率
pmax=0.01;
B=10;
vmax = 30; %maximum speed
beta_db =-60; %单位距离下信道增益 dB
sigma_db = -148; %噪声强度dB
beta = 10^(beta_db/10);
sigma = 10^(sigma_db/10);
H = 100; %无人机高度
%初始轨迹
x11 = 0;%圆心
y11 = 0;
r1 = 400;%radius
theta = 0:2pi/(N-1):2pi;
% 无人机轨迹
q11 = x11 + r1cos(theta);
q21 = y11 + r1
sin(theta);
q11 = q11’;
q21 =q21’;
q1 = [q11,q21];
% q1=[38ones(N,1),5ones(N,1)];
eachIterNum = 1;
for iterNum =1:1:1
%无人机与用户位置d_r,u
d11 = H^2+(q1(:,1)-w1(:,1)).^2+(q1(:,2)-w1(:,2)).^2;
d12 = H^2+(q1(:,1)-w2(:,1)).^2+(q1(:,2)-w2(:,2)).^2;
d13 = H^2+(q1(:,1)-w3(:,1)).^2+(q1(:,2)-w3(:,2)).^2;
d14 = H^2+(q1(:,1)-w4(:,1)).^2+(q1(:,2)-w4(:,2)).^2;
d15 = H^2+(q1(:,1)-w5(:,1)).^2+(q1(:,2)-w5(:,2)).^2;
d16 = H^2+(q1(:,1)-w6(:,1)).^2+(q1(:,2)-w6(:,2)).^2;
d= H^2+(q1(:,1)-J(:,1)).^2+(q1(:,2)-J(:,2)).^2;

g1=beta./d11;
g2=beta./d12;
g3=beta./d13;
g4=beta./d14;
g5=beta./d15;
g6=beta./d16;
gm=beta./d;

cvx_begin
% cvx_precision best
variable eta

variable p1(N)
variable p2(N)
variable p3(N)
variable p4(N)
variable p5(N)
variable p6(N)
maximize eta
subject to

sum(B*log(1+p1.*g1./(pm.gm(:)+sigma)))/T>=eta;
sum(B
log(1+p2.*g2./(pm.gm(:)+sigma)))/T>=eta;
sum(B
log(1+p3.*g3./(pm.gm(:)+sigma)))/T>=eta;
sum(B
log(1+p4.*g4./(pm.gm(:)+sigma)))/T>=eta;
sum(B
log(1+p5.*g5./(pm.gm(:)+sigma)))/T>=eta;
sum(B
log(1+p6.*g6./(pm.*gm(:)+sigma)))/T>=eta;

p1+p2+p3+p4+p5+p6<=pmax;

0.001<=p1;
0.001<=p2;
0.001<=p3;
0.001<=p4;
0.001<=p5;
0.001<=p6;

cvx_end
optvalue1(iterNum) = cvx_optval;
eachOptValue(eachIterNum) = cvx_optval;
eachIterNum = eachIterNum + 1;

q1s=q1;
for cntTra=1:1:1
d11 = H^2+(q1s(:,1)-w1(:,1)).^2+(q1s(:,2)-w1(:,2)).^2;
d12 = H^2+(q1s(:,1)-w2(:,1)).^2+(q1s(:,2)-w2(:,2)).^2;
d13 = H^2+(q1s(:,1)-w3(:,1)).^2+(q1s(:,2)-w3(:,2)).^2;
d14 = H^2+(q1s(:,1)-w4(:,1)).^2+(q1s(:,2)-w4(:,2)).^2;
d15 = H^2+(q1s(:,1)-w5(:,1)).^2+(q1s(:,2)-w5(:,2)).^2;
d16 = H^2+(q1s(:,1)-w6(:,1)).^2+(q1s(:,2)-w6(:,2)).^2;
d= H^2+(q1s(:,1)-J(:,1)).^2+(q1s(:,2)-J(:,2)).^2;

Is=sigma+(beta.*pm)./d;%初始可行解
Ls1=d11./(beta.*p1);
Ls2=d12./(beta.*p2);
Ls3=d13./(beta.*p3);
Ls4=d14./(beta.*p4);
Ls5=d15./(beta.*p5);
Ls6=d16./(beta.*p6);

A1=-1./(Ls1+B*Ls1.^2.Is);%泰勒展开系数
A2=-1./(Ls2+B
Ls2.^2.Is);
A3=-1./(Ls3+B
Ls3.^2.Is);
A4=-1./(Ls4+B
Ls4.^2.Is);
A5=-1./(Ls5+B
Ls5.^2.Is);
A6=-1./(Ls6+B
Ls6.^2.*Is);

C1=-1./(Is+B*Is.^2.Ls1);%泰勒展开系数
C2=-1./(Is+B
Is.^2.Ls2);
C3=-1./(Is+B
Is.^2.Ls3);
C4=-1./(Is+B
Is.^2.Ls4);
C5=-1./(Is+B
Is.^2.Ls5);
C6=-1./(Is+B
Is.^2.*Ls6);

cvx_begin

variable q1(N,2)
variable L1(N)
variable L2(N)
variable L3(N)
variable L4(N)
variable L5(N)
variable L6(N)
variable I(N)

variable eta
variable m(N)
expression qu1(N,1)

maximize eta

subject to
sum(Blog(1+1./(Ls1(:).Is(:)))-abs(A1).(L1(:)-Ls1(:))-abs(C1).(I(:)-Is(:)))/T>=eta;%(1-1)
sum(Blog(1+1./(Ls2(:).Is(:)))-abs(A2).(L2(:)-Ls2(:))-abs(C2).(I(:)-Is(:)))/T>=eta;
sum(Blog(1+1./(Ls3(:).Is(:)))-abs(A3).(L3(:)-Ls3(:))-abs(C3).(I(:)-Is(:)))/T>=eta;
sum(Blog(1+1./(Ls4(:).Is(:)))-abs(A4).(L4(:)-Ls4(:))-abs(C4).(I(:)-Is(:)))/T>=eta;
sum(Blog(1+1./(Ls5(:).Is(:)))-abs(A5).(L5(:)-Ls5(:))-abs(C5).(I(:)-Is(:)))/T>=eta;
sum(Blog(1+1./(Ls6(:).Is(:)))-abs(A6).(L6(:)-Ls6(:))-abs(C6).(I(:)-Is(:)))/T>=eta;

for i=1:1:N

H^2+sum_square_abs(q1(i,:)-w1(i,:))<=beta.*p1.*L1(i)%(1-2)
H^2+sum_square_abs(q1(i,:)-w2(i,:))<=beta.*p2.*L2(i);
H^2+sum_square_abs(q1(i,:)-w3(i,:))<=beta.*p3.*L3(i);
H^2+sum_square_abs(q1(i,:)-w4(i,:))<=beta.*p4.*L4(i);
H^2+sum_square_abs(q1(i,:)-w5(i,:))<=beta.*p5.*L5(i);
H^2+sum_square_abs(q1(i,:)-w6(i,:))<=beta.*p6.*L6(i);

pm*beta.*inv_pos(m(i))+sigma<=I(i)%(1-3)

end

for i=1:1:N
qu1(i)=2*q1s(i,1)q1(i,1)-q1s(i,1)^2+J(i,1)^2-2J(i,1)q1(i,1)+2q1s(i,2)q1(i,2)-q1s(i,2)^2+J(i,2)^2-2J(i,2)*q1(i,2)+H^2;%一阶泰勒
end

m<=qu1;%1-4
m>=0;%(1-5)
q1(1,:slight_smile: == [38,5];
q1(N,:slight_smile: == [38,5];
for i = 1:1:N-1
norm(q1(i+1,:)-q1(i,:))<=vmax*delta;
end

cvx_end
q1s=q1;

optValueTrajectory(cntTra) = cvx_optval;
end
optvalue2(iterNum) = cvx_optval;
eachOptValue(eachIterNum) = cvx_optval;
eachIterNum = eachIterNum + 1;

end
CVX Warning:
Models involving “log” or other functions in the log, exp, and entropy
family are solved using an experimental successive approximation method.
This method is slower and less reliable than the method CVX employs for
other models. Please see the section of the user’s guide entitled
The successive approximation method
for more details about the approach, and for instructions on how to
suppress this warning message in the future.

Calling Mosek 9.1.9: 3000 variables, 1435 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 (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1435
Cones : 720
Scalar variables : 3000
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.02
Lin. dep. - number : 0
Presolve terminated. Time: 0.03
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1435
Cones : 720
Scalar variables : 3000
Matrix variables : 0
Integer variables : 0

Optimizer - threads : 8
Optimizer - solved problem : the primal
Optimizer - Constraints : 1435
Optimizer - Cones : 720
Optimizer - Scalar variables : 3000 conic : 2160
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.00 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 4675 after factor : 7309
Factor - dense dim. : 18 flops : 6.69e+04
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 3.6e+00 3.5e+00 6.0e+02 0.00e+00 5.960436473e+02 0.000000000e+00 1.0e+00 0.06
1 1.1e+00 1.1e+00 1.1e+02 5.43e-01 2.043426300e+02 -1.082815965e+01 3.2e-01 0.14
2 2.7e-01 2.6e-01 5.0e+00 1.33e+00 2.643180252e+01 -1.124141109e+01 7.5e-02 0.14
3 7.0e-02 6.9e-02 6.7e-01 2.43e+00 3.902638075e+00 -9.988838799e-01 2.0e-02 0.14
4 2.6e-02 2.6e-02 1.6e-01 1.28e+00 3.217895718e+00 1.489610385e+00 7.4e-03 0.14
5 8.9e-03 8.7e-03 3.2e-02 1.01e+00 3.145271874e+00 2.548523874e+00 2.5e-03 0.16
6 3.5e-03 3.4e-03 7.9e-03 9.78e-01 3.110894235e+00 2.874120452e+00 9.8e-04 0.16
7 1.3e-03 1.3e-03 1.8e-03 9.93e-01 3.104266244e+00 3.015912248e+00 3.6e-04 0.16
8 2.8e-04 2.7e-04 1.7e-04 9.96e-01 3.108672010e+00 3.089828367e+00 7.8e-05 0.16
9 3.2e-05 3.1e-05 6.6e-06 9.97e-01 3.111754722e+00 3.109585480e+00 8.9e-06 0.17
10 4.4e-06 4.3e-06 3.4e-07 9.99e-01 3.112130422e+00 3.111831895e+00 1.2e-06 0.19
11 1.4e-06 1.3e-06 5.8e-08 1.00e+00 3.112173497e+00 3.112081119e+00 3.8e-07 0.19
12 1.5e-07 1.5e-07 2.1e-09 9.98e-01 3.112191291e+00 3.112181061e+00 4.2e-08 0.19
13 1.2e-07 9.4e-08 1.1e-09 1.00e+00 3.112192464e+00 3.112185883e+00 2.7e-08 0.19
14 1.0e-08 7.2e-09 2.3e-11 1.00e+00 3.112194325e+00 3.112193824e+00 2.0e-09 0.19
15 2.7e-08 3.2e-09 6.8e-12 1.00e+00 3.112194410e+00 3.112194187e+00 9.1e-10 0.20
16 3.8e-08 3.2e-09 6.7e-12 1.00e+00 3.112194411e+00 3.112194189e+00 9.1e-10 0.20
17 6.6e-08 1.9e-09 3.1e-12 1.00e+00 3.112194437e+00 3.112194304e+00 5.5e-10 0.22
18 6.8e-08 7.5e-10 7.7e-13 1.00e+00 3.112194463e+00 3.112194411e+00 2.1e-10 0.22
Optimizer terminated. Time: 0.25

Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: 3.1121944633e+00 nrm: 4e+00 Viol. con: 3e-08 var: 2e-07 cones: 0e+00
Dual. obj: 3.1121944110e+00 nrm: 6e+00 Viol. con: 0e+00 var: 7e-12 cones: 0e+00
Optimizer summary
Optimizer - time: 0.25
Interior-point - iterations : 18 time: 0.22
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: Solved
Optimal value (cvx_optval): +3.11219

Calling Mosek 9.1.9: 90484 variables, 2158 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 (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 62: The A matrix contains a large value of -6.7e+10 in constraint ‘’ (720) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -6.9e+10 in constraint ‘’ (721) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -7.0e+10 in constraint ‘’ (722) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -7.0e+10 in constraint ‘’ (723) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -6.9e+10 in constraint ‘’ (724) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -6.8e+10 in constraint ‘’ (725) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -6.6e+10 in constraint ‘’ (726) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -6.3e+10 in constraint ‘’ (727) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -6.0e+10 in constraint ‘’ (728) at variable ‘’ (2).
MOSEK warning 62: The A matrix contains a large value of -5.6e+10 in constraint ‘’ (729) at variable ‘’ (2).
Warning number 62 is disabled.
MOSEK warning 710: #120 (nearly) zero elements are specified in sparse col ‘’ (2) of matrix ‘A’.
MOSEK warning 710: #120 (nearly) zero elements are specified in sparse col ‘’ (3) of matrix ‘A’.
MOSEK warning 710: #120 (nearly) zero elements are specified in sparse col ‘’ (4) of matrix ‘A’.
MOSEK warning 710: #120 (nearly) zero elements are specified in sparse col ‘’ (5) of matrix ‘A’.
MOSEK warning 710: #120 (nearly) zero elements are specified in sparse col ‘’ (6) of matrix ‘A’.
MOSEK warning 710: #120 (nearly) zero elements are specified in sparse col ‘’ (7) of matrix ‘A’.
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 2158
Cones : 959
Scalar variables : 90484
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Eliminator - tries : 0 time : 0.00
Lin. dep. - tries : 0 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.00
Optimizer terminated. Time: 0.06

Interior-point solution summary
Problem status : DUAL_INFEASIBLE
Solution status : DUAL_INFEASIBLE_CER
Primal. obj: -9.4800000000e+04 nrm: 4e+02 Viol. con: 0e+00 var: 0e+00 cones: 0e+00
Optimizer summary
Optimizer - time: 0.06
Interior-point - iterations : 0 time: 0.03
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

I modified my code, but NaN still appears during the iteration process, what should I do, thank you

On each iteration , the problems gets wilder, and at some iteration, the solver will fail to find an optimal solution, for one reason or another. Search this forum for my posts about the perils of “Successive Convex Approximation”.