Jump to content

Adept (C++ library)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Rjhogan (talk | contribs) at 13:54, 25 June 2023 (Updated logo). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Adept C++ Library
Developer(s)Robin Hogan
Stable release
2.1 / 5 February 2021 (3 years ago) (2021-02-05)
Repository
Written inC++
Operating systemCross-platform
TypeLibrary
LicenseApache 2.0 (open source)
Websitewww.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.[1][2] 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),[1][3][4][5][6] although comparable performance has been reported for Stan and in some cases Sacado.[3] 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 financial modeling,[6][7] computational fluid dynamics,[8] physical chemistry,[9] parameter estimation[10] and meteorology.[11] 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 <iostream>
#include <adept_arrays.h>

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

  1. ^ a b Hogan, Robin J. (2014). "Fast reverse-mode automatic differentiation using expression templates in C++" (PDF). ACM Trans. Math. Softw. 40 (4): 26:1–26:16. doi:10.1145/2560359. S2CID 9047237.
  2. ^ Griewank, Andreas (2014). "On automatic differentiation and algorithmic linearization". Pesquisa Operacional. 34 (3): 621–645. doi:10.1590/0101-7438.2014.034.03.0621.
  3. ^ a b Carpenter, Bob (2015). "The Stan Math Library: Reverse-Mode Automatic Differentiation in C++". arXiv:1509.07164 [cs.MS].
  4. ^ "Sensitivities in Quantitative Finance: Libor Swaption Portfolio Pricer (Monte-Carlo)". 2016-12-02. Retrieved 2017-10-21.
  5. ^ Rieck, Matthias. Discrete controls and constraints in optimal control problems (PDF) (PhD Thesis). Technical University of Munich. Retrieved 2017-10-21.
  6. ^ a b Zhao, Ze. Stochastic volatility models with applications in finance (Thesis). University of Iowa. Retrieved 2017-10-27.
  7. ^ Pagès, Gilles; Pironneau, Olivier; Sall, Guillaume (2016). "Vibrato and automatic differentiation for high order derivatives and sensitivities of financial options". arXiv:1606.06143 [q-fin.CP].
  8. ^ Albring, T.; Sagebaum, M.; Gauger, N. R. (2016). Dillmann, A.; Heller, G.; Krämer, E.; Wagner, C.; Breitsamter, C. (eds.). A Consistent and Robust Discrete Adjoint Solver for the SU2 Framework—Validation and Application. New Results in Numerical and Experimental Fluid Mechanics X. Notes on Numerical Fluid Mechanics and Multidisciplinary Design. Vol. 132. Springer, Cham. doi:10.1007/978-3-319-27279-5_7.
  9. ^ Niemeyer, Kyle E.; Curtis, Nicholas J.; Sung, Chih-Jen (2017). "pyJac: Analytical Jacobian generator for chemical kinetics". Comput. Phys. Commun. 215: 188–203. arXiv:1605.03262. Bibcode:2017CoPhC.215..188N. doi:10.1016/j.cpc.2017.02.004. S2CID 19675513.
  10. ^ Albert, Carlo; Ulzega, Simone; Stoop, Ruedi (2016). "Boosting Bayesian parameter inference of nonlinear stochastic differential equation models by Hamiltonian scale separation". Phys. Rev. E. 93 (43313): 043313. arXiv:1509.05305. Bibcode:2016PhRvE..93d3313A. doi:10.1103/PhysRevE.93.043313. PMID 27176434. S2CID 4479221.
  11. ^ Mason, S.; Chiu, J.-C.; Hogan, R. J.; Moisseev, D.; Kneifel, S. (2018). "Retrievals of riming and snow particle density from vertically-pointing Doppler radars" (PDF). J. Geophys. Res. 123. doi:10.1029/2018JD028603.