Type Stability of IpoptProblem#532
Conversation
|
The current suggestion is to use PackageCompiler, not JuliaC: We test it with JuMP and Ipopt: https://github.com/jump-dev/JuMP.jl/blob/master/test/PackageCompiler/build_app.jl There are a number of trade-offs to consider here, including whether it is worth making a breaking change. |
|
Thanks @odow. I'd like to take advantage of juliac trimming capability. If I make the pr backward compatible can it be merged? Also, what is the breaking change? |
|
I understand the motivation for wanting to use JuliaC, but proper support is likely years rather than months away. Adding new type parameters can be breaking if anyone dispatched on Ideally we'd also merge something like this only if there are also tests that run JuliaC so we can confirm it works. I guess the fact that there are multiple open PRs shows that there's not a simple quick fix 😄 |
|
|
||
| mutable struct IpoptProblem | ||
| mutable struct IntermediateCallbackWrapper | ||
| f::Function |
There was a problem hiding this comment.
Why is this one okay? Is it just that you didn't test JuliaC with an intermediate callback?
There was a problem hiding this comment.
This should be fixed in latest commit.
There was a problem hiding this comment.
I still don't understand: why is the non-type-stable f::Function okay here, but it wasn't okay in IpoptProblem for eval_f::Function etc?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #532 +/- ##
===========================================
- Coverage 100.00% 99.75% -0.25%
===========================================
Files 5 5
Lines 1191 1200 +9
===========================================
+ Hits 1191 1197 +6
- Misses 0 3 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I'd need to double check, but I think the other consequence of this is that precompilation would now be specific to the model: Ipopt.jl/ext/IpoptMathOptInterfaceExt/IpoptMathOptInterfaceExt.jl Lines 21 to 77 in 1f6a40c So this would hurt the startup times of all users not using JuliaC. |
|
Precompilation doesn't seem to be affected: Before (tmp) pkg> st
Status `/private/tmp/Project.toml`
[b6b21f68] Ipopt v1.14.1
[4076af6c] JuMP v1.30.0
julia> using JuMP, Ipopt
julia> @time begin
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, x)
@variable(model, y)
@objective(model, Min, (1 - x)^2 + 100 * (y - x^2)^2)
optimize!(model)
assert_is_solved_and_feasible(model)
end
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit https://github.com/coin-or/Ipopt
******************************************************************************
2.261278 seconds (11.55 M allocations: 556.102 MiB, 6.35% gc time, 99.85% compilation time: 1% of which was recompilation)After (ip2) pkg> st
Status `/private/tmp/ip2/Project.toml`
[b6b21f68] Ipopt v1.14.1 `~/git/jump-dev/Ipopt`
[4076af6c] JuMP v1.30.0
julia> using JuMP, Ipopt
julia> @time begin
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, x)
@variable(model, y)
@objective(model, Min, (1 - x)^2 + 100 * (y - x^2)^2)
optimize!(model)
assert_is_solved_and_feasible(model)
end
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit https://github.com/coin-or/Ipopt
******************************************************************************
2.262386 seconds (11.55 M allocations: 556.119 MiB, 7.09% gc time, 99.85% compilation time: 1% of which was recompilation) |
|
If we are to consider making a breaking change by adding type parameters, I wonder if we're better off doing something like: abstract type AbstractOracle end
struct HS071 <: AbstractOracle end
function Ipopt.eval_f(::HS071, x::Vector{Float64})
return x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3]
end
Ipopt.eval_grad_f()
Ipopt.eval_g()
Ipopt.eval_jac_g()
Ipopt.has_eval_h(::HS071) = true
Ipopt.eval_h()
prob = Ipopt.CreateIpoptProblem(n, x_L, x_U, m, g_L, g_U, 8, 10, HS071())
struct IpoptProblem{O<:AbstractOracle}
oracle::O
endThis would be much more "Julian" in its approach. It would be completely type stable. It avoids the intermediate callback issue, because you could have |
|
Take a look at the alternative in #535. There's now a merge conflict because I made some changes inspired by some of your diffs. |
I have been trying to use JuliaC.jl with Ipopt.jl. This requires fixing #518. (JuliaC also doesn't work with #519).