Constraint definition

I have a variable >b in my constraint. b is a vector 100*1. I want to put constraint like norm each bi <6. how can I do it?
it is so embarrassing to write norm(b1)<6,…,norm(b100)<6.
what do you suggest?

Do you just have a single vector b, and you want the absolute value of each component to be < 6 (note, I will use <=, because that is how CVX treats <). If so,

norm(b,inf) <= 6

If instead, you have m different 100 by 1 vectors, and you want the norm of each vector (column) to be constrained, you can declare B as a matrix variable and use norms.

variable B(100,m)
norms(B) <= 6

I want to check absolote value of any values in a vector b be <6. I want to check abs each element of b is less than 6.
acourding to
norm inf find max, this is not what I want.
I used abs(b)<6 but I got error.

Mark’s answer is correct, but so is abs(b) <= 6. If you are seeing an error it is due to something else in your model (e.g., b isn’t affine). Feel free to share more specifics about your error.

norm(b,inf) <= 6
is the same as
max(abs(b)) <= 6
is the same as
abs value of each component of b <= 6
is the same as
abs(b) <= 6

The following is valid CVX code: Hence, see mcg’s comment above.

variable b(100,1)
abs(b) <= 6

if < is used instead of <=, CVX will produce a warning message, but not an error message.

1 Like

but I got error when I change it to this form.
variable b(100,1)
1<=abs(b) <= 6

Error using cvxprob/newcnstr (line 192)
Disciplined convex programming error:
Invalid constraint: {real constant}
<= {convex}

Error in <= (line 21)
b = newcnstr( evalin( ‘caller’,
‘cvx_problem’, ‘[]’ ), x, y, ‘<=’ );

1 <= abs(b) is non-convex. Hence, the CVX error. The error message states quite clearly why this ws not accepted.

A convex function <= constant or affine expression is convex. A convex function >= constant or affine expression is non-convex. Perhaps you should study . Also, the CVX Users’ Guide quite clearly states the latter is not accepted by CVX.