JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.1k stars 214 forks source link

Update to new MOI nonlinear interface #1052

Closed blegat closed 6 months ago

blegat commented 9 months ago

JuMP v1.15 now supports providing the nonlinear objective and constraints with @objective and @constraint. The old syntax @NLobjective and @NLconstraint is kept for backward compatibility only. Since the MOI wrapper in Optim is new, we don't need to support the old interface so this PR replace it the new one which works with @objective and @constraint.

codecov[bot] commented 9 months ago

Codecov Report

Merging #1052 (1d64631) into master (760993c) will decrease coverage by 0.32%. The diff coverage is 71.05%.

:exclamation: Current head 1d64631 differs from pull request most recent head e4e17d3. Consider uploading reports for the commit e4e17d3 to get more accurate results

@@            Coverage Diff             @@
##           master    #1052      +/-   ##
==========================================
- Coverage   84.94%   84.62%   -0.32%     
==========================================
  Files          44       44              
  Lines        3427     3422       -5     
==========================================
- Hits         2911     2896      -15     
- Misses        516      526      +10     
Files Coverage Δ
src/MOI_wrapper.jl 74.27% <71.05%> (-4.06%) :arrow_down:

... and 7 files with indirect coverage changes

pkofod commented 9 months ago

lgtm

blegat commented 9 months ago

Should be ready from my side as well

blegat commented 7 months ago

@pkofod bump

pkofod commented 6 months ago

I'll review it, thanks

pkofod commented 6 months ago

Okay, fairly small change compared to the original. LGTM

odow commented 6 months ago

This PR did not appropriately update the compat in Project.toml: https://github.com/JuliaNLSolvers/Optim.jl/pull/1060

ccoffrin commented 6 months ago

@blegat, is there a way this can support both the old and the new interface?

blegat commented 6 months ago

It's not too hard, what's the motivation ?

ccoffrin commented 6 months ago

Legacy code may not yet be updated to the new NLP interface.

Now that I think of it, I think it would be ok if there was one version that worked with the old NLP interface and another version that only supported the new one.

When I tried to use the old NLP interface with the current tagged release of Optim it did not seem to work for me.

blegat commented 6 months ago

Yes, the addition of the old NLP was merged a few months ago so after the latest release. I thought that since it's a new feature there is no need to maintain support for the old interface

ccoffrin commented 6 months ago

Ya I agree no need to maintain support for the old interface, but can we make sure there is a release where the old interface works?

blegat commented 5 months ago

The issue is that v1 has already been tagged so if we release a version with the old interface and then remove it, it's a breaking change and we need v2

ccoffrin commented 5 months ago

Good point. I was very confused when I made my first comment on this. I thought that in a previously release this package had been working with the legacy NL interface, but that is not the case.

I 100% agree going for the new NL interface, folks should be targeting that for new code development.