# When I solving the SOCP problem, the output is Nan?

%% 参数
clc;clear ;
Z_mc=1;
c=3e8;
f =28e9;%f=18.5e+9; 8e-3=0.008 0.5lambda
lambda=c/f;
dx=5e-3;% 0.5
lambda
dy=dx;
Ny=8;Nx=8;
kc=1j *2 *pi /lambda;
theta_0=0;%目标角度 *pi/180
phi_0=0;
% theta_i=30;%干扰角度 *pi/180
% phi_i=0;
% INR=30;
u=10.^(1./10);%主瓣阈值（上限）
l=10.^(-1./10);%主瓣阈值（下限）
taos=0.001;%旁瓣阈值（上限）30dB taos=0.001;%旁瓣阈值（上限）=10.^(-30./10); -30db
%% 目标导向矢量
a0_x=exp(kc *(0:Nx-1)’ *dx *sin(theta_0 *pi/180) *cos(phi_0 *pi/180));
a0_y=exp(kc *(0:Ny-1)’ *dy *sin(theta_0 *pi/180) *sin(phi_0 pi/180));
a0=kron(a0_x, a0_y);%导向矢量
a=a0’ Z_mc;%耦合导向矢量 1N
%% 主瓣导向矢量
theta_m=(-10:10);
phi_m=(-10:10);
M =length(theta_m);
for m=1:M
am_x=exp(kc * (0:Nx-1)’ * dx * sin(theta_m(m) * pi/180) * cos(phi_m(m) * pi/180));
am_y=exp(kc * (0:Ny-1)’ * dy * sin(theta_m(m) * pi/180) * sin(phi_m(m) * pi/180));
a10=kron(am_x, am_y);%导向矢量
a1(m,:)=a10’ * Z_mc;%耦合导向矢量 1
N
end
%% 旁瓣导向矢量
theta_s=[-91:4:-9,11:4:91];
phi_s=[-91:4:-9,11:4:91];
S =length(theta_s);
for s=1:S
as_x=exp(kc * (0:Nx-1)’ * dx * sin(theta_s(s) * pi/180) cos(phi_s(s) pi/180));
as_y=exp(kc * (0:Ny-1)’ * dy * sin(theta_s(s) * pi/180) sin(phi_s(s) * pi/180));
a20=kron(as_x, as_y);%导向矢量
a2(s,:)=a20’ * Z_mc;%耦合导向矢量 1
N
end
N=Ny * Nx;
%% cvx
yita=(u-l) * sqrt(Ny * Nx)/2;%导向矢量误差
cvx_begin
cvx_solver SeDuMi
variable w(N) complex %N
1
minimize(norm(w))%优化目标
subject to
a * w==1;
for m=1:1:M
real(a1(m, : ) * w) -yita * norm(w) >= l;%
norm(a1(m, : ) * w)+yita * norm(w) <= u;%
end
for s=1:1:S
norm(a2(s,: ) * w) +yita * norm(w)<= taos;%
end
cvx_end
% wopt=w% N
1

## Calling SeDuMi 1.3.4: 11240 variables, 276 equality constraints For improved efficiency, SeDuMi is solving the dual problem.

SeDuMi 1.3.4 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 276, order n = 383, dim = 11242, blocks = 150
nnz(A) = 29783 + 0, nnz(ADA) = 54546, nnz(L) = 27411
it : by gap delta rate t/tP t/tD* feas cg cg prec
0 : 4.60E+00 0.000
1 : 1.20E-01 1.71E+00 0.000 0.3723 0.9000 0.9000 3.87 1 1 6.4E+00
2 : -4.93E-01 3.93E-01 0.000 0.2298 0.9000 0.9000 0.15 1 1 6.0E+00
3 : -1.51E+01 2.22E-02 0.000 0.0563 0.9900 0.9900 -0.78 1 1 4.3E+00
4 : -7.54E+04 4.74E-06 0.018 0.0002 0.9999 0.9999 -0.99 1 1 4.4E+00
5 : -8.28E+07 4.26E-09 0.000 0.0009 0.9999 0.9999 -1.00 1 1 4.4E+00
6 : -1.92E+13 2.03E-14 0.000 0.0000 1.0000 1.0000 -1.00 1 1 5.0E+00

Dual infeasible, primal improving direction found.
iter seconds |Ax| [Ay]_+ |x| |y|
6 0.6 1.6e-13 2.0e-14 1.1e+01 6.2e-01

## Detailed timing (sec) Pre IPM Post 1.320E-01 2.410E-01 3.400E-02 Max-norms: ||b||=1, ||c|| = 1.258925e+00, Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.

Status: Infeasible
Optimal value (cvx_optval): +Inf

First: Improve the scaling so that non-zero input data is within a small number of orders of magnitude of one.

Second. if the problem is still reported as infeasible, follow the advice (except for section 1) in https://yalmip.github.io/debugginginfeasible .