multi-dimensional sdpvar problem

99 views
Skip to first unread message

yunxiang da

unread,
Apr 19, 2021, 5:06:25 AM4/19/21
to YALMIP
Hi Johan,

I defined a three-dimensional variable Psij=sdpvar(N,Ng,Nm), but there was an error after running it.

error:Only full matrices are allowed to use n-dimensional indexes.

How can I solve this problem?

Thank you very much.

Johan Löfberg

unread,
Apr 19, 2021, 5:10:42 AM4/19/21
to YALMIP

no idea, you would have to supply a minimal reproducible example

yunxiang dai

unread,
Apr 19, 2021, 5:26:41 AM4/19/21
to YALMIP
Thank you for the help,This is part of the error code:
......
Psij=sdpvar(N,Ng,Nm);
Pinj=sdpvar(N,1);   
Wgij=binvar(N,Ng,);      
Wlkj=binvar(N,Ns);
Ptcw=sdpvar(N,Nm,);       
Ptcl=sdpvar(N,Nm); 
for s=1:Nm
    for j=1:N
        for i=1:Ng
            B1(j,i,s)=ps(1,s)*(ai(1,i)*Psij(j,i,s)^2+bi(1,i)*Psij(j,i,s)+ci(1,i)*Wgij(j,i));                   error:Incorrect use of sdpvar / subsasgn ( line 248 )  Only full matrices are allowed to use n-dimensional indexes.
        end
        for k=1:Ns
            B2(j,k,s)=ps(1,s)*(Wlkj(j,k,s)*a);      
        end
        B3(j,s)=ps(1,s)*(Ptcw(j,s)*kw+Ptcl(j,s)*kl)
    end
    C1(1,s)=sum(sum(B1));
    C2(1,s)=sum(sum(B2));
end
C=sum(C1)+sum(C2)+sum(sum(B3));     
......

Johan Löfberg

unread,
Apr 19, 2021, 6:51:13 AM4/19/21
to YALMIP
code cannot be run, i.e. not a reproducible example

yunxiang dai

unread,
Apr 19, 2021, 8:26:01 AM4/19/21
to YALMIP
Sorry, it can be solved when only a single scene is considered and psij is a binary variable. The following is the code when considering multiple scenes, psij is a three-dimensional variable. This will cause the program to run incorrectly.
uc.txt

Johan Löfberg

unread,
Apr 19, 2021, 8:31:27 AM4/19/21
to YALMIP
create a dummy variable B1=sdpvar(N,Ng,Nm) and it will run

yunxiang dai

unread,
Apr 19, 2021, 8:49:05 AM4/19/21
to YALMIP
Thank you very much. I'll have a try.
Reply all
Reply to author
Forward
0 new messages