# How to formulate this constraint in CVX?

Let, D=[d_1,d_2,\cdots,d_T] is a known vector.
t is an optimization variable, L of size T\times S is an binary optimization variable
R^{(1)},R^{(2)},\cdots,R^{(T)} are known matrices
Z^{(1)},Z^{(2)},\cdots,Z^{(T)} are optimization variables

Note that Z^{(p)} and R^{(p)} are of same size.
Z^{(1)} and Z^{(2)} can be of different sizes.

\begin{bmatrix} \left(\sum_{m=1}^{M_1}\sum_{n=1}^{N_1}Z^{(1)}_{m,n}R^{(1)}_{m,n}\right)L_{1,1} & \left(\sum_{m=1}^{M_1}\sum_{n=1}^{N_1}Z^{(1)}_{m,n}R^{(1)}_{m,n}\right)L_{1,2} & \cdots & \left(\sum_{m=1}^{M_1}\sum_{n=1}^{N_1}Z^{(1)}_{m,n}R^{(1)}_{m,n}\right)L_{1,S} \\ \left(\sum_{m=1}^{M_2}\sum_{n=1}^{N_2}Z^{(2)}_{m,n}R^{(2)}_{m,n}\right)L_{2,1} & \left(\sum_{m=1}^{M_2}\sum_{n=1}^{N_2}Z^{(2)}_{m,n}R^{(2)}_{m,n}\right)L_{2,2} & \cdots & \left(\sum_{m=1}^{M_2}\sum_{n=1}^{N_2}Z^{(2)}_{m,n}R^{(2)}_{m,n}\right)L_{2,S}\\ \left(\sum_{m=1}^{M_3}\sum_{n=1}^{N_3}Z^{(3)}_{m,n}R^{(3)}_{m,n}\right)L_{3,1} & \left(\sum_{m=1}^{M_3}\sum_{n=1}^{N_3}Z^{(3)}_{m,n}R^{(3)}_{m,n}\right)L_{3,2} & \cdots & \left(\sum_{m=1}^{M_3}\sum_{n=1}^{N_3}Z^{(3)}_{m,n}R^{(3)}_{m,n}\right)L_{3,S}\\ \vdots & \ddots & \cdots & \vdots\\ \left(\sum_{m=1}^{M_T}\sum_{n=1}^{N_T}Z^{(T)}_{m,n}R^{(T)}_{m,n}\right)L_{T,1} & \left(\sum_{m=1}^{M_T}\sum_{n=1}^{N_T}Z^{(T)}_{m,n}R^{(T)}_{m,n}\right)L_{T,2} & \cdots & \left(\sum_{m=1}^{M_T}\sum_{n=1}^{N_T}Z^{(T)}_{m,n}R^{(T)}_{m,n}\right)L_{T,S} \end{bmatrix}

Let the matrix above is defined as Q.

The constraint I have is

  sum(Q,2)>=D.*t


Apart from the linearization (knowing the linearization technique), how can I express this in CVX?

Or

\begin{bmatrix} \left(\sum_{m=1}^{M_1}\sum_{n=1}^{N_1}Z^{(1)}_{m,n}R^{(1)}_{m,n}\right)L_{1,1} + \left(\sum_{m=1}^{M_1}\sum_{n=1}^{N_1}Z^{(1)}_{m,n}R^{(1)}_{m,n}\right)L_{1,2} + \cdots + \left(\sum_{m=1}^{M_1}\sum_{n=1}^{N_1}Z^{(1)}_{m,n}R^{(1)}_{m,n}\right)L_{1,S} \\ \left(\sum_{m=1}^{M_2}\sum_{n=1}^{N_2}Z^{(2)}_{m,n}R^{(2)}_{m,n}\right)L_{2,1} + \left(\sum_{m=1}^{M_2}\sum_{n=1}^{N_2}Z^{(2)}_{m,n}R^{(2)}_{m,n}\right)L_{2,2} + \cdots + \left(\sum_{m=1}^{M_2}\sum_{n=1}^{N_2}Z^{(2)}_{m,n}R^{(2)}_{m,n}\right)L_{2,S}\\ \left(\sum_{m=1}^{M_3}\sum_{n=1}^{N_3}Z^{(3)}_{m,n}R^{(3)}_{m,n}\right)L_{3,1} + \left(\sum_{m=1}^{M_3}\sum_{n=1}^{N_3}Z^{(3)}_{m,n}R^{(3)}_{m,n}\right)L_{3,2} +\cdots + \left(\sum_{m=1}^{M_3}\sum_{n=1}^{N_3}Z^{(3)}_{m,n}R^{(3)}_{m,n}\right)L_{3,S}\\ \vdots\\ \left(\sum_{m=1}^{M_T}\sum_{n=1}^{N_T}Z^{(T)}_{m,n}R^{(T)}_{m,n}\right)L_{T,1} +\left(\sum_{m=1}^{M_T}\sum_{n=1}^{N_T}Z^{(T)}_{m,n}R^{(T)}_{m,n}\right)L_{T,2} + \cdots + \left(\sum_{m=1}^{M_T}\sum_{n=1}^{N_T}Z^{(T)}_{m,n}R^{(T)}_{m,n}\right)L_{T,S} \end{bmatrix}

Let us define the vector above as q, the constraint I have is

q>=D.*t

Once you have performed the linearization, implement it in CVX the same as you would in “MATLAB” if all variables were MATLAB variables rather than some being CVX variables. CVX allows use of for loops to build up expressions (for whatever you don;t manage to vectorize).