Constraint definition


(Ali Darabi) #1

hello,
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?
thanks


(Mark L. Stone) #2

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

(Ali Darabi) #3

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
http://mathworld.wolfram.com/L-Infinity-Norm.html
norm inf find max, this is not what I want.
I used abs(b)<6 but I got error.


(Michael C. Grant) #4

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.


(Mark L. Stone) #5

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.

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

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


(Ali Darabi) #6

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

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, ‘<=’ );


(Mark L. Stone) #7

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 http://web.stanford.edu/~boyd/cvxbook/ . Also, the CVX Users’ Guide quite clearly states the latter is not accepted by CVX.