Hi,
I have two questions about vectorizing the for loops in cvx. I would really appreciate any help.
q1) I vectorize the following for loop as bellow but in running I get the error “Operands to the || and && operators must be convertible to logical scalar values.” could any one help me?
for m_index=1 : U c1_=0; for b= 1 : S for k= 1 : C c1_= c1_ + ULA(b,m_index,k); end end c1(m_index)=c1_;
end
vectorized constraint:
variables ULA(S,U,C)
expressions c1(1,U)
m_index=1 : U;
c1=sum(ULA(:,m_index,:),[1 3]); %debugger stop here!
q2) I would appreciate your help to vectorize this code. I have read the How to vectorize most constraint loops in CVX thread, but I don’t figure out how to do that for bellow code:
for b=1 : S for n= 1 : D for k= 1 : C I_BU= 0; for bb= 1 : S if ( bb ~= b ) for nn= 1 : D if (nn ~= n) I_BU= I_BU + X(bb)* DL_p_t(bb,nn,k)* (G_bd(bb,n,k)/temp); end end end end C(b,n,k)=I_BU; end end end
Here, X, G_bd, DL_p_t are matrices with dimension of 1*
S and S*
D*
C, S*
D*
C respectively. DL_p_t is the only cvx variable.
Thanks in advance.