Algorithm cannot converge

clear all; clc;
% ========== System Parameters Initialization ==========
I = 3; % Number of UAVs
J = 2; % Number of RSUs
M = 2; % Number of vehicles
T = 5; % Time steps
% D = randi([3e4,5e4], T, I); % Data volume
% S = randi([4e2,1e3], T, I); % Task size
D = 4e4 * ones(T, I); % Data volume(3e4-5e4)4e4
S = 1e3 * ones(T, I); % Task size(1000)
% sigma2 = 1e-9; % Noise power
sigma2 = 1e-14; % Noise power(W)(-110dBm)
B_mj = 2e6 * ones(J, M); % Bandwidth(2MHz)
Gamma_L = 0.5; % Utility parameter of completing low-priority task on time
Gamma_H = 1; % Utility parameter of completing low-priority task past the time
c = 0.1; % Attenuation coefficient
p_max = 1; % Maximum transmit power(1W)
eta_max = 1.25e8;% Resource allocation upper limit(100-150MHz)
max_iter = 500; % Maximum iterations
tol = 1e-3; % Convergence tolerance
% delta = randi([6e6,8e6], I, 1); % UAV local computing resources (CPU Hz)
delta = 7e6 * ones(I, 1); % UAV local computing resources (CPU Hz)(6-8MHz)
P = rand(T,I,J);% Line-of-sight probability

r_ij = 3.226e6 * ones(T,I,J);% Transmission power between UAV i and RSU j
r_im = 6.452e6 * ones(T,I,J,M);% Transmission power between UAV i and vehicle m
g_mj = 7.14e-9 * ones(J,M);% Channel gain between vehicle m and RSU j(1/(1.4e8))
tau_i = zeros(T,I);
for t = 1:T
    for i = 1: I
        tau_i(t,i) = D(t,i) * S(t,i)/delta(i); % Task completion time threshold
    end
end
v = randi([0,1], T,I); % Task priority (0: low, 1: high)

beta = max(tau_i(:)) * 2;%1e3; % Big-M constant

% ========== Proposed method ==========

% ========== Initialize Variables ==========
theta1_prev = 0.5 * ones(T,I); % Initial task offloading ratio

T_1_prev = tau_i;
eta1_prev = 0.5 * eta_max/I *ones(T,I,J);
p_mi1_prev = 0.5 * p_max/I * ones(T,I,M);

% ========== SCA Iteration ==========
for k = 1:max_iter

    % --- Build convex optimization problem for current iteration ---
    cvx_solver Mosek
    cvx_begin
    variable theta1(T,I) % Optimization variable: task offloading ratio

    variable eta1(T,I,J) % RSU resource allocation
    variable p_mi1(T,I,M) % Vehicle transmit power
    variable T_1(T,I);% Time required for task ki(t)
    variable z1(T, I) binary;% Big-M auxiliary variable
    variable u1(T, I);

    variable T_off1(T, I);
    % --- Objective function definition ---
    total_utility1 = 0;
    for t = 1:T
        for i = 1:I
            term_local = (1 - theta1(t,i)) * S(t,i) * D(t,i) / delta(i);
            T_1(t,i) >= term_local;

            for j = 1:J
                for m = 1:M
                    % Transmission time of task from vehicle m to RSU j  
                    C = (theta1_prev(t,i)*D(t,i))/(B_mj(j, m) * (log(1 + p_mi1_prev(t,i,m) * g_mj(j,m) / sigma2)/log(2)))+ ...
                        ((theta1(t,i) - theta1_prev(t,i))*D(t,i))/(B_mj(j, m) * (log(1 + p_mi1_prev(t,i,m) * g_mj(j,m) / sigma2)/log(2)))- ...
                        ((theta1_prev(t,i)*D(t,i)* g_mj(j,m))/(log(2) * B_mj(j, m) * sigma2 * (1 + p_mi1_prev(t,i,m) * g_mj(j,m) / sigma2) * (log(1 + p_mi1_prev(t,i,m) * g_mj(j,m) / sigma2)/log(2))^2) ) * (p_mi1(t,i,m) - p_mi1_prev(t,i,m));
                    
                    % Mathematical expectation of transmission time from UAV i to RSU j for task
                    G = P(t,i,j) * ((theta1(t,i) * D(t,i))/r_ij(t,i,j)) + (1 - P(t,i,j)) * (((theta1(t,i) * D(t,i))/r_im(t,i,j,m)) + C);

                    % Computation time of task in RSU j
                    E = (theta1_prev(t,i)*S(t,i)*D(t,i))/eta1_prev(t,i,j) + ...
                        (theta1(t,i) - theta1_prev(t,i))*S(t,i)*D(t,i)/eta1_prev(t,i,j) - ...
                        (theta1_prev(t,i)*S(t,i)*D(t,i))/(eta1_prev(t,i,j)^2)*(eta1(t,i,j) - eta1_prev(t,i,j));

                    T_1(t,i) >= G + E;
                end
            end

            % Calculate task utility based on big-M method
            % T_1(t,i)<= tau_i
            f1 = v(t,i)*(log(1 + tau_i(t,i) - T_1(t,i))/log(2) + Gamma_L) + (1 - v(t,i))*Gamma_L;

            % T_1(t,i)> tau_i
            f2 = -v(t,i)*Gamma_H + (1-v(t,i))*Gamma_L * exp(-c*(T_1_prev(t,i) - tau_i(t,i))) ...
                - c*(1-v(t,i))*Gamma_L * exp(-c*(T_1_prev(t,i) - tau_i(t,i))) * (T_1(t,i) - T_1_prev(t,i));

            u1(t,i) <= f1 + beta * (1-z1(t,i))

            u1(t,i) <= f2 + beta * z1(t,i)

            total_utility1 = total_utility1 + u1(t,i);
        end
    end
    maximize(total_utility1)

    % --- Constraints ---
    subject to
    % Variable range constraints
    0 <= theta1 <= 1;% Constraint C2
    0.001 <= eta1 <= eta_max;% Constraint C3
    % Constraint C4
    for t = 1:T
        for j = 1:J
            sum(eta1(t,:,j)) <= eta_max;
        end
    end
    0.001 <= p_mi1 <= p_max;% Constraint C5
    % Constraint C6
    for t = 1:T
        for m = 1:M
            sum(p_mi1(t,:,m)) <= p_max;
        end
    end

    % Big-M method
    for t = 1:T
        for i = 1:I
            T_1(t,i) <= tau_i(t,i) + beta * (1 - z1(t,i));
            T_1(t,i) >= tau_i(t,i) - beta * z1(t,i);

        end
    end

    cvx_end

    % --- Check convergence ---
    a = norm(theta1 - theta1_prev, 'fro');
    if norm(theta1 - theta1_prev, 'fro') < tol
        break;
    end

    % --- Save previous iteration variable values ---
    if ~(anynan(theta1) || anynan(T_1) || anynan(eta1) || anynan(p_mi1))
    theta1_prev = theta1;
    T_1_prev = T_1;
    eta1_prev = eta1;
    p_mi1_prev = p_mi1;
    end
end

% ========== Output Results ==========
fprintf('Proposed method total utility: %f\n', cvx_optval);

The algorithm iterates to the maximum iterations each time (I tried up to 100 times at most and it still did not converge).
What could I do to fix it?

SCA is generally unreliable, and might not converge to anything, let alone a global or even local optimum of the original problem.

You should try to improve numerical scaling of input data, for instance by changing units, so that all non-zero input data is within a small number of orders of magnitude of 1. That might help your overall SCA performance, but not necessarily. Different (better) initialization values for the “SCA” variables might help, but not necessarily.