Skip to main content

CasADi: A Symbolic Package for Automatic Differentiation and Optimal Control

  • Conference paper
  • First Online:
Recent Advances in Algorithmic Differentiation

Part of the book series: Lecture Notes in Computational Science and Engineering ((LNCSE,volume 87))

Abstract

We present CasADi, a free, open-source software tool for fast, yet efficient solution of nonlinear optimization problems in general and dynamic optimization problems in particular. To the developer of algorithms for numerical optimization and to the advanced user of such algorithms, it offers a level of abstraction which is notably lower, and hence more flexible, than that of algebraic modeling languages such as AMPL or GAMS, but higher than working with a conventional automatic differentiation (AD) tool.CasADi is best described as a minimalistic computer algebra system (CAS) implementing automatic differentiation in eight different flavors. Similar to algebraic modeling languages, it includes high-level interfaces to state-of-the-art numerical codes for nonlinear programming, quadratic programming and integration of differential-algebraic equations. CasADi is implemented in self-contained C++ code and contains full-featured front-ends to Python and Octave for rapid prototyping. In this paper, we present the AD framework of CasADi and benchmark the tool against AMPL for a set of nonlinear programming problems from the CUTEr test suite.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    A sparse input in this context is an input that is never used by the operation.

  2. 2.

    The template class Matrix<> can also be instantiated with other types, including numerical types and (though it has not been tested) the scalar types of other AD tools.

References

  1. DyOS User Manual. RWTH Aachen University, Germany, 2.1 edn. (2002)

    Google Scholar 

  2. Anderson, E., et al.: Lapack Users’ Guide, 2 edn. SIAM, Philadelphia (1995)

    Google Scholar 

  3. Beazley, D.M.: Automated scientific software scripting with SWIG. Future Gener. Comput. Syst. 19, 599–609 (2003)

    Google Scholar 

  4. Bell, B.: CppAD: a package for C++ algorithmic differentiation. Computational Infrastructure for Operations Research coin-or(http://www.coin-or.org/CppAD) (2012)

  5. Bergstra, J., Breuleux, O., Bastien, F., Lamblin, P., Pascanu, R., Desjardins, G., Turian, J., Bengio, Y.: Theano: a CPU and GPU math expression compiler. In: Proceedings of the Python for Scientific Computing Conference (SciPy) (2010). Oral

    Google Scholar 

  6. Bischof, C.H., Bücker, H.M.: Computing derivatives of computer programs. In: J. Grotendorst (ed.) Modern Methods and Algorithms of Quantum Chemistry: Proceedings, Second Edition, NIC Series, vol. 3, pp. 315–327. NIC-Directors, Jülich (2000). URL http://www.fz-juelich.de/nic-series/Volume3/bischof.pdf

  7. Bischof, C.H., Bücker, H.M., Lang, B., Rasch, A., Vehreschild, A.: Combining source transformation and operator overloading techniques to compute derivatives for MATLAB programs. In: Proceedings of the Second IEEE International Workshop on Source Code Analysis and Manipulation (SCAM 2002), pp. 65–72. IEEE Computer Society, Los Alamitos, CA, USA (2002). DOI 10.1109/SCAM.2002.1134106

    Google Scholar 

  8. Bock, H., Plitt, K.: A multiple shooting algorithm for direct solution of optimal control problems. In: Proceedings 9th IFAC World Congress Budapest, pp. 243–247. Pergamon Press (1984). URL http://www.iwr.uni-heidelberg.de/groups/agbock/FILES/Bock1984.pdf

  9. Byrd, R.H., Nocedal, J., Waltz, R.A.: KNITRO: An integrated package for nonlinear optimization. In: G. Pillo, M. Roma (eds.) Large Scale Nonlinear Optimization, pp. 35–59. Springer Verlag (2006)

    Google Scholar 

  10. Coleman, T.F., Verma, A.: ADMAT: An automatic differentiation toolbox for MATLAB. Tech. rep., Computer Science Department, Cornell University (1998)

    Google Scholar 

  11. Corp., I.: IBM ILOG CPLEX V12.1, User’s Manual for CPLEX (2009)

    Google Scholar 

  12. Ferreau, H.: qpOASES – An Open-Source Implementation of the Online Active Set Strategy for Fast Model Predictive Control. In: Proceedings of the Workshop on Nonlinear Model Based Control – Software and Applications, Loughborough, pp. 29–30 (2007)

    Google Scholar 

  13. Forth, S.A.: An efficient overloaded implementation of forward mode automatic differentiation in MATLAB. ACM Transactions on Mathematical Software 32(2), 195–222 (2006). URL http://doi.acm.org/10.1145/1141885.1141888

  14. Gay, D.M.: Automatic differentiation of nonlinear AMPL models. In: A. Griewank, G.F. Corliss (eds.) Automatic Differentiation of Algorithms: Theory, Implementation, and Application, pp. 61–73. SIAM, Philadelphia, PA (1991)

    Google Scholar 

  15. Gebremedhin, A.H., Manne, F., Pothen, A.: What color is your Jacobian? graph coloring for computing derivatives. SIAM Review 47(4), 629–705 (2005). DOI 10.1137/S0036144504444711. URL http://link.aip.org/link/?SIR/47/629/1

  16. Gertz, E., Wright, S.: Object-Oriented Software for Quadratic Programming. ACM Transactions on Mathematical Software 29(1), 58–81 (2003)

    Google Scholar 

  17. Griewank, A., Juedes, D., Mitev, H., Utke, J., Vogel, O., Walther, A.: ADOL-C: A package for the automatic differentiation of algorithms written in C/C++. Tech. rep., Institute of Scientific Computing, Technical University Dresden (1999). Updated version of the paper published in ACM Trans. Math. Software 22, 1996, 131–167

    Google Scholar 

  18. Griewank, A., Mitev, C.: Detecting Jacobian sparsity patterns by Bayesian probing. Mathematical Programming, Ser. A 93(1), 1–25 (2002). DOI 10.1007/s101070100281

    Google Scholar 

  19. Griewank, A., Walther, A.: Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, 2nd edn. No. 105 in Other Titles in Applied Mathematics. SIAM, Philadelphia, PA (2008). URL http://www.ec-securehost.com/SIAM/OT105.html

  20. Hindmarsh, A., et al.: SUNDIALS: Suite of nonlinear and differential/algebraic equation solvers. ACM Transactions on Mathematical Software 31, 363–396 (2005)

    Google Scholar 

  21. Houska, B., Ferreau, H., Diehl, M.: An Auto-Generated Real-Time Iteration Algorithm for Nonlinear MPC in the Microsecond Range. Automatica 47(10), 2279–2285 (2011)

    Google Scholar 

  22. Kharche, R.V., Forth, S.A.: Source transformation for MATLAB automatic differentiation. In: V.N. Alexandrov, G.D. van Albada, P.M.A. Sloot, J. Dongarra (eds.) Computational Science – ICCS 2006, Lecture Notes in Computer Science, vol. 3994, pp. 558–565. Springer, Heidelberg (2006). DOI 10.1007/11758549{ _}77

    Google Scholar 

  23. Leineweber, D.: Efficient reduced SQP methods for the optimization of chemical processes described by large sparse DAE models, Fortschritt-Berichte VDI Reihe 3, Verfahrenstechnik, vol. 613. VDI Verlag, Düsseldorf (1999)

    Google Scholar 

  24. von Stryk, O.: User’s Guide for DIRCOL. Technische Universität Darmstadt (2000)

    Google Scholar 

  25. Verma, A.: Structured automatic differentiation. Ph.D. thesis, Department of Computer Science, Cornell University, Ithaca, NY (1998)

    Google Scholar 

  26. Wächter, A., Biegler, L.: On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming. Mathematical Programming 106(1), 25–57 (2006)

    Google Scholar 

Download references

Acknowledgements

Joel Andersson and Moritz Diehl were supported by the Research Council KUL: GOA/11/05 Ambiorics, GOA/10/09 MaNet , CoE EF/05/006 Optimization in Engineering (OPTEC) en PFV/10/002 (OPTEC), IOF-SCORES4CHEM, several PhD/postdoc & fellow grants; Flemish Government: FWO: PhD/postdoc grants, projects: G0226.06 (cooperative systems and optimization), G0321.06 (Tensors), G.0302.07 (SVM/ Kernel), G.0320.08 (convex MPC), G.0558.08 (Robust MHE), G.0557.08 (Glycemia2), G.0588.09 (Brain-machine) research communities (WOG: ICCoS, ANMMM, MLDM); G.0377.09 (Mechatronics MPC) IWT: PhD Grants, Eureka-Flite+, SBO LeCoPro, SBO Climaqs, SBO POM, O&O-Dsquare Belgian Federal Science Policy Office: IUAP P6/04 (DYSCO, Dynamical systems, control and optimization, 2007–2011) ; EU: ERNSI; FP7-HD-MPC (INFSO - ICT - 223854), COST intelliCIS, FP7-EMBOCON (ICT-248940), FP7-SADCO ( MC ITN-264735), ERC HIGHWIND (259 166) Contract Research: AMINAL Helmholtz: vICERP ACCM

Johan Ã…kesson was supported by the Swedish Research Council in the framework the Lund Center for Control of Complex Engineering Systems.

The authors also would like thank the anonymous reviewers who helped to improve the original manuscript and everyone who has contributed to the CasADi project, in particular Joris Gillis, Attila Kozma and Carlo Savorgnan.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Joel Andersson .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Andersson, J., Ã…kesson, J., Diehl, M. (2012). CasADi: A Symbolic Package for Automatic Differentiation and Optimal Control. In: Forth, S., Hovland, P., Phipps, E., Utke, J., Walther, A. (eds) Recent Advances in Algorithmic Differentiation. Lecture Notes in Computational Science and Engineering, vol 87. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-30023-3_27

Download citation

Publish with us

Policies and ethics