How to use reshape in a constraint

I have the following model:

     variable theta(N*T) nonnegative
     minimize( norm(A*theta-b, 2) + gamma*norm(theta,1) )
     subject to
        ineqmat*theta <= ones(N,1);        

theta is an (NxT)x1 vector that represents the stacked columns of a matrix. (I mean, once I estimate it, I reshape it to an NxT matrix to do additional stuff.)

I need to add constraints that the minimum of each row of the theta matrix is greater than a constant. Or, in vector form, I need the minimum of the first T values of theta, and then the minimum of the next T values of theta, etc. So if I can reshape theta into a matrix within the cvx code and add a constraint for each row I believe I’ll have what I need. Is it possible to do this? How would I reshape it just within the constraint?

Ideas for alternative approaches would also be greatly appreciated.


Keep what you have.
min(reshape(theta,N,T),[],2) >= constant

Or you can do

theta_matrix = reshape(theta,N,T)
min(theta_matrix,[],2) >= constant

Edit: Of course, if constant is a scalar (i.e., has a common value across rows) rather than a vector, I believe what you described would be equivalent to min(theta) >= constant , which in turn is equivalent to theta >= constant .

1 Like