coin-or / CppAD

A C++ Algorithmic Differentiation Package: Home Page
https://cppad.readthedocs.io
Other
446 stars 94 forks source link

Working with CppAD::ipopt::solve and CppADCodeGen #160

Closed a-jp closed 1 year ago

a-jp commented 1 year ago

Based on recent help here, I have a working test case based heavily on this joint CppAD and Ipopt example. Before I extend my code, I'm really interested to understand CppADCodeGen while I still have a small toy example codebase.

I see there is support for CodeGen directly in CppAD. Sorry to ask, but for specifically using CppADCodeGen with CppAD::ipopt::solve would it be possible to have an example? Ideally, if the linked example above could be converted to use codegen that would be brilliant and allow me to understand those changes on a test case that already makes sense to me.

bradbell commented 1 year ago

Have you looked at https://coin-or.github.io/CppAD/doc/example_jit.htm

a-jp commented 1 year ago

I haven't seen that, no. Could you give me a bit more info about that link you provided? Is that CppADCodeGen behind the scenes, a different approach and pure CppAD? Not sure what I'm looking at coming to that cold.

Couldn't seen any ipopt there, should I take from that, that as long as I use the approach to call ipopt in the example I cited it will work? If not, is there a version of that example I cited that uses CppADCodeGen?
Many thanks,

bradbell commented 1 year ago

This is a different approach that was inspired by the speeds obtained by CppADCodeGen. Initial test shows its speeds are similar.

There is no support for ipopt::solve here, but a version of ipopt::solve that uses CppAD JIT to compute derivatives would be a very good addon to CppAD (if you are interested in such a project). https://coin-or.github.io/CppAD/doc/addon.htm

I am currently working on converting CppAD's documentation from omhelp (something I wrote myself years ago) to sphinx. This is part of a larger project of doing this for all my open source projects. Once I have this done, it should be easier for other people to modify the documentation in CppAD source.

a-jp commented 1 year ago

Ok, thanks for this info, much appreciated. I'd be very interested in CppAD JIT with ipopt::solve - the chances of me being able to materially help there are small, but I can try once I know it's got going...