-
Notifications
You must be signed in to change notification settings - Fork 94
[FileFormats] fix copy_to for NL.Model when used with bridges #1780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
IMO, the restriction for the optimizer of a |
Yeah that could be a different pull request. It might lead to some weird errors, but should be okay for most things. However, can we merge this first? That lets JuMP 1.0 depend on MOI 1.0. We can drop the restriction in a future version of MOI, and then change JuMP to use that if/when we want to bump the minimum supported version of MOI. |
Why would it ? If JuMP depends on this PR, it also means that it will depend on MOI v1.1 no ? |
Its a bug-fix. JuMP's code doesn't need to change. |
JuMP's code doesn't need to change if we allow |
Because JuMP either needs to explicitly construct a caching optimizer, or call julia> MOI.instantiate(MOI.FileFormats.NL.Model)
ERROR: The provided `optimizer_constructor` returned an object of type MathOptInterface.FileFormats.NL.Model. Expected a MathOptInterface.AbstractOptimizer.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] _instantiate_and_check(optimizer_constructor::Type{MathOptInterface.FileFormats.NL.Model})
@ MathOptInterface ~/.julia/packages/MathOptInterface/IQWV4/src/instantiate.jl:66
[3] instantiate(optimizer_constructor::Type; with_bridge_type::Nothing)
@ MathOptInterface ~/.julia/packages/MathOptInterface/IQWV4/src/instantiate.jl:119
[4] instantiate(optimizer_constructor::Type)
@ MathOptInterface ~/.julia/packages/MathOptInterface/IQWV4/src/instantiate.jl:119
[5] top-level scope
@ REPL[2]:1 |
If we additionally fix |
Okay. Let me put together a PR with the full fix. Maybe we do just lower-bound JuMP to MOI 1.1.2 |
Closing in favor of #1781 |
Closes jump-dev/JuMP.jl#2931
This was actually slightly more complicated that expected (there's a long comment in the code explaining why this is necessary). But essentially we were missing a test for the case where we tried to copy to a
Bridges.full_bridge_optimizer(NL.Model(), Float64)
. The other file formats work fine because they use@model
, but NL is special because I cut out an extra cache and only implementedcopy_to
. (I can't have tried it via JuMP since I removed the cache.)Other fixes, like JuMP using a CachingOptimizer, won't work because
NL.Model
is not an AbstractOptimizer. This is definitely a hole in the API, but since this is a one-off case we can keep it like this for now. If we encounter other places where this is useful, we could consider adding aCachingModel
toMOI.Utilities
.