-
Notifications
You must be signed in to change notification settings - Fork 23
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
Thoughts on the C interface #267
Comments
We use the C interfaces of Ipopt.jl and KNITRO.jl for the packages NLPModelsIpopt.jl and NLPModelsKnitro.jl. |
I guess to clarify, my change would mostly make it so that the only This would mostly affect calls like this, which, despite calling a But yes, this would be a breaking change, so we'd need to decide if it was worth it. My point at the moment is that there is really 3 APIs that we are maintaining: MOI, |
Perhaps let me draft a PR, and then we will have something more concrete to discuss. |
Another problem with the C wrapper is that it just ignores all return codes, so we're not catching errors. |
@odow I agree with you: the current C wrapper is a bit clunky, and was developed before Clang.jl has been made broadly available. In general, I prefer simplicity. If you want, I can update the examples with the new bare-bone C wrapper. |
I've made good progress #268. I have't updated the examples yet. The |
I'm now much more confidence about the state of the KNITRO C wrapper, and I think simplifying it is a very good idea. The C examples were trivial to update, and in every case, they made things much more explicit. If we merge this, I'll be responsible for updating NLPModelsKnitro. |
I updated NLPModelsKnitro: JuliaSmoothOptimizers/NLPModelsKnitro.jl#117, so I think I'm ready to close this issue and release v0.14. |
Closing because I'm now pretty happy with the C wrapper. The only changes are around This should be much easier to debug and maintain going forwards. |
@frapac (and other watchers), I'd like to get feedback on potentially removing the
C_wrapper
part of the C API.The main reason for removing it is because it is undocumented, and serves as a slightly complicated abstraction layer between MOI and the solver. It introduces a number of ways of doing the same thing:
KNITRO.jl/src/C_wrapper.jl
Lines 375 to 402 in 4db649c
and it uses multiple dispatch to create new functions that look like they're from the C API, but are actually not:
KNITRO.jl/src/C_wrapper.jl
Lines 703 to 725 in 4db649c
I've previously removed layers like this from Gurobi/CPLEX/etc and I think it is a big win. There is now only the MOI wrapper, and the upstream documented C API.
The downside, of course, is that there are a large number of examples using the C API, although we could update them to the underlying C:
https://github.com/jump-dev/KNITRO.jl/tree/master/examples
This would of course be horribly breaking, but it'd be nice to decide before releasing KNITRO v1.0.
I guess the other comparison here is Ipopt:
https://github.com/jump-dev/Ipopt.jl/blob/master/src/C_wrapper.jl
It has a very minimal C wrapper, which is mainly just to simplify the
@cccallable
stuff. So we wouldn't have to throw away theC_wrapper.jl
entirely, just the bits that could otherwise be the original C.The text was updated successfully, but these errors were encountered: