Allocation-free access to evaluator
I did this some months ago in an attempt to see if we could get allocation-free iterations after https://github.com/jump-dev/MathOptInterface.jl/pull/2740.
Before this PR, it relies on calling MOI.eval_objective(model, x) which access model.nlp_data.evaluator which is type-unstable since the type of evaluator is not concrete:
https://github.com/jump-dev/MathOptInterface.jl/blob/034a5272dad29a233783cc49ed7e15195450dd96/src/nlp.jl#L176
So the fix in this PR is to give to Ipopt closures that capture the evaluator, not the model.
Now even after this, we're not allocation-free yet because there is the type-instability in accessing
https://github.com/jump-dev/Ipopt.jl/blob/077843b3b77b5946011c7656c267fc272a0427f0/src/C_wrapper.jl#L18-L21
We can add the type of these functions as parameters to IpoptProblem but then we need to modify this type-assert:
https://github.com/jump-dev/Ipopt.jl/blob/077843b3b77b5946011c7656c267fc272a0427f0/src/C_wrapper.jl#L35
and I'm not sure how to make it work with @ccallable
https://github.com/jump-dev/Ipopt.jl/blob/077843b3b77b5946011c7656c267fc272a0427f0/src/C_wrapper.jl#L190-L191
As discussed during the JuMP-dev hackathon, maybe https://github.com/jump-dev/Ipopt.jl/pull/514/ could help.