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

Simplify handling of linear and quadratic derivatives for nonlinear solvers

Open blegat opened this issue 4 years ago • 4 comments

The wrappers of nonlinear solvers like Ipopt and NLopt are quite complicated because the solvers only expect gradient, jacobian, hessian callbacks and they also support linear and quadratic objective and constraints. We cannot rewrite them with bridges since bridges do not play well with the NLPBlock. This will be resolved by https://github.com/jump-dev/MathOptInterface.jl/issues/846 but in the short term, it would be good to have a solution as well. We could create an MOI layer (that would be a copy-paste of part of the Ipopt wrapper basically) that would do the transformation. Now how do we add this MOI layer in JuMP for nonlinear solvers ? Similarly to https://github.com/jump-dev/JuMP.jl/pull/2610, the MOI layer would be automatically added by JuMP if it detects that a linear/quadratic constraints is not supported even when adding bridges but the solver supports NLPBlock.

blegat avatar Jun 19 '21 14:06 blegat

I think this is out-of-scope for MathOptInterface 1.0.

There are only a handful of solvers that need this, and they are already implemented. The Ipopt.jl wrapper could do with a large refactoring, but that could happen post MOI 1.0.

Let's focus on finishing what we have, rather than adding yet more complexity.

odow avatar Jun 19 '21 23:06 odow

I think doing this would in fact decrease complexity quite a lot. Maintaining this MOI layer and simpler NL solver is much easier than maintaining MOI wrappers that are so complicated. I don't think a refactoring of Ipopt.jl would help, the wrapper is written quite well it's just doing too many things. Also, this is currently a big blocker for adding support for more NL solvers since writing the MOI wrapper go so much more complicated with MOI compared to MPB where you didn't have to support affine and quadratic.

I don't think it's blocking the release of MOI v0.10 or MOI v1.0 though as it's non-breaking but I might do this to ease the addition for new MOI wrappers for NL solvers I need.

blegat avatar Jun 20 '21 00:06 blegat

This could be a separate package first. It's really one of these "model transformers" we have been talking about.

  • Dualization.jl: model -> dual
  • Complementarity.jl: model + Complements -> MILP or nonlinear approximation
  • Hypothetical Nonlinear: nonlinear model + linear/quadratic -> Pure nonlinear model
  • Hypothetical Presolve: model -> presolved equivalent

odow avatar Jun 20 '21 20:06 odow

https://github.com/jump-dev/Ipopt.jl/pull/320 adds a QPData type with overloads that solves this.

odow avatar Jul 18 '22 04:07 odow

We now have bridges from ScalarAffine and ScalarQuadratic to ScalarNonlinearFunction, so solvers who don't exploit linear/quadratic functions are much simpler.

If solvers do exploit, then they'll need specialized support anyway. One option is to copy the code from Ipopt. I don't know if we need to add yet-another-utility to MOI for this.

I propose to close this issue unless anyone objects.

odow avatar Sep 12 '23 21:09 odow