How to express this optimization problem in CVX?

(sun) #1

The optimization problem is described below:


1:=================================================================
image
2:=================================================================
image
3:=================================================================
image
4:=================================================================

I wrote the following code, but it doesn’t seem to be correct. I hope someone can help me, I will be very grateful!

    clc,clear;
    %%========================Initialization parameter
    T=400;%Total flight duration
    N=T/0.5;%The flight time slot
    D=3*0.5;%Maximum flight distance
    H=100;%altitude
    P=-5;%The initial power
    Ppeak=4*P;%Maximum power value
    r0=80;%SNR
    Lambda=100;%A coefficient in a power expression
    v=10^(-4);%The convergence accuracy                                  
    %++++++Initializes the coordinate value
    xf=100;%UAV terminal coordinates
    yf=-600;
    x0=100;%UAV origin coordinates
    y0=600;
    xe=200;%Eavesdropper coordinates
    ye=0;
    xg=0;%Legitimate coordinates
    yg=0;
    %++++++Initialization variable
    xfea=100;
    yfea=600;
    ufea=580000;



    %%======================Use the CVX toolbox to find x, y
    for k=1:N

    cvx_begin 
        variables x(1,N) y(1,N) u(1,N) t(1,N);
        
    %++++++Compute the concave function f
         f=0;
         for i=1:N
             g=-P*u(1,i)/(log(2)*(ufea^2+P*ufea));
             h=-(rel_entr(t(1,i),t(1,i)+P)+rel_entr(t(1,i)+P,t(1,i)))/log(2);
             f=g+h+f;
         end
         
         maximize(f);
         
         subject to
         
         %+++++++C1
         for n=1:N
             t(1,n)+xfea^2-2*xfea*x(1,n)+2*xe*x(1,n)-xe^2+yfea^2-2*yfea*y(1,n) ...
                 +2*ye*y(1,n)-ye^2-H^2<=0;
         end
        
           %++++++++C2
             (x(1,1)-x0)^2+(y(1,1)-y0)^2<=D^2;
               for m=1:N-1
                    (x(1,m+1)-x(1,m))^2+(y(1,m+1)-y(1,m))^2<=D^2;
               end
             (xf-x(1,N))^2+(yf-y(1,N))^2<=D^2;
        
       %++++++++C3
         for n=1:N
            x(1,n)^2-2*xg*x(1,n)+xg^2+y(1,n)^2-2*yg*y(1,n)+yg^2+H^2-u(1,n)<=0;
         
        %++++++++C4
            t(1,n)>=H^2;
         end
         
         cvx_end
        
        fprintf('%f %f %f %f\n',x(1,k),y(1,k),u(1,k),t(1,k));
        xfea=x(1,k);
        yfea=y(1,k);
        ufea=u(1,k);
    end

It keeps displaying the following information after running. I don’t know why

(Mark L. Stone) #2

What is the output from cvx_version ? if using CVX 3.0beta, please switch to CVX 2.1.

Does the program make it through the first time through cvx_begin ... cvx_end ? If so, is the result that the problem is solved? Is it infeasible? Why is there for k=1:N loop outside cvx_begin .. cvx_end ?

I changed the outside for loop to for k=1:1 and the program ran to completion, declaring the problem to be infeasible. Please read https://yalmip.github.io/debugginginfeasible/ . I haven’t actually looked at your model or implementation, and have no idea if it is correct.

Perhaps you should start with a smaller version of the problem and get that working correctly before going to the full-size version.

(sun) #3

Thank you very much for your answer. I don’t think my program is due to the CVX version. And I’m sure there’s nothing wrong with my model. In fact, I edited another executable program, but the result wasn’t what I wanted. Maybe I need to modify some of the initial values of the program to get the results I want. Nevertheless, I am very grateful for your reply.

(Mark L. Stone) #4

Search this forum for narginchk and you will see why I asked you to show the output of cvx_version .

(sun) #5

ok

(Mark L. Stone) #6

With regard to the narginchk error, I suggest you reinstall CVX, and look carefully for any errors or warnings during installation.

(sun) #7

OK,thank you for your reply.
I 've solved the problem,and I reinstall a new version MATLAB,from MATLAB 2016a to MATLAB 2018b,the warning never come back.