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

Rebuild IpoptProblem only if modified

Open odow opened this issue 1 year ago • 5 comments

Part of https://github.com/jump-dev/JuMP.jl/issues/1185 x-ref https://github.com/jump-dev/JuMP.jl/pull/3018

For @ccoffrin's PF example: https://github.com/lanl-ansi/nlp-jump-examples/pull/9 (private link at present)

Without this PR

julia> @time bench_pf_nlparameter(case="pglib_opf_case2000_goc.m", n = 100)
 83.591282 seconds (225.00 M allocations: 34.441 GiB, 14.97% gc time, 1.07% compilation time)

With this PR

julia> @time bench_pf_nlparameter(case="pglib_opf_case2000_goc.m", n = 100)
 21.147063 seconds (27.64 M allocations: 1.517 GiB, 4.47% gc time)

odow avatar Jul 17 '22 23:07 odow

Codecov Report

Merging #321 (5028dd9) into master (5bf1161) will increase coverage by 0.12%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #321      +/-   ##
==========================================
+ Coverage   91.39%   91.52%   +0.12%     
==========================================
  Files           4        4              
  Lines         732      743      +11     
==========================================
+ Hits          669      680      +11     
  Misses         63       63              
Impacted Files Coverage Δ
src/MOI_wrapper.jl 88.78% <100.00%> (+0.30%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 17 '22 23:07 codecov[bot]

A nice improvement for such minor updates.

ccoffrin avatar Jul 18 '22 02:07 ccoffrin

It's actually not so straightforward, because it relies on https://github.com/jump-dev/JuMP.jl/pull/3018#issuecomment-1186677741. And it isn't obvious whether we need to call MOI.initialize if a parameter changes.

odow avatar Jul 18 '22 03:07 odow

Regardless of the JuMP change, this is still a win if you want to repeatedly solve the same problem with different primal/dual starting points.

odow avatar Jul 18 '22 03:07 odow

@odow good point! I had not noticed the JuMP change that is required.

ccoffrin avatar Jul 18 '22 15:07 ccoffrin

This does't solve the JuMP issue, because that needs changes in MOI/JuMP, but this is an uncontroversial change in Ipopt that still improves things somewhat (we don't rebuild if you want to change the starting point and re-optimize).

odow avatar Aug 17 '22 04:08 odow

Still there are some good uses cases of this. Like multi-start inside of MINLP algorithms.

ccoffrin avatar Aug 17 '22 04:08 ccoffrin

Like multi-start inside of MINLP algorithms.

Yes, this is exactly what I had in mind.

odow avatar Aug 17 '22 04:08 odow