I am trying to solve Joint optimization problem with the CVX toolbox and second sub problem becomes concave + Convex as the sub problem gives negative powers (Even if I specify nonnegative ). Then program stops running . Please help me in this regardng

This is my optimization code:

%************************************************************
        %  Alternating Optimization Algorithm
        %************************************************************
                   
        % Random power (Is feasible ?)
        P_rand = P1;              % Maximum power allocated to each UE

        % Feasible receive beamforming for users
        w_k_initial=w_k;
        
        % Objective function related to Non-optimized
        [~,~,~,main_obj1] = objective_main(K,w_k_initial,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);

        EE_small_unopt(:,sim)=main_obj1; % Store unoptimized EE for each small scale setup
                          
        % Objective function
        J =  zeros(1,N_iter);

        for iter = 1 : N_iter

         % Update y (eq.2) and z_k (eq.4)
        [~,SINR_sqr,update_y,~] = objective_main(K,w_k_initial,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);
    
        y=update_y; % Update y
        z=SINR_sqr; % Update z
    
        % Modern optimization solver  
         cvx_solver mosek
    
         cvx_begin quiet
    
         variable P_opt(K) nonnegative
                    
         % Compute objective function (eq.5)
         [obj_power] = objective_power(K,w_k_initial,h_theta,P_opt,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS,y,z);
         obj = obj_power;
                    
         maximize real(obj)
                    
         % constraints
    
         % Target sensing constraint (eq.6)
         temp = 0;
         for k = 1:K
    
            temp = temp + ( norm( w_0'*h_theta(:,k) )^2 )*(P_opt(k));
                    
         end
                
         Gamma_t*( temp + norm(w_0'*h_s_i*v)^2 + sigma_sqr*( norm(w_0')^2 ) )...
                         <= sigma_sqr_t*(norm(w_0'*g_theta*v)^2);
    
         % Individual Rate constraint (QoS) (eq.7)
                    
          for k=1:K
    
            a2 = (norm(w_k_initial(:,k)'*h_theta(:,k))^2)*P_opt(k);
    
            b2=zeros(1,1);
    
            for mm=1:K
    
               if mm~=k
    
                   b2 =  b2 + (norm(w_k_initial(:,k)'*h_theta(:,mm))^2)*P_opt(mm);
                            %b1(:,k) = b;
                       
               end
                   
             end
                
             c2(k) = norm(w_k_initial(:,k)'*g_theta*v)^2;
             d2(k) = norm(w_k_initial(:,k)'*h_s_i*v)^2;
             e2(k) = norm(w_k_initial(:,k)')^2 ;
    
          (2^(R_min)-1)*( b2 + c2(k)*sigma_sqr_t + d2(k) + e2(k)*sigma_sqr)<= a2 ;          
    
          end
                                    
          % Individual Power Constraint (eq.8c)
    
          for k = 1:K
    
              P_opt(k) <= P;
    
              P_opt(k) >=0;
             
          end
    
          cvx_end
                          
    
          % cvx_status
    
          if strcmp(cvx_status,'Solved') %|| strcmp(cvx_status, 'Inaccurate/Solved') %|| strcmp(cvx_status,'Failed')
    
              P_rand = P_opt;
    
          else 
    
              % P_opt = P_rand;   % default value
    
          end   
          P_rand;
        % First optimize uplink transmit power allocation
        % [P_rand]=power_optimize(K,P,R_min,P_BS,P_UE,P_RIS,Gamma_t,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_rand,h_theta,g_theta,h_s_i,v,w_k_initial,w_0);   
                                      
        % Optimize Receiving beamforming for users 
        [SINR,SINR_sqr,~,~] = objective_main(K,w_k_initial,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);

        a_k=SINR; % SINR corresponding to optimized w_k
        b_k=sqrt(1+a_k).*SINR_sqr;
        
        % Modern optimization solver
        cvx_solver mosek
        
        % Solving problem (P4)
        cvx_begin  %quiet
        
        variable w_k_opt(Mr_rec,K) complex
        
        % Compute objective function (eq.11)
        [obj_Rxbeam] = objective_Rxbeam(K,w_k_opt,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,a_k,b_k);
        obj = obj_Rxbeam;
        
        maximize real(obj)
        
        % constraints
        
        % Individual Rate constraint (QoS) (eq.15)
        
        for k=1:K
            %n = pow_pos((norm(w_k_opt(:,k)'*h_theta(:,k))),2)*P1(k);
            f=zeros(1,1);
            for mm=1:K
                if mm~=k
                    f=  f + pow_pos(norm(w_k_opt(:,k)'*h_theta(:,mm)),2)*P_rand(mm);
                    %b1(:,k) = b;
                end
            end
            c1 = pow_pos(norm(w_k_opt(:,k)'*g_theta*v),2);
            d1 = pow_pos(norm(w_k_opt(:,k)'*h_s_i*v),2);
            e1 = pow_pos(norm(w_k_opt(:,k)'),2);
        
            (2^(R_min)-1)*( f + c1*sigma_sqr_t + d1 + e1*sigma_sqr)...
                <= (2*real ( w_k_initial(:,k)'*h_theta(:,k)*h_theta(:,k)'*w_k_opt(:,k))...
                -  norm ( w_k_initial(:,k)'*h_theta(:,k) )^2 ) *P_rand(k);
        
        end
        
        cvx_end
        
        % cvx_status
        
        if strcmp(cvx_status,'Solved') || strcmp(cvx_status, 'Inaccurate/Solved') %|| strcmp(cvx_status,'Failed')
        
            w_k_initial = w_k_opt;
        
        else
        
            % w_k_opt = w_k_initial;   % default value
        
        end

Error occurs at:

Error using +
Disciplined convex programming
error:
Illegal operation: {concave} +
{convex}

Error in objective_Rxbeam (line 14)
i2 = i2 + pow_pos(norm(w_k(:,k)'*h_theta(:,mm)),2)*P(mm);

Error in Opt_power_beamforming (line 199)
[obj_Rxbeam] = objective_Rxbeam(K,w_k_opt,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,a_k,b_k);

Even I specify the first sub probelm as nonnegative as given as:
variable P_opt(K) nonnegative

But optimization powers at this junction is obtained as:

P_opt =

-0.0000
-0.0000
0.0000
0.0000
0.0016
Because of the negative values, second problem becomes concave + convex.

And second problem is that Some powers are not satisfying the constraint as:

% Individual Power Constraint (eq.8c)

          for k = 1:K
    
              P_opt(k) <= P;
    
              P_opt(k) >=0;
             
          end
    But solution status is solved.

But if I run subproblem 1 individually, no negative powers obtained. When combined, negative powers obtained.

Please help in this regard!

1 Like

Either:

Use >= small_positive_number, such as 1e-6, instead of >= 0

or

Adjust any slightly negative solutions to nonnegative before providing as input to the next subproblem.

As to whether he overall algorithm then converges to anything, let alone a global or even local optimum of the original problem?

Adjust any slightly negative solutions to nonnegative before providing as input to the next subproblem. How to do it Sir?

As to whether he overall algorithm then converges to anything, let alone a global or even local optimum of the original problem? I am not understanding this question Sir.
Here, optimal powers has given to beamforming sub problem. And for the next iteration, optimal beamforming values given to power and this will continue upto convergence.

1 Like

If it converges, great? Whether it will, I have no idea.

After cvx_end,
P_opt = max(P_opt,minimum_desired_value);

where minimum_desired_value is whatever number you want to allow as the minimum value of elements of P_opt.` That can be 0, 1e-8, or whatever you choose.

Ok Sir.

I am getting this error as:

Unrecognized field name “sol”.

Error in cvx_mosek

Error in cvxprob/solve (line 435)
[ x, status, tprec, iters ] = shim.solve( At, b, c, cones, quiet, prec, solv.settings, eargs{:} );

Error in cvx_end (line 88)
solve( prob );

Error in Opt_power_beamforming (line 226)
cvx_end

MATLAB code has given as follows:

% Modern optimization solver
cvx_solver mosek

        % Solving problem (P4)
        cvx_begin  quiet
        
        variable w_k_opt(Mr_rec,K) complex
        
        % Compute objective function (eq.11)
        [obj_Rxbeam] = objective_Rxbeam(K,w_k_opt,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,a_k,b_k);
        obj = obj_Rxbeam;
        
        maximize real(obj)
        
        % constraints
        
        % Individual Rate constraint (QoS) (eq.15)
        
        % for k=1:K
        %     %n = pow_pos((norm(w_k_opt(:,k)'*h_theta(:,k))),2)*P1(k);
        %     f=zeros(1,1);
        %     for mm=1:K
        %         if mm~=k
        %             f=  f + pow_pos(norm(w_k_opt(:,k)'*h_theta(:,mm)),2)*P_rand(mm);
        %             %b1(:,k) = b;
        %         end
        %     end
        %     c1 = pow_pos(norm(w_k_opt(:,k)'*g_theta*v),2);
        %     d1 = pow_pos(norm(w_k_opt(:,k)'*h_s_i*v),2);
        %     e1 = pow_pos(norm(w_k_opt(:,k)'),2);
        % 
        %     (2^(R_min)-1)*( f + c1*sigma_sqr_t + d1 + e1*sigma_sqr)...
        %         <= (2*real ( w_k_initial(:,k)'*h_theta(:,k)*h_theta(:,k)'*w_k_opt(:,k))...
        %         -  norm ( w_k_initial(:,k)'*h_theta(:,k) )^2 ) *P_rand(k);
        % 
        % end
        
        cvx_end
1 Like

Make sure you are using CVX 2.2, not CVX 3.0beta.

What is the output of
mosekdiag

If that is successful, perhaps the MATLAB session is corrupted, in which case starting a new MATLAB session might resolve this. Or perhaps the CVX installation got corrupted, in which case reinstalling CVX in a new MATLAB session might resolve it.

1 Like

Yes cvx version is 2.2. Even after restarting the MATLAB session, same error occurs. I have not displaying the result in command window.

If I type mosekdiag in command window, then it is displaying as OK

1 Like

Do not use quiet and you should see in the log output what the problem is.

Unrecognized field name “sol”.

means that there was an error while running Mosek and the solution was not computed. Usually it is with either a license problem (which you claim is fine), or some humongous coefficients Mosek refuses to accept etc. The log output should explain the issue.

1 Like

Yes Sir, I am displaying the results in the command window now.

Now, the error is given as follows:

Calling Mosek 9.1.9: 320 variables, 130 equality constraints

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 57: A large value of 7.7e+11 has been specified in c for variable ‘’ (203).
MOSEK warning 57: A large value of 3.4e+11 has been specified in c for variable ‘’ (209).
MOSEK warning 57: A large value of 9.7e+11 has been specified in c for variable ‘’ (215).
MOSEK warning 57: A large value of 7.4e+11 has been specified in c for variable ‘’ (221).
Mosek error: MSK_RES_ERR_HUGE_C (A huge value in absolute size is specified for one an objective coefficient.)

Status: Error
Optimal value (cvx_optval): NaN

Unrecognized field name “sol”.

Error in cvx_mosek

Error in cvxprob/solve (line 435)
[ x, status, tprec, iters ] = shim.solve( At, b, c, cones, quiet, prec, solv.settings, eargs{:} );

Error in cvx_end (line 88)
solve( prob );

Error in Opt_power_beamforming (line 227)
cvx_end

1 Like

If this occurs on an iteration subsequent to the first, perhaps it’s a result of your alternating optimization diverging. You claimed it converges, I never did.

1 Like

Yes Sir, This is an iterative algorithm and optimized values from the sub problem-1 given to the sub problem-2.

The error occurs at solving sub problem-2.

Sir, What should be the solution to this issue?

1 Like

Make your algorithm more robust. how to do so is out of scope of this forum.

Or use a non-convex optimization solver under YALMIP.

1 Like

My optimization problem is convex only. If I use non-convex optimization solver YALMIP , will there any change in the solution?

1 Like

If your optimization problem is convex, why are you performing alternating optimization? It would appear that even though each subproblem is convex, the original (overall) problem is not convex.

1 Like

Yes Sir. Original problem is non-convex. Hence, we divide original problem into three sub problems and each sub problem becomes convex.
Each sub problem is getting solved using CVX without any issues , but when we do alternative optimization problem arises.
To get overall optimal solution. we are trying to perform AO algorithm as given below:

1 Like

Your problem is non-convex. Perhaps you’ll be luckier with a different starting value (initialization).

In reality, step 9 is until Convergence or Divergence or Neither. In your case, you are achieving divergence. Perhaps you should re-read my link above.

if the algorithm authors claim it always converges, I’ll let you resolve that with them.

1 Like

This error means you had coefficients bigger than 1e+16 somewhere. Surely you don’t want to solve optimization problems with that scaling, so you probably need to look at your data before feeding it into the solver again.

You can also use Mosek 10.1 instead of the older 9.1. It will not help with this error, but you may get better performance and stability overall once you tame the numerical issues.

1 Like

Yes sir, I will try to use Mosek 10.1 and Will verify the data before feeding to solver

1 Like

How to verify the data before feeding it to solver Sir? I do not know the procedure and there is no initial points to the CVX optimization problem as it will optimize based on the data given.

For example code is given as follows:

% Inner loop for N_sim random simulations
for sim=1:samples

       [g_t,g_r,d_t,d_r,G_t,G_r,h_r,h_d,w_0,h_s_i,h_theta,g_theta,w_k,v] = Channel_generator(C0_db,K,Mt_trans,Mr_rec,N,sigmaSI_sqr,antennaSpacing,alpha_BS_Target,alpha_RIS_Target,alpha_BS_RIS,alpha_UE_RIS,alpha_UE_BS,Rician,phi,Loc_BS,Loc_Target,Loc_RIS,Loc_UE);
                    
        %**************************************************************************
        % Optimize Uplink transmit power allocation
        %**************************************************************************
       
        % Random power (Is feasible ?)
        P_rand = P1;% Initial value

        [~,~,~,~,main_obj1] = objective_main(K,w_k,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);

        EE_small_unopt(:,sim)=main_obj1; % Store unoptimized EE for each small scale setup

        % P_rand = rand(K,1)*P; % Random power allocated to each user
        % 
        % [~,~,~,~,main_obj2] = objective_main(K,w_k,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);
        % 
        % EE_small_unopt1(:,sim)=main_obj2; % Store unoptimized EE for each small scale setup
        % 
        % Objective function related to power optimization
        J =  zeros(1,N_iter);

        for iter = 1 : N_iter
            p = iter; 

            % Update y (eq.2) and z_k (eq.4)
            [~,SINR_sqr,~,update_y,~] = objective_main(K,w_k,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);

            y=update_y; % Update y
            z=SINR_sqr; % Update z

            % Modern optimization solver  
            cvx_solver mosek

            cvx_begin quiet

            variable  P_opt(K) nonnegative
            
            % Compute objective function (eq.5)
             [obj_power] = objective_power(K,w_k,h_theta,P_opt,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS,y,z);
             obj = obj_power;
            
             maximize real(obj)

             subject to
            
            % constraints

            %Target sensing constraint (eq.6)
            temp = 0;
            for k = 1:K

            temp = temp + ( norm( w_0'*h_theta(:,k) )^2 )*(P_opt(k));

            end

            Gamma_t*( temp + norm(w_0'*h_s_i*v)^2 + sigma_sqr*( norm(w_0')^2 ) )...
                 <= sigma_sqr_t*(norm(w_0'*g_theta*v)^2);

            % Individual Rate constraint (QoS) (eq.7)
            
            % for k=1:K
            % a2 = (norm(w_k(:,k)'*h_theta(:,k))^2)*P_opt(k);
            % b2=zeros(1,1);
            % for mm=1:K
            %     if mm~=k
            %         b2 =  b2 + (norm(w_k(:,k)'*h_theta(:,mm))^2)*P_opt(mm);
            %         %b1(:,k) = b;
            %     end
            % end
            % c2(k) = norm(w_k(:,k)'*g_theta*v)^2;
            % d2(k) = norm(w_k(:,k)'*h_s_i*v)^2;
            % e2(k) = norm(w_k(:,k)')^2 ;
            % 
            % (2^(R_min)-1)*( b2 + c2(k)*sigma_sqr_t + d2(k) + e2(k)*sigma_sqr)...
            %          <= a2 ;          
            % 
            % end
                            
            % Individual Power Constraint (eq.8c)
            
            for k = 1:K

               P_opt(k) <= P;

               P_opt(k) >=0;

               
            end

           cvx_end
                  

        % cvx_status 

        if strcmp(cvx_status,'Solved') || strcmp(cvx_status, 'Inaccurate/Solved') %|| strcmp(cvx_status,'Failed') 

            P_rand = P_opt;

        else

           % P_opt = P_rand;   % default value

        end
         %P_opt
        % compute objective function
        [~,~,~,~,main_obj] = objective_main(K,w_k,h_theta,P_rand,g_theta,h_s_i,v,sigma_sqr_t,sigma_sqr,rho_UE,rho_BS,P_BS,P_UE,P_RIS);
        J(iter) = real(main_obj);
        %transmit_rate_UE;

        % test stopping criterion

        if N_iter > 1

            abs(J(N_iter) - J(N_iter-1)) <= tol;

            break;
        end
   
  end

Please help me in this regard.
Thanks in advance!

You can use MATLAB (double precision) commands and functions to check your input data. That does not involve CVX. Perhaps you are generating the input data in a bad way, in which case you should fix it. How to generate Monte Carlo input data in a good way is out of scope of this forum.

If you are using SCA without being an expert in computational non-convex nonlinear optimization, don’t be surprised if you have a never ending series of difficulties. Again, you’re pretty much on your own. it’s your research project, not the forum readers’ research project.