How can cvx solve function like exp(x)*(exp(exp(-x))-1)?


(Humpbackwha1e) #1

I got a problem when I tried to minimize such function in cvx and I have already proved that it is convex.
I know that for functions like x*(exp(1/x) - 1), I could introduce another variable like z \triangleq x*(exp(1/x) - 1) and write rel_entr(z,x) in the constraints so that cvx can solve it, but how to directly solve function like exp(x)*(exp(exp(-x))-1) ? exp(x) cannot be replaced by t (or other variables) since some other constraints are product terms and it is needed to convert the posynomials into convex forms.
Could anyone help? Thanks a lot.


(Henrik A. Friberg) #2

This answer might need translation, as I am not a CVX user, but you nearly provided the answer yourself. The inequality

t >= exp(x)*(exp( exp(-x) )-1),

is the same as

t >= exp(x)*(exp( 1/exp(x) )-1),

representable as

t >= z*(exp(1/z)-1),
z >= exp(x).

which is the same as

(t+z) >= z*exp(1/z),
z >= exp(x).

This is two exponential cones (exp_cone in CVX).


(Mark L. Stone) #3

Welcome to the forum @hfriberg .Thanks for the solution.

I believe the following CVX code segment implements your solution:

variables t z
exp(x) <= z
{1,z,t+z} == exponential(1)

(Henrik A. Friberg) #4

If only my first post on this forum was correct. Variable z will of course just shoot to +infinity and satisfy all constraints since z*(exp(1/z)-1) is decreasing, oops. We need the inverse slack as in

t >= ( exp(z)-1 ) / z,
z >= 1/exp(x),

but neither of these inequalities can currently be handled in CVX I think, although both convex.


(Mark L. Stone) #5

Well yeah, admittedly I posted the CVX implementation of your erroneous solution before getting to the point of understanding why your solution was correct.

Actually, the second of your inequalities can be handled by using exp(-x) which is convex and accepted by CVX.

As for the first inequality, is that a “solution”:to the convex modeling challenge by @Erling as posted at https://twitter.com/J_P_Vielma/status/1014513695605608448

Conic modeling challenge by https://twitter.com/e_d_andersen Do you have a nonlinear constraint that can be written in a modeling language, but can’t be represented with linear, socp, sdp, exponential cone and power cones?


(Erling D.Andersen) #6

Regarding the challenge then one good reply is

t \geq \log(1+d)/d, d>0

and

t \geq \log(1+d/x)/d, d,x>0.

Most likely CVX cannot deal with those either.


(Humpbackwha1e) #7

Thank you for your reply! I have solved this problem by changing problem formulation and avoiding logarithm substitution. Anyway, thank you all!


(Mark L. Stone) #8

Please show us your formulation. Is your formulation mathematically equivalent to the old formulation, i.e., has the same argmin?


(Humpbackwha1e) #9

Oh, it is just a simple change. I tried to introduce exp (x) to solve the product terms in my problem, but later I find that the product terms have a special form in which a binary variable times a continuous variable. Thus, I turn to use the big-M formulation, i.e., introducing another variable and some linear constraints to substitute the product terms, and I do not need exp(x) anymore. Finally, I go back to use x*(exp(1/x)-1), which can be easily handled by cvx.


(Mark L. Stone) #10

I’;m glad it worked out for you. (and @Erling got another challenge problem). But if you had shared the entirety of your problem here, perhaps one of the posters would have come up with a solution. There are a number of questions on this forum for which various people, including myself have provided Big M formulations using CVX’s MIDCP capability, to deal with certain non-convexities, specifically including the product of binary with continuous, general integer (using binary encoding) with continuous, or general integer with general integer using binary encoding, among other things. Introducing an exp into the formulation was probably not a good idea, especially when it didn’t lead to a model that anyone of this forum could figure out how to get into CVX - and some of the Mosek people who visit this forum are pretty doggone good at doing that if it is possible.