Zhang Rui老师的将IRS引入无线通信安全的论文《Secure Wireless Communication via Intelligent Reflecting Surface》有较高的引用量,在此给出要论文的复现及代码。
该论文的目的是引入IRS并联合优化基站的主动式波束和IRS的被动式波束,使得抑制窃听者信噪比的同时最大化合法用户处的信噪比。其场景如下:
因此可以构造出以下的优化问题:
即在基站发射功率的约束下,优化基站和IRS的波束使得保密速率最大化。
可简单地将求绝对值的平方进行简单展开,令
将对数相减变换为真数相除,对数是单调递增函数,因此最大化对数,即是最大化真数即可。因此,可简化为以下的问题:
该结构可以参考文献[1]直接给出解的形式如下:
该部分推导较为复杂,可以详细阅读论文,如果有不懂的地方,可以评论或私信交流。主要是利用了分式规划将其转化为一个半正定松弛问题,求解该问题然后利用高斯随机化过程进行求解,转化后的问题如下所示:
clc;clear;
epsilon = 1e-3; % 收敛停止条件
% 天线数
M = 4; % AP天线数
Nx = 8;
Nz = 8;
N = Nx*Nz; % IRS单元个数
% 用户位置
APloc = [0;0]; % AP位置
userloc = [150;0]; % user位置
edloc= [145;0]; % 窃听者位置
IRSloc = [145;5]; % IRS位置
C0 = db2pow(-30); % 参考距离时的路损
D0 = 1; % 参考距离
sigmaK2 = db2pow(-80); % 噪声功率,-80dBm
L = @(d, alpha)C0*(d/D0)^(-alpha); % 路损模型
% 路损参数
alpha_AU = 3;
alpha_AE = 3;
alpha_AI = 2.2;
alpha_IU = 3;
alpha_IE = 3;
% 莱斯因子
K_AU = db2pow(1);
K_AE = db2pow(1);
K_AI = db2pow(1);
K_IU = db2pow(1);
K_IE = db2pow(1);
R = 1000; % 信道实现数
P_AP = db2pow(25); % 发射功率15dBm
论文中说明信道都为独立的莱斯信道,论文中有些信道考虑的是具有空间相关性的莱斯信道,需要在NLoS部分前后乘以一个相关系数矩阵,具体内容可以参考论文[1],为简化,在此没有考虑相关系数矩阵,则可以产生如下信道:
dAE = norm(APloc-edloc);
hAE = sqrt(L(dAE,alpha_AE)/sigmaK2)*(sqrt(K_AE/(1+K_AE))*ones(M,1)'+sqrt(K_AE/(1+K_AE))*(randn(1,M)+1i*randn(1,M))/sqrt(2));
dAU = norm(APloc-userloc);
hAU = sqrt(L(dAU,alpha_AU)/sigmaK2)*(sqrt(K_AU/(1+K_AU))*ones(M,1)'+sqrt(K_AU/(1+K_AU))*(randn(1,M)+1i*randn(1,M))/sqrt(2));
dAI = norm(APloc-IRSloc);
thetaIRS = atan(145/5);phi = 0; thetaAP = atan(5/145);
HAI = sqrt(L(dAI,alpha_AI)/sigmaK2)*(sqrt(K_AI/(1+K_AI))*URA_sv(thetaIRS, phi,Nx,Nz)*ULA_sv(thetaAP,M)'+sqrt(K_AI/(1+K_AI))*(randn(N,M)+1i*randn(N,M))/sqrt(2));
dIU = norm(IRSloc-userloc);
thetaIRS = -pi/4; phi = 0;
hIU = sqrt(L(dIU,alpha_IU))*(sqrt(K_IU/(1+K_IU))*URA_sv(thetaIRS, phi,Nx,Nz)'+sqrt(K_IU/(1+K_IU))*(randn(1,N)+1i*randn(1,N))/sqrt(2));
dIE = norm(IRSloc-edloc);
thetaIRS = 0; phi = 0;
hIE = sqrt(L(dIE,alpha_IE))*(sqrt(K_IE/(1+K_IE))*URA_sv(thetaIRS, phi,Nx,Nz)'+sqrt(K_IE/(1+K_IE))*(randn(1,N)+1i*randn(1,N))/sqrt(2));
q = 2*pi*rand(1,N); % 随机初始化IRS的相位
Q = diag(exp(1i*q));
% 给定q优化W
A = (hIU*Q*HAI+hAU)'*(hIU*Q*HAI+hAU); % 公式(9)
B = (hIE*Q*HAI+hAE)'*(hIE*Q*HAI+hAE); % 公式(10)
I_M = eye(M);
C = (B+1/P_AP*I_M)\(A+1/P_AP*I_M);
[V,D] = eig(C); % 特征值分解
[d,ind] = sort(diag(D));
u_max = V(:,ind(end))/norm(V(:,ind(end)));
w_opt = sqrt(P_AP) * u_max;
% 给定W优化q
hU = conj(hAU)*conj(w_opt)*(w_opt.')*(hAU.');
hE = conj(hAE)*conj(w_opt)*(w_opt.')*(hAE.');
GU = [diag(conj(hIU))*conj(HAI)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIU) diag(conj(hIU))*conj(HAI)*conj(w_opt)*(w_opt.')*(hAU.');...
conj(hAU)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIU) 0];
GE = [diag(conj(hIE))*conj(HAI)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIE) diag(conj(hIE))*conj(HAI)*conj(w_opt)*(w_opt.')*(hAE.');...
conj(hAE)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIE) 0]; % 公式(18)
q = SDR(hU,hE,GU,GE,N);
Q = diag(q);
R = max(0, log2(1+abs((hIU*Q*HAI+hAU)*w_opt)^2)- log2(1+abs((hIE*Q*HAI+hAE)*w_opt)^2))
function ura_sv = URA_sv(theta, phi,Nx,Ny)
m = 0:Nx-1;
a_az = exp(1i*pi*m*sin(theta)*cos(phi)).';
n = 0:Ny-1;
a_el = exp(1i*pi*n*sin(phi)).';
ura_sv = kron(a_az,a_el);
end
function ula_sv = ULA_sv(theta, M)
m = 0:M-1;
ula_sv = exp(1i*pi*m*sin(theta)).';
end
SDR求解问题(22a)
function [q,cvx_optval] = SDR(hU,hE,GU,GE,N)
L = 1000; % 高斯随随机化次数
cvx_begin sdp quiet
variable X(N+1,N+1) hermitian
variable mu1(1,1)
maximize(real(trace(GU*X)+mu1*(hU+1)))
subject to
real(trace(GE*X))+mu1*(hE+1)==1;
for i=1:N+1
En = zeros(N+1,N+1);
En(i,i)=1;
real(trace(En*X)) == mu1;
end
X == hermitian_semidefinite(N+1);
mu1 >= 0;
cvx_end
% 高斯随机化过程
%% method 1
max_F = 0;
max_q = 0;
S = X / mu1;
[U, Sigma] = eig(S);
for l = 1 : L
r = sqrt(2) / 2 * (randn(N+1, 1) + 1j * randn(N+1, 1));
q = U * Sigma^(0.5) * r;
if q' * GU * q > max_F
max_q = q;
max_F = q' * GU * q;
end
end
q = exp(1j * angle(max_q / max_q(end)));
q = q(1 : N);
end
以上程序是给定发射功率的单点优化程序,仿真随着发射功率变化的完整程序以及对比算法如下:
clc;clear;
epsilon = 1e-3; % 收敛停止条件
% 天线数
M = 4; % AP天线数
Nx = 8;
Nz = 8;
N = Nx*Nz; % IRS单元个数
% 用户位置
APloc = [0;0]; % AP位置
userloc = [150;0]; % user位置
edloc= [145;0]; % 窃听者位置
IRSloc = [145;5]; % IRS位置
C0 = db2pow(-30); % 参考距离时的路损
D0 = 1; % 参考距离
sigmaK2 = db2pow(-80); % 噪声功率,-80dBm
L = @(d, alpha)C0*(d/D0)^(-alpha); % 路损模型
% 路损参数
alpha_AU = 3;
alpha_AE = 3;
alpha_AI = 2.2;
% alpha_IU = 3;
alpha_IU = 2.3;
% alpha_IE = 3;
alpha_IE = 2.5;
% 莱斯因子
K_AU = db2pow(1);
K_AE = db2pow(1);
% K_AI = db2pow(1);
K_AI = db2pow(10);
% K_IU = db2pow(1);
K_IU = db2pow(10);
% K_IE = db2pow(1);
K_IE = db2pow(10);
P = db2pow(-5:5:25); % 发射功率15dBm
frame = 10;
maxIter = 20;
RSDR = zeros(length(P),1);
RMRT = zeros(length(P),1);
RWIRS = zeros(length(P),1);
RUB = zeros(length(P),1);
for p=1:length(P)
p
P_AP = P(p);
for fr = 1:frame
dAE = norm(APloc-edloc);
hAE = sqrt(L(dAE,alpha_AE)/sigmaK2)*(sqrt(K_AE/(1+K_AE))*ones(M,1)'+sqrt(K_AE/(1+K_AE))*(randn(1,M)+1i*randn(1,M))/sqrt(2));
dAU = norm(APloc-userloc);
hAU = sqrt(L(dAU,alpha_AU)/sigmaK2)*(sqrt(K_AU/(1+K_AU))*ones(M,1)'+sqrt(K_AU/(1+K_AU))*(randn(1,M)+1i*randn(1,M))/sqrt(2));
dAI = norm(APloc-IRSloc);
thetaIRS = atan(145/5);phi = 0; thetaAP = atan(5/145);
HAI = sqrt(L(dAI,alpha_AI)/sigmaK2)*(sqrt(K_AI/(1+K_AI))*URA_sv(thetaIRS, phi,Nx,Nz)*ULA_sv(thetaAP,M)'+sqrt(K_AI/(1+K_AI))*(randn(N,M)+1i*randn(N,M))/sqrt(2));
dIU = norm(IRSloc-userloc);
thetaIRS = -pi/4; phi = 0;
hIU = sqrt(L(dIU,alpha_IU))*(sqrt(K_IU/(1+K_IU))*URA_sv(thetaIRS, phi,Nx,Nz)'+sqrt(K_IU/(1+K_IU))*(randn(1,N)+1i*randn(1,N))/sqrt(2));
dIE = norm(IRSloc-edloc);
thetaIRS = 0; phi = 0;
hIE = sqrt(L(dIE,alpha_IE))*(sqrt(K_IE/(1+K_IE))*URA_sv(thetaIRS, phi,Nx,Nz)'+sqrt(K_IE/(1+K_IE))*(randn(1,N)+1i*randn(1,N))/sqrt(2));
q = 2*pi*rand(1,N); % 随机初始化IRS的相位
Q = diag(exp(1i*q));
R_old = 0;
R_new = 10;
count = 0;
while(abs(R_old-R_new)/R_new > epsilon && count < maxIter)
count = count + 1;
% 给定q优化W
A = (hIU*Q*HAI+hAU)'*(hIU*Q*HAI+hAU); % 公式(9)
B = (hIE*Q*HAI+hAE)'*(hIE*Q*HAI+hAE); % 公式(10)
I_M = eye(M);
C = (B+1/P_AP*I_M)\(A+1/P_AP*I_M);
[V,D] = eig(C); % 特征值分解
[d,ind] = sort(diag(D));
u_max = V(:,ind(end))/norm(V(:,ind(end)));
w_opt = sqrt(P_AP) * u_max;
% 给定W优化q, SDR
hU = conj(hAU)*conj(w_opt)*(w_opt.')*(hAU.');
hE = conj(hAE)*conj(w_opt)*(w_opt.')*(hAE.');
GU = [diag(conj(hIU))*conj(HAI)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIU) diag(conj(hIU))*conj(HAI)*conj(w_opt)*(w_opt.')*(hAU.');...
conj(hAU)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIU) 0];
GE = [diag(conj(hIE))*conj(HAI)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIE) diag(conj(hIE))*conj(HAI)*conj(w_opt)*(w_opt.')*(hAE.');...
conj(hAE)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIE) 0]; % 公式(18)
[q,upper_bound] = SDR(hU,hE,GU,GE,N);
Q = diag(q);
R_old = R_new;
R = max(0, log2(1+abs((hIU*Q*HAI+hAU)*w_opt)^2)- log2(1+abs((hIE*Q*HAI+hAE)*w_opt)^2));
R_new = R;
end
RSDR(p) = RSDR(p) + R;
RUB(p) = RUB(p) + log2(upper_bound);
% AP MRT with IRS
R_old = 0;
R_new = 10;
count = 0;
while(abs(R_old-R_new)/R_new > epsilon && count < maxIter)
count = count + 1;
% 给定q优化W
w_opt = sqrt(P_AP)*HAI(1,:)'/norm(HAI(1,:));
% 给定W优化q, SDR
hU = conj(hAU)*conj(w_opt)*(w_opt.')*(hAU.');
hE = conj(hAE)*conj(w_opt)*(w_opt.')*(hAE.');
GU = [diag(conj(hIU))*conj(HAI)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIU) diag(conj(hIU))*conj(HAI)*conj(w_opt)*(w_opt.')*(hAU.');...
conj(hAU)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIU) 0];
GE = [diag(conj(hIE))*conj(HAI)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIE) diag(conj(hIE))*conj(HAI)*conj(w_opt)*(w_opt.')*(hAE.');...
conj(hAE)*conj(w_opt)*(w_opt.')*(HAI.')*diag(hIE) 0]; % 公式(18)
[q,~] = SDR(hU,hE,GU,GE,N);
Q = diag(q);
R_old = R_new;
R = max(0, log2(1+abs((hIU*Q*HAI+hAU)*w_opt)^2)- log2(1+abs((hIE*Q*HAI+hAE)*w_opt)^2));
R_new = R;
end
RMRT(p) = RMRT(p) + R;
% without IRS
A = (hAU)'*(hAU); % 公式(9)
B = (hAE)'*(hAE); % 公式(10)
I_M = eye(M);
C = (B+1/P_AP*I_M)\(A+1/P_AP*I_M);
[V,D] = eig(C); % 特征值分解
[d,ind] = sort(diag(D));
u_max = V(:,ind(end))/norm(V(:,ind(end)));
w_opt = sqrt(P_AP) * u_max;
R = max(0, log2(1+abs((hAU)*w_opt)^2)- log2(1+abs((hAE)*w_opt)^2));
RWIRS(p) =RWIRS(p) +R;
end
end
plot(pow2db(P), RSDR/frame,'b-o','LineWidth',2)
hold on
plot(pow2db(P), RMRT/frame,'k-o','LineWidth',2)
plot(pow2db(P), RWIRS/frame,'r-.d','LineWidth',2)
plot(pow2db(P), RUB/frame,'m-.+','LineWidth',2)
grid on
xlabel('P_{AP} (dBm)')
ylabel('Average Secrecy Rate (bps/Hz)')
legend('Alternating Optimization with IRS','AP MRT with IRS','Optimal AP without IRS','Upper bound','Location','northwest')
可以看出不同算法的趋势基本复现,数值上可能有些不同,可能还是信道建模部分以及反射面个数的问题,不影响对于算法整体的理解。
[1] A. Khisti and G. W. Wornell, “Secure transmission with multiple antennas I: the MISOME wiretap channel,”IEEE Trans. Inf. Theory, vol. 56, no. 7, pp. 3088-3104, Jul. 2010.
有任何不清楚的写错或程序有误的地方,欢迎在评论区留言或私信交流!