Hello everyone, I have encountered this problem while writing the code, I have tested my code, some places are orders of magnitude (E10 / E-11), I also checked the forum posts and tried to normalize the operation and replace the solver, but still have the above problem, please help me

That’s the problem I’m trying to solve

This is my input

N = 4;

M = 20;

K = 5;

B = 10e6;

mu = 1;

savedata = 0;

%---------powers------------

noise_maxpower_original = 10^((-80-30) / 10);

% noise_maxpower = 1;

trans_maxpower =2 ;

%—computing limitation------

F_local_max= 1e9;

F_c_max = 20e9;

k_energy = 1e-28;

T_MAX = 3;

%-------input tasks-------------

user_task_para = zeros(K, 2);

for ii = 1 : K

user_data_amount(ii) =randi([250 350])* 1024 * 8;

user_circle(ii) = 500* randi([250 350])* 1024 * 8;

end

user_task_para = [user_data_amount’, user_circle’];

%% Simulation loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%—input channels------

num_loop = 1;

load(‘H_UB_all’);

load(‘H_UI_all’);

load(‘H_IB_all’);

for loop = 1 : num_loop

outerflag=1;

T1=cputime; %

tic;

H_UB=H_UB_all(1:N,1:K,loop) /sqrt(noise_maxpower_original);%^2：e17

H_UI =H_UI_all(1:M,1:K,loop) /sqrt(noise_maxpower_original);

H_IB = H_IB_all(1:N,1:M,loop) /sqrt(noise_maxpower_original);

noise_maxpower=1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% Initialize

A = zeros(K, 1);

phi_temp=randn(M,1) + sqrt(-1)* randn(M,1);

phi_ini=exp(1jangle(phi_temp));2

W_ini=randn(N,K);

W(:, :, 1)=full(W_ini);

phi(:, 1)=phi_ini;

Phi(:, :, 1) = diag((phi(:, 1))’);

Phi_ini = Phi(:, :, 1);

trans_power_ini=rand(K,1 );

trans_power (:, 1)=trans_power_ini;

F_c_ini = rand(K, 1)1e9;(user_circle(ii)).^3/T_MAX^2; %本地计算能耗

F_c(:, 1) = F_c_ini;

a_local = [];

for ii = 1 : K

if user_circle(ii)<= T_MAX * F_local_max

a_local = [a_local; ii];

end

A(a_local) = 1;

user_task_local = user_task_para(a_local);

end

E_local = [];

for ii = 1 : length(a_local)

E_local(a_local(ii)) = k_energy

end

E_local;

num_iterative = 300;

for n = 1 : num_iterative

xi_mintrans_power = 0;

xi_maxtrans_power =max(E_local);

%%%%% Optimize P and xi %%%%%

while 1

a_off = [];

xi_trans_power = (xi_maxtrans_power + xi_mintrans_power )/2;

for ii = 1 : length(a_local)

if E_local(a_local(ii)) > xi_trans_power

a_off = [a_off;a_local(ii)];

end

end

a_off ;

for ii = 1:length(a_off)

d(a_off(ii)) = user_circle(a_off(ii))/ F_c_ini(a_off(ii));

end

relax_scaler_delta = 1;

relax_scaler_omega = zeros(K,1);

relax_scaler_omega(a_off) = 1;

[trans_power_1, innerflag] = Generate_trans_power(B, K, a_off (:,n ),H_UI, H_IB, H_UB,…

noise_maxpower_original, trans_maxpower, Phi(:, :, n), W(:, :, n), F_c(:, n ), xi_trans_power, user_data_amount, user_circle, T_MAX, mu, relax_scaler_delta , relax_scaler_omega );

This is the function I made a mistake with

function [trans_power_opt, flag_P] = Generate_trans_power(B, K, a_off, H_UI, H_IB, H_UB,…

noise_maxpower_original,trans_maxpower ,Phi_ini, W_ini , F_c_ini, xi_trans_power, user_data_amount, user_circle, T_MAX , mu, relax_scaler_delta , relax_scaler_omega)

relax_scaler_delta_ini = relax_scaler_delta;

relax_scaler_omega_ini = relax_scaler_omega;

cvx_begin

variable trans_power_opt(K)

variable relax_scaler_omega(K)

variable relax_scaler_delta

for ii = 1:length(a_off)

a1(a_off(ii)) = (norm((W_ini(:, a_off(ii))’( H_IBPhi_iniH_UI(:, a_off(ii)) + H_UB(:, a_off(ii)))), 2)^2);%e10Phi_ini

y(a_off(ii))=((trans_power_opt(a_off(ii))norm((W_ini(:, a_off(ii))’( H_IBH_UI(:, a_off(ii)) + H_UB(:, a_off(ii)))), 2)^2))(noise_maxpower_original);

end

for ii = 1:length(a_off)

a2(a_off(ii)) = norm(W_ini(:, a_off(ii))’, 2)^2;

z_ini(a_off(ii))=((sum(y) - y(a_off(ii)))+((noise_maxpower_original)^2)norm(W_ini(:, a_off(ii))’, 2)^2) ;(xi_trans_power/mu);

end

for ii = 1:length(a_off)

constraint_2a(a_off(ii)) = trans_power_opt(a_off(ii))user_data_amount(a_off(ii)) - (B(log(1+relax_scaler_omega(a_off(ii))))/log(2))

constraint_2b(a_off(ii)) = user_data_amount(a_off(ii))inv_pos(Blog(1+ relax_scaler_omega(a_off(ii)) )/log(2)) + user_circle(a_off(ii))/ F_c_ini(a_off(ii)) - T_MAX;

constraint_3(a_off(ii)) = relax_scaler_delta - z_ini(a_off(ii));

constraint_4(a_off(ii)) = (relax_scaler_delta_ini/(2*relax_scaler_omega_ini(a_off(ii))))relax_scaler_omega(a_off(ii))^2+ (relax_scaler_omega_ini(a_off(ii))/ (2relax_scaler_delta_ini))*relax_scaler_delta^2 - y(a_off(ii));

end

subject to

for ii = 1:length(a_off)

real(constraint_2a) <= 0;

real(constraint_2b)<= 0 ;

real(constraint_3) >= 0;

real(constraint_4)<= 0;

0 <= trans_power_opt <= trans_maxpower;

relax_scaler_omega >= 0;

relax_scaler_delta >= 0;

end

cvx_end