A problem about Subscript indices


(bloo) #1

here is part of my code:

cvx_begin
cvx_solver sedumi
variable rx(n,n) symmetric
variable px(n,n)
expressions L1(n) k1(n) r1(n) rate(1,n) s1(1,n) s2(1,n) s3(1,n)
expressions temp temp0 temp1

for i=1:n-1
   for j=i+1:n
    temp=rx(i,j)+px(i,j)*h(1,i)/z;
    temp0=rx(i,j)+px(i,j)*h(1,j)/z+px(j,i)*h(1,j)/z;
    L1(i,j)=-rel_entr(rx(i,j),temp)/log(2)-rel_entr(rx(i,j),temp0)/log(2);
    temp1=rx(i,j)+px(i,j)*h(1,j)/z;
    k1(i,j)=-rel_entr(rx(i,j),temp1)/log(2);
   end
end

for i=1:n
    temp=rx(i,i)+px(i,i)*h(1,i)/z;
    L1(i,i)=-rel_entr(rx(i,i),temp)/log(2);
end


for i=1:n-1
    for j=i+1:n
        c1=c1+t*w*( L1(i,j)-( v1(i,j)+ [v11(i,j) , v12(i,j) ]*( [rx(i,j),px(i,j)]-[r(i,j),p(i,j)] )' ));
    end
end

for i=1:n
    c2=c2+t*w*L1(i,i);
end

c=c1+c2;

for i=1:n
    for j=1:n
        if j<=i-1
            rate1=rate1+( L1(j,i)-( v1(j,i)+ [v11(j,i) , v12(j,i) ]*( [rx(j,i),px(j,i)]-[r(j,i),p(j,i)] )' ) );
        end
        if j>=i
            temp=rx(i,j)+px(i,j)*h(1,i)/z;
            rate2=rate2+( -rel_entr(rx(i,j),temp)/log(2));
        end
    end
    rate(1:i)=rate1+rate2;
    rate1=0;
    rate2=0;
end

            
for i=1:n-1
    for j=i+1:n
        s1(1,i)=px(i,j)-rx(i,j)*pnomamax;
        s2(1,i)=px(j,i)-rx(i,j)*pnomamax;
    end
end

for i=1:n
    s3(1,i)=px(i,i)-rx(i,i)*pomamax;
end


maximize (c)
subject to
sum(sum(triu(rx)))<=1
rate(:)>=1/30
s1(:)<=0
s2(:)<=0
s3(:)<=0
rx(:)>=0
px(:)>=0
cvx_end

and i got a error message like this:

Subscript indices must either be real positive integers or logicals.

Error in cvx_extract (line 344)
        tmpv = sum(dbcA(temp,:)~=0,2)==1;

Error in cvx_solve (line 26)
[ At, cones, sgn, Q, P, exps, dualized ] = cvx_extract( shim.config, shim.name );

Error in cvx_finish

Error in cvx_end (line 11)
    evalin( 'caller', 'cvx_finish' );

Error in test4noma (line 151)
cvx_end

I set the breakpoint and it will occur in execution the “cvx_end”.It looks like there is no invalid subscript indices
I wonder it is my problem or something else.
Thank you for your help.
there is some parameters needed and i will upload it later


(bloo) #2

I selected specific parameters for convenience.it is runable but having the problem that i mentioned above.

n=3;
c=0;



t=10e-4;
pnomamax=250;
pomamax=250;
w=15000000;%HZ
zd=3.98e-19;
z=zd*w;


h=[2.03331203990541e-12,6.01927438470192e-12,7.69444724926411e-12];
p=[0.432088232663684,0.432088232663684,0.432088232663684;0.347948830505372,0.347948830505372,0.347948830505372;82.5532962519483,82.5532962519483,82.5532962519483];
r=[0.00172835293065475,0.00172835293065475,0.00172835293065475;0,0.00208769298303219,0.00208769298303219;0,0,0.990639555023364];   


v1=zeros(n,n);
v11=zeros(n,n);
v12=zeros(n,n);

c1=0;
c2=0;
rate1=0;
rate2=0;

for i=1:n-1
    for j=i+1:n
        tem=p(i,j)*h(1,j)/(r(i,j)*z);
        v1(i,j)=r(i,j)*log2(1+tem);
        v11(i,j)=log2(1+tem)-tem/((1+tem)*log(2));
        v12(i,j)=(h(1,j)/z)/((1+tem)*log(2));
    end
end





cvx_begin
cvx_solver sedumi
variable rx(n,n) symmetric
variable px(n,n)
% rx=x(:,:,1);
% px=x(:,:,2);
expressions L1(n) k1(n) r1(n) rate(1,n) s1(1,n) s2(1,n) s3(1,n)
expressions temp temp0 temp1

for i=1:n-1
   for j=i+1:n
    temp=rx(i,j)+px(i,j)*h(1,i)/z;
    temp0=rx(i,j)+px(i,j)*h(1,j)/z+px(j,i)*h(1,j)/z;
    L1(i,j)=-rel_entr(rx(i,j),temp)/log(2)-rel_entr(rx(i,j),temp0)/log(2);
    temp1=rx(i,j)+px(i,j)*h(1,j)/z;
    k1(i,j)=-rel_entr(rx(i,j),temp1)/log(2);
   end
end

for i=1:n
    temp=rx(i,i)+px(i,i)*h(1,i)/z;
    L1(i,i)=-rel_entr(rx(i,i),temp)/log(2);
end


for i=1:n-1
    for j=i+1:n
        c1=c1+t*w*( L1(i,j)-( v1(i,j)+ [v11(i,j) , v12(i,j) ]*( [rx(i,j),px(i,j)]-[r(i,j),p(i,j)] )' ));
    end
end

for i=1:n
    c2=c2+t*w*L1(i,i);
end

c=c1+c2;

for i=1:n
    for j=1:n
        if j<=i-1
            rate1=rate1+( L1(j,i)-( v1(j,i)+ [v11(j,i) , v12(j,i) ]*( [rx(j,i),px(j,i)]-[r(j,i),p(j,i)] )' ) );
        end
        if j>=i
            temp=rx(i,j)+px(i,j)*h(1,i)/z;
            rate2=rate2+( -rel_entr(rx(i,j),temp)/log(2));
        end
    end
    rate(1:i)=rate1+rate2;
    rate1=0;
    rate2=0;
end

            
for i=1:n-1
    for j=i+1:n
        s1(1,i)=px(i,j)-rx(i,j)*pnomamax;
        s2(1,i)=px(j,i)-rx(i,j)*pnomamax;
    end
end

for i=1:n
    s3(1,i)=px(i,i)-rx(i,i)*pomamax;
end


maximize (c)
subject to
sum(sum(triu(rx)))<=1
rate(:)>=1/30
s1(:)<=0
s2(:)<=0
s3(:)<=0
rx(:)>=0
px(:)>=0
cvx_end

(Mark L. Stone) #3

This may be a bug in CVX 3.0beta.

I got Subscript indices must either be real positive integers or logicals error message using CVX 3.0beta build 1177. I “successfully” solved it (Inaccurate/solved) using CVX 2.1 build 1116.


(bloo) #4

well…I will try CVX2.1 later
thank you,