jump-dev / Convex.jl

A Julia package for disciplined convex programming
https://jump.dev/Convex.jl/stable/
Other
559 stars 119 forks source link

perspective formulation of log #100

Closed mlubin closed 8 years ago

mlubin commented 8 years ago

What's the DCP way to represent y*log(x/y)? It should be an easy conversion to the exponential cone.

madeleineudell commented 8 years ago

y*log(x/y) is concave, so {(x,y,z): y*log(x/y) >= z} is a convex set. We can represent this using the exponential cone {(x,y,z): y*exp(x/y) <= z} using the following reasoning:

y*log(x/y) >= z iff log(x/y) >= z/y (supposing y>0) iff x/y >= exp(z/y) iff x >= y*exp(z/y),

which is the standard exponential cone form.

If you don't want to create a new atom, I'd add a new variable z and the constraint

ExpConstraint(z, y, x),

and replace y*log(x/y) by z anywhere you want to use it. (This constraint can be used like any other constraint in Convex.)

mlubin commented 8 years ago

Okay, good to see that it's at least representable. Would be nice to have an atom for the functional form. What do the other DCP languages do here?

madeleineudell commented 8 years ago

I'm not aware of (a name for) this atom existing in other DCP languages... Perhaps @SteveDiamond or @mcg1969 can comment?

@mlubin, can you say more about how this function arises for you?

mcg1969 commented 8 years ago

Oh yeah, look at rel_entr. We don't have an exact atom for the perspective of log but enough people ask that we should.

madeleineudell commented 8 years ago

I see! The function Miles was interested in (perspective of log) is just the negative of relative entropy:

-x log(x/y) = x log(y/x)

mlubin commented 8 years ago

Perspective functions come up pretty often in disjunctive modeling for mixed-integer nonlinear problems, e.g. http://link.springer.com/article/10.1007%2Fs10107-010-0360-z

mlubin commented 8 years ago

I'd be happy with a rel_entr atom.

mcg1969 commented 8 years ago

Yes, that's right. CVX doesn't attempt to model general perspective functions. But the perspective of the logarithm itself is indeed representable through the rel_entr function, with a bit of effort.

mlubin commented 8 years ago

quad_over_lin is another perspective atom, by the way

mcg1969 commented 8 years ago

That's right! I personally don't think the perspective transformation itself needs to be exposed in a modeling environment, as long as the atoms that represent them, like quad_over_lin and rel_entr, are made available.

mlubin commented 8 years ago

rel_entr is a big improvement over the manual modeling using the exponential cone as @madeleineudell suggested, although I think there's something to be said for the syntax to match the user's mental model of the problem, when it's possible. rel_entr isn't immediately identifiable as a way to model the perspective of log, and the community of MINLP people who use the perspective of log might never think or talk about entropy functions. Having to use terminology from a different field just seems like a bit of an unnecessary barrier between the user and the code.

Just an observation though, as I said I'm happy to go off and use rel_entr.

mcg1969 commented 8 years ago

Oh, yes, by all means: if there are a lot of people who want something called, say, log_perspective that implements y log(x/y), it should probably be implemented. All I was saying was that there needn't be some sort of higher-level function like perspective(fn, x, y) to implement perspectives for any function. It might be cool academically to do this, and indeed I've thought about it (with conic solvers it's possible)! I just don't think it will be widely appreciated, and then it's just something else to break.

madeleineudell commented 8 years ago

Here's a relative entropy atom sketch: b228b4fd9682e8d0dfaa275b520be7e3cce3970a. Not yet tested, but perhaps enough for @mlubin to play with?

mlubin commented 8 years ago

@mcg1969, agreed with your assessment. Perspective functions don't come up all that often, and when they do, it might be in a more structured context, e.g., disjunctive modeling, where the more natural user-facing representation of the problem is at a level above DCP.

@madeleineudell, thanks for writing that up, I'll play with it when I get a chance.

madeleineudell commented 8 years ago

Well then it's perfectly fine to add a

log_perspective (x, y ) = - relative_entropy (x, y )

Or whatever terminology you think would be easiest to search for. On Aug 31, 2015 7:55 PM, "Miles Lubin" notifications@github.com wrote:

rel_entr is a big improvement over the manual modeling using the exponential cone as @madeleineudell https://github.com/madeleineudell suggested, although I think there's something to be said for the syntax to match the user's mental model of the problem, when it's possible. rel_entr isn't immediately identifiable as a way to model the perspective of log, and the community of MINLP people who use the perspective of log might never think or talk about entropy functions. Having to use terminology from a different field just seems like a bit of an unnecessary barrier between the user and the code.

Just an observation though, as I said I'm happy to go off and use rel_entr .

— Reply to this email directly or view it on GitHub https://github.com/JuliaOpt/Convex.jl/issues/100#issuecomment-136559824.

mlubin commented 8 years ago

Closed by 9296fe8fa160dc12864f0691b460c30d351f74d0