MathOptInterface.jl icon indicating copy to clipboard operation
MathOptInterface.jl copied to clipboard

[Nonlinear] Add support for more functions

Open odow opened this issue 1 year ago • 5 comments

@harshangrjn says that there are a bunch of functions in MINLPlib that AMPL supports that JuMP currently doesn't.

Some of them are listed here: https://github.com/jump-dev/MathOptInterface.jl/blob/2aba5d5450b3a5931ff557cb8969efc2987b3ffd/src/FileFormats/NL/NLExpr.jl#L30-L101 We should go through and reconsider the ones we've left out.

In addition, Harsha says he will link to a list of functions that he'd like added.

odow avatar Sep 12 '22 22:09 odow

GAMS has a bunch here: https://www.gams.com/latest/docs/UG_Parameters.html

The univariate functions supported by JuMP/MOI are here: https://github.com/jump-dev/MathOptInterface.jl/blob/2aba5d5450b3a5931ff557cb8969efc2987b3ffd/src/Nonlinear/univariate_expressions.jl#L12-L83 the multivariate functions are here: https://github.com/jump-dev/MathOptInterface.jl/blob/2aba5d5450b3a5931ff557cb8969efc2987b3ffd/src/Nonlinear/operators.jl#L531-L547

A missing one that people use quite a bit is sign (@ccoffrin has an example where this needs to be a registered function)

odow avatar Sep 13 '22 03:09 odow

signpower(x, p) -> sign(x) * abs(x)^p for any real p > 1

A few examples where this nonlinearity appears:

  1. https://www.minlplib.org/gastransnlp.html (JuMP model)
  2. https://www.minlplib.org/waternd_fosspoly0.html (JuMP model)

harshangrjn avatar Sep 13 '22 17:09 harshangrjn

Ah. They're in the GAMS format, not AMPL. We have an open question then, of whether to bring in modeling functions like signpower that exist only in GAMS, and are not Julia functions. (Although I guess we could define MOI.Nonlinear.signpower.)

odow avatar Sep 13 '22 20:09 odow

Assuming sign and abs functions will be internally supported, writing signpower as an explicit constraint by the user shouldn't be too much though.

harshangrjn avatar Sep 13 '22 20:09 harshangrjn

I guess the issue is that signpower is smooth and differentiable at x=0. Whereas sign(x) and abs(x) are not.

odow avatar Sep 13 '22 21:09 odow