Convergence Graph

clc
clear all
iterations=30;
%% Parameter
m=4; % number of BS
n=8; % number of RIS
K=1; % number of users in
L=1; % number of Eve
P=db2pow(30); %(watts) Maximum shared power source budget
eta_i= sqrt(10^(10/10)); % Maximum amplification coefficient at each reflecting element
epsilon=sqrt(0.002); % Bound level of estimation error
sigma_B=(db2pow(-90)); %(watts) Noise power
sigma_E=(db2pow(-90)); %(watts) Noise power
sigma_I=(db2pow(-90)); %(watts) Noise power
alpha_AI=2.1; % Pathloss exponent
d0 = 1; % pathloss reference distance
beta = 0.5; % Power splitting ratio
w = rand(m,1) + 1j * rand(m,1);
%%% Channels%%%
H_AI = rand(n, m) + 1j * rand(n, m);
disp(H_AI); % Display the channel matrix
h_IB = rand(1, n) + 1j * rand(1, n);
disp(h_IB); % Display the channel matrix
h_IE = rand(1, n) + 1j * rand(1, n);
disp(h_IE); % Display the channel matrix
%%% Rician Factor %%%
Rican_AI=5;
Rican_IB=5; Rican_IE=5;

%%%%% Large scale path loss
PL_0=10^(-30/10); %dB the channel gain at the reference distance
x_bs=0;
y_bs=0;
x_RIS=50;
y_RIS=50;
%% Channel Matrices and vectors

H_DA= sqrt((x_RIS-x_bs)^2+(y_RIS-y_bs)^2); %m distance from the BS to RIS
pathloss_AI = sqrt(PL_0*(H_DA)^(2.1)); % Large-scale pass loss from the BS to the RIS

x_user=100; y_user=0;
h_DB = sqrt((x_RIS-x_user)^2+(y_RIS-y_user)^2); %m distance from the RIS to the bob user
pathloss_IB = sqrt(PL_0*(h_DB)^(2.1)); % Large-scale pass loss from the RIS to the bob user

x_eve=50; y_eve=0;
h_DE = sqrt((x_RIS-x_eve)^2+(y_RIS-y_eve)^2); %m distance from the RIS to the Eve
pathloss_IE = sqrt(PL_0*(h_DE)^(2.1)); % Large-scale pass loss from the RIS to the Eve

%%%%% Rician Channel Fading %%%%%%%%%%%%%
%ricianCh(chSize, ricianFactor, dist, pathLossRef, distRef, pathLossExp, freq, phi)
H_AI = sqrt(1/2).*ricianCh([n m], 5, H_DA, PL_0, d0, alpha_AI, 2.4e9, pi/10); % Rician Channel for H_AI
h_IB = sqrt(1/2).*ricianCh([1 n], 5, h_DB, PL_0, d0, alpha_AI, 2.4e9, pi/10); % Rician Channel for h_IB
h_IE = sqrt(1/2).*ricianCh([1 n], 5, h_DE, PL_0, d0, alpha_AI, 2.4e9, pi/10); % Rician Channel for h_IE

%%Now generating the phase shift atrix in RIS
% Create phase shift matrix
phi = rand(n, n) + 1j * rand(n, n);

h_IE_bar = h_IE;

%% Optimize variable
%% AO algorithms
%% SCA algoritms
for ite=1:iterations

disp(['   ite = ', num2str(ite)])
cvx_begin
variable S;
variable mu;
variable t;


 %     S = 1;
 %     mu = 1;
t_bar = t;
t_til = t;
t_bar = exp(t_til)*(t-t_bar+1);
I = sigma_B + norm(h_IB*phi)^2 *sigma_I;
h_B = h_IB*phi*H_AI;
H_A = phi*H_AI;
C = t*sigma_I*phi*phi';
A = t*sigma_I*phi*phi'-phi*H_AI*w*w'*H_AI'*phi';
maximize(log(1+trace(h_B*S*h_B') / I)-t);
constraintA = trace(S) <= beta*P;
constraintB =  trace(H_A*S*H_A') <= (1-beta)*P;
subject to
    constraints1 = [constraintA, constraintB];
   
    
X = [C + mu*I - H_A*S*H_A' (C-H_A*S*H_A')*h_IE_bar';
     h_IE_bar*(C-H_A*S*H_A')  h_IE_bar*A*h_IE_bar'-mu*epsilon+t*sigma_E];
real(X) >= 0;
   S >= 0;
   mu >= 0;
   

cvx_end

disp(['   itePhy = ', num2str(ite)])
cvx_begin
variable V(n,n); 
variable mu;

tau = 1;

H_B = diag(h_IB)*H_AI*w*w'*H_AI'*diag(h_IB)';
H_IB = diag(h_IB)*diag(h_IB)';
H_I = diag(H_AI*w)*diag(H_AI*w)';
H_eff = (exp(t)-1)*sigma_I*I-(H_AI*w*w'*H_AI')';

trace(H_B*V)-tau*(sigma_B + trace(H_IB*V)*sigma_I);
constraint1 = trace((H_I + sigma_I * I) * V) <= (1 - beta) * P;
constraint2 = diag(V) <= eta_i; 

subject to
    
    constraints = [constraint1, constraint2];

             
    Y = [conj(V.*H_eff)+mu*I, conj(V.*H_eff)*h_IE_bar';
          h_IE_bar*conj(V.*H_eff)' h_IE_bar*conj(V.*H_eff)*h_IE_bar'+sigma_E*t_bar-mu*epsilon];
           
    real(Y) >= 0;  
          
       mu >= 0;
       tau > 0;
       cvx_end

end
%% Define the Secrecy Rate of Bob and Eve
B = log(1 + abs(h_IB * phi * H_AI * w)^2./ (sigma_B + norm(h_IB * phi)^2 * sigma_I)); % Secrecy Rate of Bob

E = log(1 + abs(h_IE * phi * H_AI * w)^2./ (sigma_E + norm(h_IE * phi)^2 * sigma_I)); % Secrecy Rate of Eve
%% Maximize Secrecy Rate
secrecy_rate = B - E;

%% Figure
plot(iterations,secrecy_rate,‘k-o’, ‘LineWidth’, 2);
xlabel(‘Number of iterations’);
ylabel(‘Secrecy rate(nat/s/Hz)’);
title(‘Convergence of AO’);

I need this graph so please help me .
image

I can’t run the program because you haven’t provided ricianCh.

For those who don’t have the Signal Processing Toolbox, such as myself, db2pow(x) = 10*log10(x).

I don’t see how the iterations are supposed to differ, because it appears that the loop variable, ite, is not used in the for loop, except for display.

You haven’t shown the solver or CVX for even one iteration. You should start by carefully examining and analyzing that.

If you have Mosek available as solver, use that; otherwise follow the instructions at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

I deleted an earlier topic by you which appeared to be essentially the same as this topic. In the future, please edit your existing topic, rather than creating an additional topic.

2 Likes