Login  Register

Re: 答复: Adjoint Greeks

Posted by Alexander Sokol on Mar 03, 2015; 12:18pm
URL: http://quantlib.414.s1.nabble.com/Adjoint-Greeks-tp16147p16302.html

Hi Luigi, Ferdinando, Peter:

Thank you for the feedback! Answering a few of the recent comments in no particular order.

1) We concluded that the only way to both avoid making breaking changes to QuantLib and avoid creating a custom fork of CppAD/ADOL-C, is to introduce a class for Real and place AD<double> inside this class. Otherwise things like implicit conversions from Null and InterestRate classes will not work correctly and will require changes to one or the other, or can break existing code due to ambiguous conversion.

2) On the other hand, with the class for Real, we can have a compile time define to use CppAD, ADOL-C, as well as regular double (for validation of conversion to the class) inside, and it will be very easy to add any future AD library. We are using SFINAE for this, and the approach should be relatively safe as far as unintended implicit conversions. I think this is the best approach in long term. We checked that the wrapper gets fully inlined and has zero impact on performance (this can be verified by looking at assembly code), so there is really no downsize I can think of to introducing it. If Real has to be a class for AD anyway, the best way to proceed in my view is to create our own class, and then place various AD implementations inside, rather than change the core QuantLib code to work with various AD doubles.

3) Luigi, given that you are very busy these days, can you give me the list of all officially supported compiler versions and are additional tests that are not in test suite - we will then create a TeamCity installation that will be running continuous builds to verify that our branch works and has no regression. Incidentally, I would personally prefer to limit AD-based version to C++11, or rather its subset implemented by MSVC 2013, gcc, and clang. But if we have to support older compilers, we can try to get it work with cpp98 as well.

4) I will shortly send a pull request to Luigi for two branches - one based on master-adjoint-ready (please take a look if you have a moment, it is almost done and already pushed to github.com/compatibl/master-adjoint-ready), which I hope you will consider pulling into your master. The changes on this branch have to do with mixing double and Real or things like if(double), etc. - namely it is just correcting something in core QuantLib that stops AD from working, but does not have AD itself and keeps Real=double. These fixes should be very safe but we will test them before the pull request is sent. The second branch will have AD and I hope you can pull it into a separate branch in your repo so more people can try it.

Best regards
Alex