how do I solve this problem

``````% 引入CVX，并设置求解器为Mosek
%cvx_setup;
cvx_solver mosek;

% 清空CVX环境
cvx_clear;

% 定义问题数据

C = 64; % Quantization bits
q = 64;
V = 0.5; % Lyapunov weight
alpha = 1;
Round_num = 1000; % Total rounds of training
Device_num = 20; % Number of devices
Date_num = 128 * ones(1, Device_num); % Data amount for each device
d_c = 0.1; % Compute resource requirement
M = 878538;

%功率定义
% 生成服从正态分布的随机数向量
mu = 0;
sigma = 1;
rand_nums = mu + sigma * randn(1, Device_num);

% 对随机数向量进行标准化操作
rand_nums = (rand_nums - mean(rand_nums)) / max(abs(rand_nums)) * 1;

% 计算 Power_s
Power_s = 1.0 * ones(1, Device_num) - 0.05 * rand_nums;

% 计算 Power_ijD
Power_ijD = 1.0 * ones(Device_num, Device_num) - 0.05 * rand_nums;

% 计算 Power_jir
Power_jir = 1.0 * ones(Device_num, Device_num) - 0.05 * rand_nums;

a = zeros(20);
b = ones(1, Device_num);
Frequency = 1.5 * ones(1, Device_num) - 0.1 * rand_nums;
Band = 2e7;
Min_bandwidth = 0.1 / Device_num;
N0 = dBm_to_P(-174) * Band

%计算用户到基站的信道增益
H_i = zeros(1, Device_num);
% 假设 d 是距离，以千米为单位
d = 1; % 例如，假设距离为1千米
Device_num = 20;
% 先定义距离，信道增益根据距离计算
Distance_i = randi([0, 200], 1, 20);
% 计算信道增益
for k = 1:Device_num
H_i(k) = channel_gain(Distance_i(k)); % 调用 channel_gain 函数计算信道增益
end
%注：计算信道增益的公式，我不懂，但是都这么写：gain = 10^((-128.1 - 37.6 * log10(Distance_i / 1000)) / 10 - raylrnd(0.1));

%计算用户与用户之间的信道增益
H_ij = zeros(Device_num, Device_num); % 初始化信道增益矩阵
Distance_ij = randi([0, 200], Device_num, Device_num); % 生成随机距离矩阵，可以根据实际情况修改
for i = 1:Device_num
for j = 1:Device_num
H_ij(i, j) = channel_gain(Distance_ij(i, j)); % 调用 channel_gain 函数计算信道增益
end
end

T_total = [];
D2D_total = [];
E_final = [];
D2D_energy_total = [];
t_D2D = 0;
Energy_coefficient = 0.1; % Energy efficiency

% 定义CVX变量
cvx_begin
variable l_i_s(Device_num)
variable l_ij_d(Device_num, Device_num) symmetric % 定义对称矩阵变量
variable l_ji_r(Device_num, Device_num) symmetric
% 定义目标函数
for i = 1:Device_num
for j = 1:Device_num
k1 = Power_ijD(i) * H_ij(i, j) / (N0 * Band);
k2 = Power_jir(j, i) * H_i(j) / (N0 * Band);
k = (inv_pos(-rel_entr(l_ij_d(i, j), l_ij_d(i, j) + k1)) + inv_pos(-rel_entr(l_ji_r(j, i), l_ji_r(j, i) + k2))) * a(i, j) * q * M / Band;
D2D_total = [D2D_total; k] ;
end
t_D2D = sum(D2D_total);
T_total = [T_total;
d_c * Date_num(i) / Frequency(i) + ...
inv_pos(-rel_entr(l_i_s(i), l_i_s(i) + Power_s(i) * H_i(i) / (N0 * Band))) * ...
b(i) * q * M / Band + t_D2D];
D2D_total = [];
end
minimize(max(T_total));
% 添加约束条件
subject to
l_i_s >= 0 % 非负约束
l_ij_d >= 0
l_ji_r>=0
sum(l_i_s) + sum(l_ij_d) + sum(l_ji_r) ==1
cvx_end

% 打印结果

disp(['最小化目标函数值: ' num2str(V * max(T_total) + (1 - V) * sum(E_final))]);

function gain = channel_gain(d)
% 根据距离计算增益
rng('shuffle'); % 重新设置随机数种子，使得每次运行结果不同
gain = 10 ^ ((-128.1 - 37.6 * log10(d / 1000)) / 10 - raylrnd(0.1));
end
function p = dBm_to_P(b)
p = 10 ^ ((b - 30) / 10);
end

``````

Please tell us clearly what you need help with.

My optimization goal is to minimize T, and the expression for T is as follows (the optimization variable is highlighted in yellow), I used rel_entr(x,x+k), but I kept getting the following error:

Disciplined convex programming error:
Illegal operation: {real affine} + {invalid}
k = (inv_pos(-rel_entr(l_ij_d(i, j), l_ij_d(i, j) + k1)) + inv_pos(-rel_entr(l_ji_r(j, i), l_ji_r(j, i) + k2))) * a(i, j) * q * M / Band

Type each of the items in that line of code just prior to that line of code to see what it says. Most likely, at least one of them is `NaN`, which CVX considers to be `invalid`.