How to express if-else (indicator) constraints in cvx?

Uncategorized
Apr 21, 2022
K

X is a variable and a is a constant. I want to achieve the following functionality:

if X <= 0
f = X + a;
else
f = a;
end

How can I express this constraint in cvx?

J

see

by the way, the function f you posted is concave to X, it can be expressd by f=(-abs(x)+x)/2+a; in cvx.

M

Or you can use the provided pos function as
-pos(-x) + a

K
Replying to #3

Thank you very much!

K
Replying to #4

Thank you very much! I forgot that there is a pos function