jump-dev / MathOptInterface.jl

A data structure for mathematical optimization problems
http://jump.dev/MathOptInterface.jl/
Other
387 stars 87 forks source link

[Nonlinear] add support for univariate sign #2444

Closed odow closed 6 months ago

odow commented 6 months ago

Closes https://github.com/jump-dev/MathOptInterface.jl/issues/2448

I don't know about this one. We might be better off documenting people to write a signpower function at the JuMP level because this still has the problem that sign(x) * abs(x)^p is not defined when x=0 and p < 1.

Thoughts @ccoffrin?

ccoffrin commented 6 months ago

My hot take.

There may be other uses of sign we cannot anticipate, which don't have such an obvious work around. If the following conditions are met,

  1. Adding support for a new function does not add a major burden (e.g., in maintenance)
  2. It is a very common built-in Julia function (ideally also part of C standard functions)
  3. there have been multiple request for support (i.e., users want it)

Then I think it is good to add support for it.

I hear your point that this will likely lead to a bunch of non-ideal modeling choices by non-experts. However, that issue is not limited to this specific new feature. I don't think there is an easy work around for helping typical users model better. Current state of the art is basically to get a PhD in NLP to understand how to write better models.

odow commented 6 months ago

sign meets your criteria for 1, 2, and 3.

It's probably the currently unsupported operator that I see most often.

And we already support min, max, ifelse, and abs, so non-differentiatbility isn't an argument against adding.

@mlubin should weigh in before we decide to merge.