# Formulating this optimization problem

Suppose I want to minimize below objective function

$$\sum | g(x_i) \cdot I_{g(x_i)<0} |^2$$

i.e, the latter penalty terms like $$|g(x_i)|^2$$ are only computed when $$g(x_i)<0$$. $$|g(x_i)|^2$$ are convex functions. Is there a way to formulate it? I know sum of convex functions are convex, but if I have added this strange "filter" on the objective function, I hope it's still convex..

• No it will not be convex. You can just look at a simple example, such as $g(x)=x^2-1$ Sep 12 at 17:58
• What do you optimize over? The $x_i$? Sep 12 at 23:18

## 1 Answer

I'm going to assume that you optimize over the locations $$x_i$$. Then this is most easily reformulated via slack variables as follows: $$\min_{x_i,s_i} s_i^2 \\ \text{so that}\quad s_i \le g(x_i) \\ \qquad\quad s_i \le 0$$ This is not a convex problem because the feasible region described by these constraints is not convex. You can see this by just considering the function $$g(x)=x^2-1$$ mentioned by @johanlofberg in a comment, for example, and plotting the feasible region spanned by the two constraints.