Convex constraint on the restricted domain of a non DCP compliant function

In a convex minimization problem, I have a non-smooth inequality constraint of the form f(x) \leq 0 . Where f(x) has a Sigmoidal form on the restricted non-positive domain.

f(x)=\begin{cases} \frac{e^{x}}{1+e^{x}} & x \leq 0 \\ cx+0.5 & x > 0 \\ \end{cases}

Inequality constraint above is convex. However the Sigmoidal expression alone violates the DCP rule set. I’m wondering if there is a way to write the constraint in a DCP compliant format?


This is enough of an answer that I’ll make it an answer, rather than a comment, but someone may be able to expand on this.

exp(x)/(1+exp(x)) is accepted by CVX as a log-concave function. So exp(x)/(1+exp(x)) >= 0 is allowed, but not exp(x)/(1+exp(x)) <= 0. See Log of sigmoid function .

Thanks for your answer, I see that sigmoid is log-concave, but since I have it on the LHS of f(x) \leq 0 inequality, I need to use its convex portion (\frac{\partial^2 f} {\partial^2 x } \geq 0 for x \leq 0) .

I see that there are internal cvx functions e.g. inv_pos, where the function returns \frac{1}{x} for positive values and \inf otherwise. I was thinking of using the same approach so that \inf values are returned for the positive domain of the sigmoid? does this make any sense? is there any way of implementing such function in CVX?

No, there is not. inv_pos is really not an example of what you are looking for: it is a connected, continuous convex branch of 1/x. What you are looking to do is to effect some sort of smooth transition at a particular x, and CVX cannot do that.


But, what about functions like huber_pos? Is it because each branch is convex on the entire domain anyway?

Basically, yes. You simply cannot shoehorn a non-convex function into CVX, even if you restrict its domain to a convex sub-interval.