The cvx status : 'Infeasible'


(seven) #1

What should I do when the status is ‘Infeasible’ in cvx?
The code as following:

cvx_begin
     variable Ps(1,N)  %%  N 为 UAV飞行轨迹时隙的个数
     variable t_traj
     
     %expression rate2(1,N) 
       expression temp2_i(K,N)
       expression temp2_j(K,N)
      
  for n=1:N
        b2(n)=gamma.*alpha1_r(n);
        c2(n)=gamma.*(1-alpha1_r(n));
       for k=1:K  
    a2(k,n)=gamma.*alpha1_r(n)./(H^2+norm(Q_r(:,n)-W_locat(:,k)).^2);
    d2(k,n)=H^2+norm(Q_r(:,n)-W_locat(:,k)).^2;
    % e(n)=H^2+norm(Q_r(:,n)-W_locat(:,j)).^2;
    C_j2(k,n)=log(1+gamma.*alpha1_r(n).*Ps_r(n)./((H^2+norm(Q_r(:,n)-W_locat(:,k)).^2)+gamma.*(1-alpha1_r(n)).*Ps_r(n)));

    
 end
   end
   
      
    %C_j=log(1+(b2.*Ps)./(d2+c2.*Ps));
    % C_j=((c2+b2)-(d2.*(c2+b2-1)+(c2.^2-c2-b2-c2.*b2).*Ps).*inv_pos(d2+c2.*Ps));
    % C_j=log(1+b2.*inv_pos(c2)+(-b2.*d2.*inv_pos(c2).*inv_pos(c2.*Ps_r+d2)));
     % Cj=max(C_j);
    % C_j=log(1+b2.*inv_pos(c2)+(-b2.*d2.*inv_pos(c2).*inv_pos(c2.*Ps_r+d2)));
      
      % Cj=max(C_j);   
      for i=1:K
     temp2_i(i,:)=log(1+a2(i,:).*Ps);
     Ci2(i,:)=C_j2(i,:);
      end
     for j=1:K
       %  if j~=i
            temp2_j(j,:)=log(1+b2./c2+(-b2.*d2(j,:)./c2./(c2.*Ps_r+d2(j,:))))+d2(j,:).*b2.*(Ps-Ps_r)./(d2(j,:)+c2.*Ps_r)./(d2(j,:)+c2.*Ps_r+b2.*Ps_r);  
     end
      %temp2_j(j,:)=log(1+b2.*inv_pos(c2)+(-b2.*d2(j,:).*inv_pos(c2).*inv_pos(c2.*Ps_r+d2(j,:))))+d2(j,:).*b2.*(Ps-Ps_r)./(d2(j,:)+c2.*Ps_r)./(d2(j,:)+c2.*Ps_r+b2.*Ps_r);
     %ind=nchoosek(1:K,K-1);

%Cj2=arrayfun(@(x)max(temp2_j(ind(x,:),:))',1:K,'un',0);
%Cj2=flipud([Cj2{:}]');

    %Cj1(:,:)= max( C_j1(:,n));
  maxCol2=[];
for k=1:K
rowInd=[1:k-1 k+1:K];
 maxCol2=[maxCol2;max(C_j2(rowInd,:))];
end
        rate2=temp2_i- maxCol2;
         
       maximize ( t_traj)
       
subject to 

  %%%%%约束条件%%%%
  0<=Ps;
 sum(Ps)<= avg_Ps*N;
 sum(assignment1.*rate2,2)>=t_traj;
 
 for i=1:K
    for j=1:K
        if j~=i
            for n=1:N
   temp2_j(j,n)<=C_j2(i,n);
        end
    end
 end
 end
 %temp2_j<=Ci2;
 0<=t_traj;
 
cvx_end 

Ps_r=Ps;


(Mark L. Stone) #2

Try removing or relaxing constraints until the model becomes feasible.

If you find an infeasible constraint(s), you can try solving a new problem which minimizes the infeasibility(ies) instead of your actual objective function, and still subject to the other constraints.

Apply your subject matter knowledge of the problem you are solving.


(seven) #3

Thank you for your proposal.The problem is solved when i cancel the subject of"temp2_j".But the sudject is essential in the model ,so,is there any wrong in the subject of temp2_j"??


(Mark L. Stone) #4

It is your model. I have no idea what you are modeling, what the data input values should be, or whether the model and its input data do or do not make sense. You have to apply your subject matter knowledge ot consult other people who do have the requisite subject matter knowledge.


(seven) #5

OK.Thank you for your suggestion.