errorInner matrix dimensions must agree. cvx_end

Uncategorized
May 31, 2020
W

when i rewriten the constraints into the convex and use cvx to solve it. but there is an error.
Error using *
Inner matrix dimensions must agree.
出错 cvxprob/eliminate (line 137)
P = P * cvx_invert_structure( xR );

出错 cvxprob/solve (line 18)
[ At, cones, sgn, Q, P, dualized ] = eliminate( prob, true, shim.dualize );

出错 cvx_end (line 88)
solve( prob );

出错 mec1 (line 73)
cvx_end

my code

while(error>tolerance&&step<Nmax)
step=step+1;

  cvx_begin
   variable l1(1,K)
   variable p(1,K)
   variable Rt(1,K)
   variable Rs(1,K)  
   variable phi(1,K)
   variable u(1,K) 
   variable pai(1,K)  
   variable w(1,K)
   variable B(K,K)
   variable b(1,K)
   variable B1(K,K)
   expression m(1,K)
   expression  c1(1,K)     
      E = zeta*pow_abs(c,3)*pow_abs(l1,3)/0.01 + p.*T;
        
   minimize(sum(E))
   subject to
       B + B' == ones(K) - eye(K);
       B == B1;
   for k = 1:K
           (L - l1(k))-10^5* Rs(k)<=0; 
           Rt(k) - log(1+b(k))<=0;
           b_old(k)*pai_old(k) + pai_old(k)*(b(k)-b_old(k))+b_old(k)*(pai(k)-pai_old(k))- gamma(k)*p(k)<=0;
           exp(-phi(k)*pow_abs(d,alpha)) <= epsilon;
           pai_old(k)*2^Rs_old(k)+2^Rs_old(k)*(pai(k)-pai_old(k))+pai_old(k)*2^Rs_old(k)*log(2)*(2^Rs(k)-2^Rs_old(k))-u(k)<=0;
           p_old(k)*u_old(k) + u_old(k)*(p(k)-p_old(k))+p_old(k)*(u(k)-u_old(k))- w(k)<=0;
           phi_old(k)*w_old(k) + w_old(k)*(phi(k)-phi_old(k))+phi_old(k)*(w(k)-w_old(k))- (pai(k)+gamma(k)*p(k)-u(k))*10^-6<=0;       
           for l = 1:K
               m(l) = gamma(l)*(B_old(k,l)*p_old(k)+B_old(k,l)*(p(k)-p_old(k))+p_old(k)*(B(k,l)-B_old(k,l)));
               %if  B_old(k,l)~=0  
                gamma(l)*(B_old(k,l)*p_old(l) + p_old(l)*(B(k,l)-B_old(k))+B_old(k)*(p(l)-p_old(l)))<=gamma(k).* p(k); 
                B(k,l)-(B_old(k,l)*B1_old(k,l)+B_old(k,l)*(B1(k,l)-B1_old(k,l))+B1_old(k,l)*(B(k,l)-B_old(k,l)))== 0 ;
              %end
           end
           m(k)=[];
           1+m(1)+m(2)<=pai(k)
   end      
  cvx_end  
   error=abs(sum(E)-sum_energy_old)/abs(sum_energy_old);
   %各种辅助变量的更新
   Rs_old = Rs;
   p_old = p;
   pai_old = pai;
   b_old = b;
   u_old = u;
   w_old = w;
   phi_old = phi;
   B_old = B;
   B1_old = B1;
   sum_energy_old=sum(E);
end
M

For diagnostic purposes, replace all CVX variables with numerically populated MATLAB variables. Is there a MATLAB error regarding incompatible dimensions? If so, you need to fix that. Then go back to the CVX variable declarations.

If not, then either there is a bug in CVX, or your installation is messed up, or you made use of implicit expansion https://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r2016b/ , which is not supported in CVX.

If you are using CVX 3.0beta, which is known to have many bugs, you should deinstall it and install CVX 2.2.

J

you solve this problem yet? I met the same problem like yours

J
Replying to #4