The following error occurs:Disciplined convex programming error: Illegal operation: {real affine} - {invalid}

The test code is as follows:
clc;
clear all;
close all;
tic;

cvx_solver Mosek_2;
cvx_save_prefs;

% Randomly generate task sizes
Sm_list = (rand(1) + 3) * 10^5; % The size of each task (bits)

% Set distance parameters
WDAP.distance = 10;
WDEve.distance = 15;
JamAP_distance = 50;
JamEve_distance = 8;

% Path loss parameters
alpha = 3;
belta = -30; % Reference path loss (dB)
belta = db2pow(belta); % Convert dB to mW

% Channel gain calculation
WDAP_H = belta * WDAP.distance ^ (-alpha);
JamAP_H = belta * WDEve.distance ^ (-alpha);

% System parameter settings
B = 1 * 10^6; % Total bandwidth (Hz)
p_max = 0.23; % Maximum transmission power (W)
Pj_max = 1; % Maximum cooperative jamming transmission power (W)

% Noise power settings
noise = -110; % Noise power (dB)
noise = db2pow(noise); % Convert dB to mW

% Initialize iteration parameters
iteration = 0;
Dink = ;
I = 0.2 * 10^6; % Number of bits or 200 kbits
nosie_z = 10^(3/10);
nosie_k = 10^(-120/10);
T_p = 0.5 * p_max;
T_Pj = 0.5 * Pj_max; % Used for SCA and Dinkelbach
T_W = log(1 + T_p * WDAP_H / (T_Pj * JamAP_H + noise)) / log(2);
epsilon = 1e-5; % Small positive number to prevent division by zero

% Objective function initialization
F1 = 0;
F2 = 0;
F3 = 0;
F4 = 0;

% Main loop starts
while 1
cvx_begin
variable p
variable Pj
variable T
variable V
variable W
expressions F1 F2 F3 F4

    % Update expressions
    F1 = I / (B * max(T_W, epsilon)) - (I * (W - T_W)) / (B * (T_W^2 + epsilon^2));
    F2 = W + log(Pj * JamAP_H + noise) / log(2) - log(T_p * WDAP_H + T_Pj * JamAP_H + noise) / log(2) - ...
        (WDAP_H * (p - T_p)) / ((T_p * WDAP_H + T_Pj * JamAP_H + noise) * log(2)) - ...
        (JamAP_H * (Pj - T_Pj)) / ((T_p * WDAP_H + T_Pj * JamAP_H + noise) * log(2));
    
    F3 = V - p * WDAP_H - nosie_k / nosie_z;
    F4 = log(nosie_k * nosie_z) / (2 * log(nosie_z)) - V / (2 * log(nosie_z));
    
    % Minimize the objective function
    minimize T
    subject to
        F1 >= T;
        F2 >= 0;
        F3 >= 0;
        F4 >= 0.98;

        p <= p_max;
        Pj <= Pj_max;
        p > 0;
        Pj > 0;
        T > 0;
        V > 0;
        W > 0;
cvx_end

iteration = iteration + 1;
T_p = p;
T_Pj = Pj;
T_W = W;
Dink = [Dink, cvx_optval];

if length(Dink) > 1 && abs(Dink(end) - Dink(end-1)) < 1e-2
    break
end

end

T_min = cvx_optval; % Minimum value

The following error occurs:
错误使用 + (line 83)
Disciplined convex programming error:
Illegal operation: {real affine} - {invalid}

出错 - (line 21)
z = plus( x, y, true, cheat );

出错 ceshi3 (line 64)
F1 = I / (B * max(T_W, epsilon)) - (I * (W - T_W)) / (B * (T_W^2 + epsilon^2));

The test code is believed to consist entirely of convex functions, and Mosek has been installed. Is the issue caused by the parameters?

Requesting the teacher to provide an help.

My guess: on an iteration, CVX did not solve a problem to optimality. Hence, the values populating the CVX variables after cvx_end for that iteration are NaN. When these values are used as input data in the next iteration, CVX will consider them invalid.

Is NaN*x^2 a convex expression with respect to a CVX variable x.? You can’t say it is. Neither can CVX. CVX can’t even determine what to do with NaN*x, for which the sign of NaN is irrelevant. Apart from convexity, what problem could it provide to the solver even if there were no convexity restriction?

Successive Convex Approximation (SCA) can be quite unreliable. See my many posts on this forum.

Teacher, I would like to ask if there is any way to make this unsolvable problem solvable, whether it can be made solvable again by modifying initial values or other methods. Additionally, I would like to know how unsolvable problems are generally judged so that I can determine the location of the code that needs to be modified.

First, look at CVX status and see why it failed. Numerical problems, or uinbounded, or infeasible? Mosek output provides good diagnostic information, including warning messages about very small or large magnitude numbers in input data.

Please read NaN——Status: Infeasible Optimal value (cvx-optval): - Inf - #2 by Mark_L_Stone