The optimized parameter b (k) is greater than or equal to a positive number, but in each iteration, the non negative constraint on b (k) does not work. Why is this? Please help to clarify, thank you very much.
clc;
clear;
noise = 10^(-13);
load('tur1_50.mat')
k_lam = 0.1514;
lamda = 530*10^-9;
rho = 0.9 * 1.6 * 10^-19 / (6.626 * 10^-34 * 3 * 10^8 / lamda);
K = 2;
Pt = 2;
tolerance = 1e-4;
tPrevious = -inf;
for k = 1: K + 1
dist_d = 10;
var_d(k) = tur1_30(dist_d, 2);
pathl_r(k) = 0.01 * 0.9 * 0.9 / (2 * pi) / (1 - cos(10/180 * pi)) / cos(10/180 * pi) / dist_d.^2 * exp(-k_lam * dist_d);
dist_e = 35;
var_e(k) = tur1_30(dist_e, 2);
pathl_e(k) = 0.01 * 0.9 * 0.9 / (2 * pi) / (1 - cos(10/180 * pi)) / cos(10/180 * pi) / dist_e.^2 * exp(-k_lam * dist_e);
end
%% Initial value
maxIter = 30;
for i = 1 : K + 1
p_pre(i) = 1;
b_pre(i) = exp(4 * var_e(i)) * (rho * p_pre(i) * pathl_e(i))^2 + noise;
end
%% CVX
for iter = 1:maxIter
cvx_begin quiet
cvx_solver sdpt3
variable p(1, K + 1) nonnegative;
variable t;
variable b(1, K + 1) nonnegative;
maximize(t) % The goal is to maximize t
subject to
rth = 1;
for k = 1:K+1
p(k) >= 0;
% !!B (k) is displayed as a negative value after each optimization
% !!On the right side of the inequality is a positive value
% !!The constraint did not work
b(k) >= exp(4 * var_e(k)) * (rho * p(k) * pathl_e(k))^2 + noise;
2^t <= (2 * (exp(4 * var_d(k)) * (rho * pathl_r(k))^2 * p(k) * p_pre(k)) + 2 * noise) / b_pre(k) - (noise + exp(4 * var_d(k)) * (rho * pathl_r(k) * p_pre(k))^2 ) * b(k) / b_pre(k)^2;
2^rth <= (2 * (exp(4 * var_d(k)) * (rho * pathl_r(k))^2 * p(k) * p_pre(k)) + 2 * noise) / b_pre(k) - (noise + exp(4 * var_d(k)) * (rho * pathl_r(k) * p_pre(k))^2 ) * b(k) / b_pre(k)^2;
end
sum(p) <= Pt; % power
cvx_end
if abs(t - tPrevious) <= tolerance
break;
end
% Record the current value for the next round
b_pre = b;
tPrevious = t;
p_pre = p;
end
disp('MAX-ASC:');
disp(t);
disp('p:');
disp(p);