Having constraints on the values in a matrix variable


Iā€™m kind of new to using cvx so please bare with me if my question is silly :slight_smile:

If I have a matrix variable that needs to be found in the optimization process and the constraint is that all the values in that matrix are in a specific range [a, b] how should I write this in cvx?

Could I have two for loops in the constraint?

variable B(m,n)
subject to
for i
for j

does this make sense?

Note that strict inequalities are interpreted as being non-strict inequalities.

It is not necessary, and is faster, to not use for loops.

If not using sdp mode or if B is not square, you can use
a <= B <= b

You can always use
a <= B(:) <= b
or equivalently
a <= vec(B) <= b

1 Like