Adept (C++ library)
{{Infobox software
| name = Adept C++ Library
| logo =
| logo size = 300
| developer = Robin Hogan
| latest release version = 2.1.2
| latest release date = {{start date and age|df=yes|paren=yes|2023|10|03}}
| latest preview version =
| latest preview date =
| programming language = C++
| operating system = Cross-platform
| genre = Library
| license = Apache 2.0 (open source)
| website = {{URL|http://www.met.reading.ac.uk/clouds/adept/}}
}}
Adept is a combined automatic differentiation and array software library for the C++ programming language. The automatic differentiation capability facilitates the development of applications involving mathematical optimization. Adept is notable for having applied the template metaprogramming technique of expression templates to speed-up the differentiation of mathematical statements.{{cite journal|last=Hogan|first=Robin J.|title=Fast reverse-mode automatic differentiation using expression templates in C++|journal=ACM Trans. Math. Softw.|year=2014|volume=40|issue=4|pages=26:1–26:16|url=http://www.met.reading.ac.uk/%7Eswrhgnrj/publications/adept.pdf|doi=10.1145/2560359|s2cid=9047237}}{{cite journal|first=Andreas|last=Griewank|year=2014|title=On automatic differentiation and algorithmic linearization|journal=Pesquisa Operacional|volume=34|issue=3|pages=621–645|doi=10.1590/0101-7438.2014.034.03.0621|doi-access=free|s2cid=54059078 }} Along with the efficient way that it stores the differential information, this makes it significantly faster than most other C++ tools that provide similar functionality (e.g. ADOL-C, CppAD and FADBAD),{{cite arXiv|first=Bob|last=Carpenter|title=The Stan Math Library: Reverse-Mode Automatic Differentiation in C++|eprint=1509.07164|class=cs.MS|year=2015}}{{cite web|url=https://www.xcelerit.com/computing-benchmarks/software/aad/|title=Sensitivities in Quantitative Finance: Libor Swaption Portfolio Pricer (Monte-Carlo)|accessdate=2017-10-21|date=2016-12-02}}{{cite thesis|title=Discrete controls and constraints in optimal control problems|type=PhD Thesis|first=Matthias|last=Rieck|publisher=Technical University of Munich|accessdate=2017-10-21|url=https://mediatum.ub.tum.de/doc/1316413/1316413.pdf}}{{cite thesis|title=Stochastic volatility models with applications in finance|url=http://ir.uiowa.edu/cgi/viewcontent.cgi?article=6780&context=etd|archive-url=https://web.archive.org/web/20170718074806/http://ir.uiowa.edu/cgi/viewcontent.cgi?article=6780&context=etd|url-status=dead|archive-date=July 18, 2017|first=Ze|last=Zhao|accessdate=2017-10-27|publisher=University of Iowa}} although comparable performance has been reported for Stan and in some cases Sacado. Differentiation may be in forward mode, reverse mode (for use with a Quasi-Newton minimization scheme), or the full Jacobian matrix may be computed (for use with the Levenberg-Marquardt or Gauss-Newton minimization schemes).
Applications of Adept have included computer functionality in the financial field,{{cite arXiv|first1=Gilles|last1=Pagès|first2=Olivier|last2=Pironneau|first3=Guillaume|last3=Sall|title=Vibrato and automatic differentiation for high order derivatives and sensitivities of financial options|eprint=1606.06143|class=q-fin.CP|year=2016}} computational fluid dynamics,{{cite conference|first1=T.|last1=Albring|first2=M.|last2=Sagebaum|first3=N. R.|last3=Gauger|year=2016|title=A Consistent and Robust Discrete Adjoint Solver for the SU2 Framework—Validation and Application|editor-first=A.|editor-last=Dillmann|editor2-first=G.|editor2-last=Heller|editor3-first=E.|editor3-last=Krämer|editor4-first=C.|editor4-last=Wagner|editor5-first=C.|editor5-last=Breitsamter|series=New Results in Numerical and Experimental Fluid Mechanics X. Notes on Numerical Fluid Mechanics and Multidisciplinary Design|volume=132|publisher=Springer, Cham|doi=10.1007/978-3-319-27279-5_7}} physical chemistry,{{cite journal|first1=Kyle E.|last1=Niemeyer|first2=Nicholas J.|last2=Curtis|first3=Chih-Jen|last3=Sung|title=pyJac: Analytical Jacobian generator for chemical kinetics|journal=Comput. Phys. Commun.|volume=215|year=2017|pages=188–203|arxiv=1605.03262|bibcode=2017CoPhC.215..188N|doi=10.1016/j.cpc.2017.02.004|s2cid=19675513}} parameter estimation{{cite journal|title=Boosting Bayesian parameter inference of nonlinear stochastic differential equation models by Hamiltonian scale separation|first1=Carlo|last1=Albert|first2=Simone|last2=Ulzega|first3=Ruedi|last3=Stoop|journal=Phys. Rev. E|volume=93|issue=43313|pages=043313|year=2016|arxiv=1509.05305|doi=10.1103/PhysRevE.93.043313|pmid=27176434|bibcode=2016PhRvE..93d3313A|s2cid=4479221}} and meteorology.{{cite journal|first1=S.|last1=Mason|first2=J.-C.|last2=Chiu|first3=R. J.|last3=Hogan|first4=D.|last4=Moisseev|first5=S.|last5=Kneifel|title=Retrievals of riming and snow particle density from vertically-pointing Doppler radars|journal=J. Geophys. Res.|volume=123|doi=10.1029/2018JD028603|year=2018|url=http://centaur.reading.ac.uk/80877/1/manuscript.pdf|doi-access=free}} Adept is free software distributed under the Apache License.
Example
Adept implements automatic differentiation using an operator overloading approach, in which scalars to be differentiated are written as adouble
, indicating an "active" version of the normal double
, and vectors to be differentiated are written as aVector
. The following simple example uses these types to differentiate a 3-norm calculation on a small vector:
- include
- include
int main(int argc, const char** argv) {
using namespace adept;
Stack stack; // Object to store differential statements
aVector x(3); // Independent variables: active vector with 3 elements
x << 1.0, 2.0, 3.0; // Fill vector x
stack.new_recording(); // Clear any existing differential statements
adouble J = cbrt(sum(abs(x * x * x))); // Compute dependent variable: 3-norm in this case
J.set_gradient(1.0); // Seed the dependent variable
stack.reverse(); // Reverse-mode differentiation
std::cout << "dJ/dx = "
<< x.get_gradient() << "\n"; // Print the vector of partial derivatives dJ/dx
return 0;
}
When compiled and executed, this program reports the derivative as:
dJ/dx = {0.0917202, 0.366881, 0.825482}
See also
References
{{Reflist}}
External links
- [http://www.met.reading.ac.uk/clouds/adept/ Adept homepage]
{{DEFAULTSORT:Adept (C++ library)}}
Category:Articles with example C++ code
Category:C++ numerical libraries
Category:Free computer libraries
Category:Free mathematics software
Category:Free science software