HELP!!Optimal objective function value: NaN 、 cvx_status: Failed

Uncategorized
Jul 10, 2024
C

function [] = CVXC()
    %参数初始化
    clear
    K = 10;
    Dk = repmat(5e6,1,K);
    Ck = 1000;
    alpha0 = 1e-5;
    sigma2 = 1e-13;
    beita = 1e-28;
    a1 = 1;
    a2 = 1;
    Pk = 0.1;
    PuR = 0.1;
    PuT = 1;
    
    i1= 1;
    Biu = repmat(0.5e6,1,i1);
    
    H = 100; % 示例高度值
    
    q_u = [750,750]; % 用户位置的示例坐标 (q^u)
    q_i = [250,250];
    q_k = [1493, 1082;
        250, 25;
        571, 1366;
        485, 1358;
        229, 775;
        501, 1056;
        715, 1457;
        37, 839;
        966, 627;
        911, 330;
        ];
    
    
    
    B_UAV = 20e6;
    F_UAV = 3e9;
    F_ki = 10e9;
    tau = 1e-10;
    %泰勒展开点
    okun = repmat(0.2,1,K);  
    okin = repmat(0.8,1,K);  
    fkun = repmat(F_UAV / length(Dk),1,K);  % 初始时,将总资源平均分配
    fkin = repmat(F_ki / length(Dk),1,K);   % 初始时,将总资源平均分配

    cvx_quiet(true);
    cvx_begin
        % 优化变量
        variable Bku(1,K) nonnegative
        variable oku(1,K)  nonnegative
        variable oki(1,K) nonnegative %非负ty
        variable fku(1,K) nonnegative
        variable fki(1,K) nonnegative
        variable g(1,K) nonnegative
        % 目标函数                        
            minimize  sum( a1 * ( beita .*Dk.*Ck .* ( oku .* pow_pos(fkun,2  ) + okun .* pow_pos(fku,2  ) +(tau .* oku / 2) .* ( oku -  (okun ).^2) + tau .* fku / 2 .*( fku -  (fkun).^2 )      )  ...
                                 + Dk.*PuR .*inv_pos(Bku .* log2(1 + ( ( alpha0 ./ (H^2 + norm(q_u - q_k)^2) ) * Pk) / sigma2))+...
                                 + sum( oki .* Dk.*PuT ./ (  Biu .* log2(1 + ( ( alpha0 ./ (H^2 + norm(q_u - q_i)^2) ) * PuT) / sigma2)  ) )...
                                ) ...
                          +a2 * ( Dk .*inv_pos( Bku .* log2(1 + ( ( alpha0 ./ (H^2 + norm(q_u - q_k)^2) ) * Pk) / sigma2) ) + g ) ...
                         ) 
        % 约束条件  
        subject to            
            sum( Bku ) <= B_UAV;
            sum( fku ) <= F_UAV;
            sum( fki ) <= F_ki;

            oku + oki == 1;
            0 <= oku <= 1;
            0 <= oki <= 1;

            Bku >= 0;
            fku >= 0;

            oki .* Dk ./ (  Biu .* log2(1 + ( ( alpha0 ./ (H^2 + norm(q_u - q_i)^2) ) * PuT) / sigma2)  ) +...
                Dk .* Ck .*( 1/2 * pow_pos( ( oki+1*inv_pos(fki) ),2  ) - ...
                pow_pos(okin,2  ) - pow_pos(1./fkin,2  ) - okin.*(oki - okin) + ...
                pow_pos(1./fkin,3  )  .* (1.*inv_pos(fki) - 1./fkin)) <= g;
            
            Dk .* Ck .*( 1/2 * pow_pos( ( oku+1*inv_pos(fku) ),2  ) - ...
                pow_pos(okun,2  ) - pow_pos(1./fkun,2  ) - okun.*(oku - okun) + ...
                pow_pos(1./fkun,3  ) .* (1.*inv_pos(fku) - 1./fkun)) <= g;

    cvx_end

    disp('Optimal objective function value:');
    disp(cvx_optval);
    disp('cvx_status:');
    disp(cvx_status);
    val = cvx_optval;

end

CVXC
Optimal objective function value:
NaN

cvx_status:
Failed

The title of paper is : Energy-Efficiency Computation Offloading Strategy in UAV Aided V2X Network With Integrated Sensing and Communication

M

The numerical scaling of the input data looks horrendous, and likely contributed to the failure of the solver.

You need to change units or something, so that all non-zero input data is within a small number of orders of magnitude of 1.

Also, don’t use the quiet option. Then you will see the solver and CVX output, which might be useful for diagnostic purposes.

B
Replying to #2

did you solve this problem?