Sum Log fuction optimisation error with CVX


(benbousseyf) #1

Hello every one;

I’m getting the below error while execute the optimisation function with CVX.

Warning: Empty objective.

In cvxprob/newobj (line 45)
In maximize (line 21)
In Virtual_RAN_optimisationnew (line 35)
Warning: Empty cvx model; no action taken.
In cvx_end (line 22)
In Virtual_RAN_optimisationnew (line 44)
{1x30 cell} {1x40 cell} {1x10 cell} {1x20 cell}
{1x30 cell} {1x40 cell} {1x10 cell} {1x20 cell}
{1x30 cell} {1x40 cell} {1x10 cell} {1x20 cell}

Please what’s the suggestion here?

My code is here:

clear all;
clc;
% VRRM effeciency
v=3; % Vno number (GB, BG and BE)
s=4; % Service number per VNO (Voice, Visio, Web and FTP)
Nsrv=v*s;
lambdav_s= [
    50 40 30 10; 
    25 20 15 5; 
    5 4 3 1]; % the priority of SLA agreement/service for each VNO 
Nusr=[30 40 10 20;
      30 40 10 20;
      30 40 10 20];        % Number of users per service for each VNO
Rcrrm=510; % the total agregated capacity 
Rvsservmin=[0.032 2 0.5 1 ; 
            0.032 2 0.5 1 ; 
            0 0 0 0]; % Minimum data rate required for each VNO's service
Rvsservmax=[0.064 10 510 510 ; 
            0.064 10 510 510 ; 
            0.064 10 510 510]; % Maximum data rate for each VNO's service
    Rvnomin=[204 204 0]; % Minimum data rate for each VNO
    Rvnomax=[357 510 510];
    cvx_begin
    Wusr= cell(v,s);
    sm=0;
    for vs=1:Nsrv
        sn=0;
        Wusr{vs}=cell(1,Nusr(vs));
        for i=1:Nusr(vs)
            sn=sn+(Wusr{vs}{i}*(Rvsservmax(vs)/Rcrrm));
        end
        sm=sm+lambdav_s(vs)*log(sn);
    end
    
    maximize(sm)
    x=Wusr;
    subject to
        for vs=1:Nsrv
            for i=1:Nusr(vs)
                Rvsservmin(vs)<=Wusr{vs}{i};
                Wusr{vs}{i}<=Rvsservmax(vs);
            end
        end
        
cvx_end
% Results
disp(Wusr);

Thanks a lot.


(Mark L. Stone) #2

Your cell commands are creating cell arrays of empty matrices. Therefore, all your subsequent operations create empty matrices. Therefore sm is an empty matrix as of the maximize(sm) statement, hence the error message. You would better see what is going on if you removed the semicolons at the end of statements.

I don’t know what you are trying to do, but perhaps it would be easier using multidimensional variables in CVX. .See mcg’s answer at Cvx sdp mode and cell arrays .
For example
variable joeblow(4,6,5)

Once you get the problem accepted by CVX, and given your use of log, I suggest you follow the advice in CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions .


(benbousseyf) #3

thanks for your reply, let’s me give more details.

i want to resolve the optimisation problem for the function by finding the optimal values of Wusr(vs,i).
here is the function with their constraints:

and here is the code that i’m trying to develop in order to get the result of the optimum values.

clear all;
clc;
% VRRM effeciency
v=3; % Vno number (GB, BG and BE)
s=4; % Service number per VNO (Voice, Visio, Web and FTP)
Nsrv=v*s;
lambdav_s= [
50 40 30 10;
25 20 15 5;
5 4 3 1]; % the priority of SLA agreement/service for each VNO
Nusr=[30 40 10 20;
30 40 10 20;
30 40 10 20]; % Number of users per service for each VNO
Rcrrm=510; % the total agregated capacity
Rvsservmin=[0.032 2 0.5 1 ;
0.032 2 0.5 1 ;
0 0 0 0]; % Minimum data rate required for each VNO’s service
Rvsservmax=[0.064 10 510 510 ;
0.064 10 510 510 ;
0.064 10 510 510]; % Maximum data rate for each VNO’s service
Rvnomin=[204 204 0]; % Minimum data rate for each VNO
Rvnomax=[357 510 510];

cvx_begin
% Optimization function 
Wusr= cell(v,s);
sm=0;
for vs=1:Nsrv
    sn=0;
    Wusr{vs}=cell(1,Nusr(vs));
    for i=1:Nusr(vs)
        sn=sn+(Wusr{vs}{i}*(Rvsservmax(vs)/Rcrrm)); 
    end
    sm=sm+lambdav_s(vs)*log(sn);
end

maximize(sm)
x=Wusr;
subject to

Wusr{vs}{i}<=1;
Wusr{vs}{i}>=0;

% First constraint
    for vs=1:Nsrv
        for i=1:Nusr(vs)
            Rvsservmin(vs)<=Wusr{vs}{i};  
            Wusr{vs}{i}<=Rvsservmax(vs);  
        end
    end
    
  % Second constraint
  
  sm1=0;  
for vs=1:Nsrv
    sn1=0;
    Wusr{vs}=cell(1,Nusr(vs));
    for i=1:Nusr(vs)
        sn1=sn1+(Wusr{vs}{i}*(Rvsservmax(vs)));
    end
    sm1=sm1+sn1;
    sm1<=Rvnomax;
    sm1>=Rvnomin;
end
   
    
    % Third constraint
  
  sm2=0;  
for vs=1:Nsrv
    sn2=0;
    Wusr{vs}=cell(1,Nusr(vs));
    for i=1:Nusr(vs)
        sn2=sn2+(Wusr{vs}{i}*(Rvsservmax(vs)));
    end
    sm2=sm2+sn2;
end
    sm2<=Rcrrm;

cvx_end
% Results
disp(Wusr)

Waiting for your kind support.


(Mark L. Stone) #4

The optimization problem in the image has an objective function which is a weighted sum of logarthm of affine (linear) function of the optimization variable. The constraints are affine (linear) in the optimization variable. Therefore, entry into CVX is extremely straightforward, other than care being required to organize and properly index into the various input data. So that is really a matter of MATLAB syntax, not CVX syntax. I don;t feel like trying to figure out what all the indexing of your data is. You could start with a simpler problem, something like

cvx_begin
variables x(2,1)
maximize(2*log(3*x(1)) + 4*log(5*x(2)))
1 <= x <= 2
cvx_end

Then build up to the more complicated data structures.

I advise you not to use cells, although I suppose it is possible to correctly enter the program using cells.Try using arrays, to include 3-D arrays as necessary. As I advised you before, remove the semicolons at the end of statements so that you can see the result of each statement, which will help you debug your program. You can also use whos to see the dimensions of various item, which will help debug your program.


(benbousseyf) #5

I used cell because we have variable size 3d matrix, This matrix has 34n.
Where n is change in each 2d index(1:3,1:4), This is why Because 3d matrix must has fixed size, Not variable size


(Mark L. Stone) #6

You just need to carefully index. Build up your program from a simplified version.

Whatever you do with cells and indexing needs to work in MATLAB, i.e., without CVX variables or expressions, or it won’t work in CVX.

If we get rid of the yucky notation and indexing into data, the essence of your CVX program is extremely simple.