Skip to main content
Log in

CasADi: a software framework for nonlinear optimization and optimal control

  • Full Length Paper
  • Published:
Mathematical Programming Computation Aims and scope Submit manuscript


We present CasADi, an open-source software framework for numerical optimization. CasADi is a general-purpose tool that can be used to model and solve optimization problems with a large degree of flexibility, larger than what is associated with popular algebraic modeling languages such as AMPL, GAMS, JuMP or Pyomo. Of special interest are problems constrained by differential equations, i.e. optimal control problems. CasADi is written in self-contained C++, but is most conveniently used via full-featured interfaces to Python, MATLAB or Octave. Since its inception in late 2009, it has been used successfully for academic teaching as well as in applications from multiple fields, including process control, robotics and aerospace. This article gives an up-to-date and accessible introduction to the CasADi framework, which has undergone numerous design improvements over the last 7 years.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1

Similar content being viewed by others


  1. One may run these snippets on a Windows, Linux or Mac platform by following the install instructions for CasADi 3.1 at

  2. A paper draft is available at

  3. Support for finite differences, with automatic step-size selection, was added in CasADi 3.3.

  4. Cf. (Python) and (Octave).

  5. Two sparse direct linear solvers based on LDLT (for symmetric positive definite systems) and QR (for general sparse matrices), with support for C code generation, were added in CasADi 3.3.

  6. A new primal-dual active-set method for quadratic programming was added in CasADi 3.4.

  7. Support for automatic sensitivity analysis for NLPs was added in CasADi 3.4.


  1. Albersmeyer, J., Diehl, M.: The lifted Newton method and its application in optimization. SIAM J. Optim. 20(3), 1655–1684 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  2. Albert, A., Imsland, L., Haugen, J.: Numerical optimal control mixing collocation with single shooting: a case study. IFAC-PapersOnLine 49(7), 290–295 (2016)

    Article  MathSciNet  Google Scholar 

  3. Alexandrescu, A.: Modern C++ Design. Addison-Wesley, Reading (2001)

    Google Scholar 

  4. Anderson, E., et al.: LAPACK Users’ Guide, 3rd edn. SIAM, Philadelphia (1999)

    Book  MATH  Google Scholar 

  5. Andersson, J.: A General-Purpose Software Framework for Dynamic Optimization. Ph.D. thesis, Arenberg Doctoral School, KU Leuven (2013)

  6. Andersson, J., Kozma, A., Gillis, J., Diehl, M.: CasADi User Guide. Accessed 2 June 2018

  7. Andersson, L.E., Scibilia, F., Imsland, L.: An estimation-forecast set-up for iceberg drift prediction. Cold Reg. Sci. Technol. 131, 88–107 (2016)

    Article  Google Scholar 

  8. Axelsson, M., Magnusson, F., Henningsson, T.: A framework for nonlinear model predictive control in In: 11th International Modelica Conference, 118, pp. 301–310. Linköping University Electronic Press (2015)

  9. Bonmin. Accessed 1 Feb 2017

  10. Belkhir, F., Cabo, D.K., Feigner, F., Frey, G.: Optimal startup control of a steam power plant using the Jmodelica Platform. IFAC-PapersOnLine 48(1), 204–209 (2015)

    Article  Google Scholar 

  11. Belousov, B., Neumann, G., Rothkopf, C.A., Peters, J.R.: Catching heuristics are optimal control policies. In: Lee, D.D., Sugiyama, M., Luxburg, U.V., Guyon, I., Garnett, R. (eds.) Advances in Neural Information Processing Systems, pp. 1426–1434. Curran Associates, Red Hook, NY (2016)

  12. Berntorp, K., Magnusson, F.: Hierarchical predictive control for ground-vehicle maneuvering. In: American Control Conference (ACC), pp. 2771–2776 (2015)

  13. Berx, K., Gadeyne, K., Dhadamus, M., Pipeleers, G., Pinte, G.: Model-based gearbox synthesis. In: Mechatronics Forum International Conference, pp. 599–605 (2014)

  14. Biegler, L.: Solution of dynamic optimization problems by successive quadratic programming and orthogonal collocation. Comput. Chem. Eng. 8, 243–248 (1984)

    Article  Google Scholar 

  15. Bock, H., Eich, E., Schlöder, J.: Numerical solution of constrained least squares boundary value problems in differential-algebraic equations. In: Strehmel, K. (ed.) Numerical Treatment of Differential Equations. Teubner, Leipzig (1988)

    MATH  Google Scholar 

  16. Bock, H., Plitt, K.: A multiple shooting algorithm for direct solution of optimal control problems. In: IFAC World Congress, pp. 242–247. Pergamon Press (1984)

  17. Boiroux, D., Hagdrup, M., Mahmoudi, Z., Madsen, H., Bagterp, J., et al.: An ensemble nonlinear model predictive control algorithm in an artificial pancreas for people with type 1 diabetes. In: European Control Conference (ECC), pp. 2115–2120 (2016)

  18. Boyd, S., Vandenberghe, L.: Convex Optimization. Cambridge University Press, Cambridge (2004)

    Book  MATH  Google Scholar 

  19. Bremer, J., Rätze, K.H., Sundmacher, K.: Co$_{2}$ methanation: optimal start-up control of a fixed-bed reactor for power-to-gas applications. AIChE J. 63(1), 23–31 (2017)

    Article  Google Scholar 

  20. Büskens, C., Wassel, D.: Modeling and Optimization in Space Engineering, Chapter. The ESA NLP Solver WORHP. Springer, Berlin (2012)

    MATH  Google Scholar 

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

    Chapter  MATH  Google Scholar 

  22. casiopeia. Accessed 19 May 2017

  23. Clp. Accessed 1 Feb 2017

  24. CppAD. Accessed 11 May 2012

  25. Cabianca, L.: Advanced techniques for robust dynamic optimization of chemical reactors. Master’s thesis, Politecnico Milano (2014)

  26. Codas, A., Jahanshahi, E., Foss, B.: A two-layer structure for stabilization and optimization of an oil gathering network. IFAC-PapersOnLine 49(7), 931–936 (2016)

    Article  Google Scholar 

  27. Cuthrell, J., Biegler, L.: Simultaneous optimization and solution methods for batch reactor profiles. Comput. Chem. Eng. 13(1/2), 49–62 (1989)

    Article  Google Scholar 

  28. Davis, T.: Direct Methods for Sparse Linear Systems. SIAM, Philadelphia (2006)

    Book  MATH  Google Scholar 

  29. De Coninck, R., Helsen, L.: Practical implementation and evaluation of model predictive control for an office building in Brussels. Energy Build. 111, 290–298 (2016)

    Article  Google Scholar 

  30. De Coninck, R., Helsen, L.: Quantification of flexibility in buildings by cost curves—methodology and application. Appl. Energy 162, 653–665 (2016)

    Article  Google Scholar 

  31. De Coninck, R., Magnusson, F., Åkesson, J., Helsen, L.: Toolbox for development and validation of grey-box building models for forecasting and control. J. Build. Perform. Simul. 9(3), 288–303 (2016)

    Article  Google Scholar 

  32. Debrouwere, F., Loock, W.V., Pipeleers, G., Diehl, M., Schutter, J.D.: Time-optimal path following for robots with object collision avoidance using Lagrangian duality. In: 2012 Benelux Meeting on Systems and Control (2013)

  33. Debrouwere, F., Van Loock, W., Pipeleers, G., Swevers, J.: Time-optimal tube following for robotic manipulators. In: 2014 IEEE 13th International Workshop on Advanced Motion Control (AMC), pp. 392–397 (2014)

  34. Domahidi, A., Zgraggen, A., Zeilinger, M., Morari, M., Jones, C.: Efficient interior point methods for multistage problems arising in receding horizon control. In: IEEE Conference on Decision and Control (CDC), pp. 668 – 674. Maui (2012)

  35. Dunning, I., Huchette, J., Lubin, M.: JuMP: a modeling language for mathematical optimization. arXiv:1508.01982 [math.OC] (2015)

  36. Durand, H., Ellis, M., Christofides, P.D.: Economic model predictive control designs for input rate-of-change constraint handling and guaranteed economic performance. Comput. Chem. Eng. 92, 18–36 (2016)

    Article  Google Scholar 

  37. Ellis, M., Christofides, P.D.: On closed-loop economic performance under Lyapunov-based economic model predictive control. In: American Control Conference (ACC), pp. 1778–1783 (2016)

  38. Erhard, M., Horn, G., Diehl, M.: A quaternion-based model for optimal control of an airborne wind energy system. ZAMM J. Appl. Math. Mech. Z. Angew. Math. Mech. 97(1), 7–24 (2017)

    Article  Google Scholar 

  39. Ersdal, A.M., Fabozzi, D., Imsland, L., Thornhill, N.F.: Model predictive control for power system frequency control taking into account imbalance uncertainty. IFAC Proc. Vol. 47(3), 981–986 (2014)

    Article  Google Scholar 

  40. Ersdal, A.M., Imsland, L., Uhlen, K.: Model predictive load-frequency control. IEEE Trans. Power Syst. 31(1), 777–785 (2016)

    Article  Google Scholar 

  41. Feng, X., Houska, B.: Real-time algorithm for self-reflective model predictive control. arXiv:1611.02408 (2016)

  42. Ferreau, H.: qpOASES—an open-source implementation of the online active set strategy for fast model predictive control. In: Workshop on Nonlinear Model Based Control—Software and Applications, pp. 29–30 (2007)

  43. Fiacco, A.V., Ishizuka, Y.: Sensitivity and stability analysis for nonlinear programming. Ann. Oper. Res. 27, 215–235 (1990)

    Article  MathSciNet  MATH  Google Scholar 

  44. Fouquet, M., Guéguen, H., Faille, D., Dumur, D.: Hybrid dynamic optimization of power plants using sum-up rounding and adaptive mesh refinement. In: IEEE Conference on Control Applications, pp. 316–321 (2014)

  45. Fourer, R., Gay, D.M., Kernighan, B.W.: AMPL: a modeling language for mathematical programming, 2nd edn. Thomson, Stamford (2003)

    MATH  Google Scholar 

  46. Frasch, J.V., Vukov, M., Ferreau, H., Diehl, M.: A dual Newton strategy for the efficient solution of sparse quadratic programs arising in SQP-based nonlinear MPC (2013). Optimization Online 3972

  47. Frasch, J.V., Wirsching, L., Sager, S., Bock, H.G.: Mixed-level iteration schemes for nonlinear model predictive control. IFAC Proc. Vol. 45(17), 138–144 (2012)

    Article  Google Scholar 

  48. Frison, G., Sorensen, H., Dammann, B., Jorgensen, J.: High-performance small-scale solvers for linear model predictive control. In: European Control Conference (ECC), pp. 128–133 (2014)

  49. Gabiccini, M., Artoni, A., Pannocchia, G., Gillis, J.: A computational framework for environment-aware robotic manipulation planning. In: Bicchi, A., Burgard, W. (eds.) Robotics Research. Proceedings in Advanced Robotics, vol 3. Springer, Cham (2018)

  50. Gebremedhin, A.H., Manne, F., Pothen, A.: What color is your Jacobian? Graph coloring for computing derivatives. SIAM Rev. 47, 629–705 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  51. Geebelen, K., Wagner, A., Gros, S., Swevers, J., Diehl, M.: Moving horizon estimation with a huber penalty function for robust pose estimation of tethered airplanes. In: American Control Conference (ACC), pp. 6169–6174 (2013)

  52. Gertz, E., Wright, S.: Object-oriented software for quadratic programming. ACM Trans. Math. Softw. 29(1), 58–81 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  53. Gesenhues, J., Hein, M., Habigt, M., Mechelinck, M., Albin, T., Abel, D.: Nonlinear object-oriented modeling based optimal control of the heart. In: European Control Conference (ECC), pp. 2108–2114 (2016)

  54. Giering, R., Kaminski, T.: Automatic sparsity detection implemented as a source-to-source transformation. In: Alexandrov, V.N., van Albada, G.D., Sloot, P.M.A., Dongarra, J. (eds.) Lecture Notes in Computer Science, vol. 3994, pp. 591–598. Springer, Berlin, Heidelberg (2006)

  55. Giles, M.: Collected matrix derivative results for forward and reverse mode algorithmic differentiation. In: Bischof, C.H., Bücker, H.M., Hovland, P., Naumann, U., Utke, J. (eds.) Advances in Automatic Differentiation, pp. 35–44. Springer, Berlin (2008)

  56. Gill, P., Murray, W., Saunders, M.: SNOPT: an SQP algorithm for large-scale constrained optimization. SIAM Rev. 47(1), 99–131 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  57. Gillis, J.: Practical methods for approximate robust periodic optimal control of nonlinear mechanical systems. Ph.D. thesis, Arenberg Doctoral School, KU Leuven (2015)

  58. 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., Technical University of Dresden, Institute of Scientific Computing and Institute of Geometry (1999). Updated version of the paper published in ACM Transactions on Mathematical Software, vol. 22, pp. 131–167 (1996)

  59. Griewank, A., Mitev, C.: Detecting Jacobian sparsity patterns by Bayesian probing. Math. Program. 93(1), 1–25 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  60. Griewank, A., Walther, A.: Evaluating Derivatives, 2nd edn. SIAM, Philadelphia (2008)

    Book  MATH  Google Scholar 

  61. Gros, S.: A distributed algorithm for NMPC-based wind farm control. In: IEEE Conference on Decision and Control (CDC), pp. 4844–4849 (2014)

  62. Gros, S., Diehl, M.: Modeling of airborne wind energy systems in natural coordinates. In: Ahrens, U., Diehl, M., Schmehl, R. (eds.) Airborne Wind Energy. Springer, Berlin (2013)

  63. Gros, S., Zanon, M., Diehl, M.: Baumgarte stabilisation over the SO (3) rotation group for control. In: IEEE Conference on Decision and Control (CDC), pp. 620–625 (2015)

  64. Gurobi Optimizer Reference Manual Version 7.0. Accessed 2 June 2018

  65. HSL. A collection of Fortran codes for large scale scientific computation. Accessed 2 June 2018

  66. Hanssen, K.G., Foss, B.: Scenario based implicit dual model predictive control. IFAC-PapersOnLine 48(23), 416–421 (2015)

    Article  Google Scholar 

  67. Hart, W., Watson, J.P., Woodruff, D.: Pyomo: modeling and solving mathematical programs in Python. Math. Program. Comput. 3(3), 1–42 (2011)

    Article  MathSciNet  Google Scholar 

  68. Haugen, J., Imsland, L.: Monitoring moving objects using aerial mobile sensors. IEEE Trans. Control Syst. Technol. 24(2), 475–486 (2016)

    Google Scholar 

  69. Herrmann, S., Utschick, W.: Availability and interpretability of optimal control for criticality estimation in vehicle active safety. In: Design, Automation & Test in Europe Conference & Exhibition (DATE), pp. 415–420 (2016)

  70. Hindmarsh, A., et al.: SUNDIALS: suite of nonlinear and differential/algebraic equation solvers. ACM Trans. Math. Softw. 31, 363–396 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  71. Holmqvist, A., Magnusson, F.: Open-loop optimal control of batch chromatographic separation processes using direct collocation. J. Process Control 46, 55–74 (2016)

    Article  Google Scholar 

  72. Holmqvist, A., et al.: Dynamic parameter estimation of atomic layer deposition kinetics applied to in situ quartz crystal microbalance diagnostics. Chem. Eng. Sci. 111, 15–33 (2014)

    Article  Google Scholar 

  73. Horn, G., Diehl, M.: Numerical trajectory optimization for airborne wind energy systems described by high fidelity aircraft models. In: Ahrens, U., Diehl, M., Schmehl, R. (eds.) Airborne Wind Energy, pp. 205–218. Springer, Berlin, Heidelberg (2013)

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

  75. Janka, D., Kirches, C., Sager, S., Wchter, A.: An SR1/BFGS SQP algorithm for nonconvex nonlinear programs with block-diagonal Hessian matrix. Math. Program. Comput. 8(4), 435–459 (2016)

    Article  MathSciNet  MATH  Google Scholar 

  76. Kirches, C.: Fast numerical methods for mixed-integer nonlinear model-predictive control. Ph.D. thesis, Ruprecht-Karls-Universität Heidelberg (2010)

  77. Krishnamoorthy, D., Foss, B., Skogestad, S.: Real-time optimization under uncertainty applied to a gas lifted well network. Processes 4(4), 52 (2016)

    Article  Google Scholar 

  78. Larsson, P.O., Casella, F., Magnusson, F., Andersson, J., Diehl, M., Akesson, J.: A framework for nonlinear model-predictive control using object-oriented modeling with a case study in power plant start-up. In: IEEE Conference on Computer Aided Control System Design (CACSD), pp. 346–351 (2013)

  79. Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In: International Symposium on Code Generation and Optimization (2004)

  80. Le, T.T., Truong, B.D., Jost, F., Le, C.P., Halvorsen, E., Sager, S.: Synthesis of optimal controls and numerical optimization for the vibration-based energy harvesters. arXiv:1608.08885 (2016)

  81. Leek, V.: An Optimal Control Toolbox for MATLAB Based on CasADi. Master’s thesis, Linköping University (2016)

  82. 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 

  83. Licitra, G., Sieberling, S., Engelen, S., Williams, P., Ruiterkamp, R., Diehl, M.: Optimal control for minimizing power consumption during holding patterns for airborne wind energy pumping system. In: European Control Conference (ECC), pp. 1574–1579 (2016)

  84. Liu, M., Tan, Y., Padois, V.: Generalized hierarchical control. Auton. Robots 40, 17–31 (2016)

    Article  Google Scholar 

  85. Lopes, V.V., et al.: On the use of markov chain models for the analysis of wind power time-series. In: Conference on Environment and Electrical Engineering (EEEIC), pp. 770–775 (2012)

  86. Lucia, S., Andersson, J.A., Brandt, H., Bouaswaig, A., Diehl, M., Engell, S.: Efficient robust economic nonlinear model predictive control of an industrial batch reactor. IFAC Proc. Vol. 47(3), 11093–11098 (2014)

    Article  Google Scholar 

  87. Lucia, S., Engell, S.: Control of towing kites under uncertainty using robust economic nonlinear model predictive control. In: European Control Conference (ECC), pp. 1158–1163 (2014)

  88. Lucia, S., Paulen, R.: Robust nonlinear model predictive control with reduction of uncertainty via robust optimal experiment design. IFAC Proc. Vol. 47(3), 1904–1909 (2014)

    Article  Google Scholar 

  89. Lucia, S., Paulen, R., Engell, S.: Multi-stage nonlinear model predictive control with verified robust constraint satisfaction. In: IEEE Conference on Decision and Control (CDC), pp. 2816–2821 (2014)

  90. Lucia, S., Schliemann-Bullinger, M., Findeisen, R., Bullinger, E.: A set-based optimal control approach for pharmacokinetic/pharmacodynamic drug dosage design. IFAC-PapersOnLine 49(7), 797–802 (2016)

    Article  Google Scholar 

  91. Lucia, S., Tătulea-Codrean, A., Schoppmeyer, C., Engell, S.: An environment for the efficient testing and implementation of robust nmpc. In: IEEE Conference on Control Applications, pp. 1843–1848 (2014)

  92. Lucia, S., Tătulea-Codrean, A., Schoppmeyer, C., Engell, S.: Rapid development of modular and sustainable nonlinear model predictive control solutions. Control Eng. Pract. 60, 51–62 (2017)

    Article  Google Scholar 

  93. Lundahl, K., Lee, C.F., Frisk, E., Nielsen, L.: Path-dependent rollover prevention for critical truck maneuvers. In: Symposium of the International Association for Vehicle System Dynamics (IAVSD 2015), p. 317. CRC Press (2016)

  94. Lynn, L.L., Parkin, E.S., Zahradnik, R.L.: Near-optimal control by trajectory approximations. I&EC Fundam. 9(1), 58–63 (1970)

    Article  Google Scholar 

  95. Lynn, L.L., Zahradnik, R.L.: The use of orthogonal polynomials in the near-optimal control of distributed systems by trajectory approximation. Int. J. Control 12(6), 1079–1087 (1970)

    Article  MATH  Google Scholar 

  96. mpc-tools-casadi. Accessed 19 May 2017

  97. Magnusson, F., Åkesson, J.: Dynamic optimization in Processes 3(2), 471–496 (2015)

    Article  Google Scholar 

  98. Marcucci, T., Gabiccini, M., Artoni, A.: A two-stage trajectory optimization strategy for articulated bodies with unscheduled contact sequences. IEEE Robot. Autom. Lett. 2(1), 104–111 (2017)

    Article  Google Scholar 

  99. Maree, J., Imsland, L.: Multi-objective predictive control for non steady-state operation. In: European Control Conference (ECC), pp. 1541–1546 (2013)

  100. Maree, J., Imsland, L.: On multi-objective economic predictive control for cyclic process operation. J. Process Control 24(8), 1328–1336 (2014)

    Article  Google Scholar 

  101. Maree, J.P., Imsland, L.: Optimal control strategies for oil production under gas coning conditions. In: IEEE Conference on Control Applications, pp. 572–578 (2014)

  102. Martí, R., et al.: An efficient distributed algorithm for multi-stage robust nonlinear predictive control. In: European Control Conference (ECC), pp. 2664–2669 (2015)

  103. Merz, M., Johansen, T.A.: Feasibility study of a circularly towed cable-body system for uav applications. In: Conference on Unmanned Aircraft Systems (ICUAS), pp. 1182–1191 (2016)

  104. Minko, T., Wisniewski, R., Bendtsen, J.D., Izadi-Zamanabadi, R.: Non-linear model predictive supervisory controller for building, air handling unit with recuperator and refrigeration system with heat waste recovery. In: IEEE Conference on Control Applications, pp. 1274–1281 (2016)

  105. Mukkula, A.R.G., Paulen, R.: Model-based design of optimal experiments for nonlinear systems in the context of guaranteed parameter estimation. Comput. Chem. Eng. 99, 198–213 (2017)

    Article  Google Scholar 

  106. Naumann, U.: The Art of Differentiating Computer Programs: An Introduction to Algorithmic Differentiation. No. 24 in Software, Environments, and Tools. SIAM, Philadelphia (2012)

    Google Scholar 

  107. Nezhadali, V., Eriksson, L.: A framework for modeling and optimal control of automatic transmission systems. IFAC-PapersOnLine 48(15), 285–291 (2015)

    Article  Google Scholar 

  108. Nezhadali, V., Eriksson, L.: Optimal control of engine controlled gearshift for a diesel-electric powertrain with backlash. IFAC-PapersOnLine 49(11), 762–768 (2016)

    Article  Google Scholar 

  109. Nimmegeers, P., Telen, D., Beetens, M., Logist, F., Van Impe, J.: Parametric uncertainty propagation for robust dynamic optimization of biological networks. In: American Control Conference (ACC), pp. 6929–6934 (2016)

  110. Nimmegeers, P., Telen, D., Logist, F., Van Impe, J.: Dynamic optimization of biological networks under parametric uncertainty. BMC Syst. Biol. 10(1), 86 (2016)

    Article  Google Scholar 

  111. Pannocchia, G., Gabiccini, M., Artoni, A.: Offset-free MPC explained: novelties, subtleties, and applications. IFAC-PapersOnLine 48(23), 342–351 (2015)

    Article  Google Scholar 

  112. Patil, S., Kahn, G., Laskey, M., Schulman, J., Goldberg, K., Abbeel, P.: Scaling up gaussian belief space planning through covariance-free trajectory optimization and automatic differentiation. In: Algorithmic Foundations of Robotics XI, pp. 515–533. Springer, Berlin (2015)

  113. Poland, J., Stadler, K.S.: Stochastic optimal planning of solar thermal power. In: Les Antibes J. (ed.) IEEE Conference on Control Applications, pp. 593–598 (2014)

  114. Reiter, A., Müller, A., Gattringer, H.: Inverse kinematics in minimum-time trajectory planning for kinematically redundant manipulators. In: Annual Conference of the IEEE Industrial Electronics Society (IECON), pp. 6873–6878 (2016)

  115. Rostampour, V., Esfahani, P.M., Keviczky, T.: Stochastic nonlinear model predictive control of an uncertain batch polymerization reactor. IFAC-PapersOnLine 48(23), 540–545 (2015)

    Article  Google Scholar 

  116. Scholz, T., Raischel, F., Lopes, V.V., Lehle, B., Wächter, M., Peinke, J., Lind, P.G.: Parameter-free resolution of the superposition of stochastic signals. Phys. Lett. A 381(4), 194–206 (2017)

    Article  MathSciNet  MATH  Google Scholar 

  117. Scott, P., Thiébaux, S.: Distributed multi-period optimal power flow for demand response in microgrids. In: ACM Conference on Future Energy Systems, pp. 17–26 (2015)

  118. Sirmatel, I.I., Geroliminis, N.: Model predictive control of large-scale urban networks via perimeter control and route guidance actuation. In: IEEE Conference on Decision and Control (CDC), pp. 6765–6770 (2016)

  119. Sivertsson, M., Eriksson, L.: Optimal stationary control of diesel engines using periodic control. J. Automob. Eng. 231(4), 457–475 (2017)

    Article  Google Scholar 

  120. Skjong, E., et al.: Management of harmonic propagation in a marine vessel by use of optimization. In: IEEE Transportation Electrification Conference and Expo (ITEC), pp. 1–8 (2015)

  121. St John, P.C., Doyle, F.J.: Estimating confidence intervals in predicted responses for oscillatory biological models. BMC Syst. Biol. 7(1), 71 (2013)

    Article  Google Scholar 

  122. Thangavel, S., Lucia, S., Paulen, R., Engell, S.: Towards dual robust nonlinear model predictive control: A multi-stage approach. In: American Control Conference (ACC), pp. 428–433 (2015)

  123. Trägårdh, M., et al.: Input estimation for drug discovery using optimal control and markov chain Monte Carlo approaches. J. Pharmacokinet. Pharmacodyn. 43(2), 207–221 (2016)

    Article  Google Scholar 

  124. Utstumo, T., Berge, T.W., Gravdahl, J.T.: Non-linear model predictive control for constrained robot navigation in row crops. In: IEEE Conference on Industrial Technology (ICIT), pp. 357–362 (2015)

  125. van Duijkeren, N., Keviczky, T., Nilsson, P., Laine, L.: Real-time NMPC for semi-automated highway driving of long heavy vehicle combinations. IFAC-PapersOnLine 48(23), 39–46 (2015)

    Article  Google Scholar 

  126. Vallerio, M., Vercammen, D., Van Impe, J., Logist, F.: Interactive NBI and (E)NNC methods for the progressive exploration of the criteria space in multi-objective optimization and optimal control. Comput. Chem. Eng. 82, 186–201 (2015)

    Article  Google Scholar 

  127. Van Loock, W., Pipeleers, G., Swevers, J.: B-spline parameterized optimal motion trajectories for robotic systems with guaranteed constraint satisfaction. Mech. Sci. 6(2), 163–171 (2015)

    Article  Google Scholar 

  128. Van Parys, R., Pipeleers, G.: Online distributed motion planning for multi-vehicle systems. In: European Control Conference (ECC), pp. 1580–1585 (2016)

  129. Venrooij, J., et al.: Comparison between filter-and optimization-based motion cueing in the Daimler driving simulator. In: Driving Simulation Conference (2016)

  130. Verheyleweghen, A., Jäschke, J.: Health-aware operation of a subsea gas compression system under uncertainty. In: Foundations of Computer Aided Process Operations/Chemical Process Control (2017)

  131. Verschueren, R., van Duijkeren, N., Quirynen, R., Diehl, M.: Exploiting convexity in direct optimal control: a sequential convex quadratic programming method. In: IEEE Conference on Decision and Control (CDC), pp. 1099–1104 (2016)

  132. Verschueren, R., van Duijkeren, N., Swevers, J., Diehl, M.: Time-optimal motion planning for n-dof robot manipulators using a path-parametric system reformulation. In: American Control Conference (ACC), pp. 2092–2097 (2016)

  133. Vochten, M., De Laet, T., De Schutter, J.: Generalizing demonstrated motions and adaptive motion generation using an invariant rigid body trajectory representation. In: IEEE Conference on Robotics and Automation (ICRA), pp. 234–241 (2016)

  134. Wächter, A., Biegler, L.: On the implementation of a primal-dual interior point filter line search algorithm for large-scale nonlinear programming. Math. Program. 106(1), 25–57 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  135. Walraven, D., et al.: Optimum configuration of shell-and-tube heat exchangers for the use in low-temperature organic rankine cycles. Energy Convers. Manag. 83, 177–187 (2014)

    Article  Google Scholar 

  136. Welsh, D.J.A., Powell, M.B.: An upper bound for the chromatic number of a graph and its application to timetabling problems. Comput. J. 10, 85–86 (1967)

    Article  MATH  Google Scholar 

Download references


The authors thank for the generous support that has made this work possible. In particular: the K.U. Leuven Research Council via CoE EF/05/006 Optimization in Engineering (OPTEC); the Flemish Government via FWO; the Belgian State via Science Policy programming (IAP VII, DYSCO); the European Union via HDMPC (223854), EMBOCON (248940), HIGHWIND (259166), TEMPO (607957), AWESCO (642682); the Helmholtz Association via vICERP; the German Federal Ministry for Economic Affairs and Energy (BMWi) via projects eco4wind and DyConPV; the German Research Foundation (DFG) via Research Unit FOR 2401; Flanders Make via MBSE4M, Drivetrain Co-design, Conceptdesign. We also thank our industrial partners, including GE Global Research and Johnson Controls International Inc. Finally, we thank the reviewers for valuable comments that helped to improve the final manuscript.

Author information

Authors and Affiliations


Corresponding author

Correspondence to Joel A. E. Andersson.

Additional information

The software reviewed as part of this submission was given the digital object identifier (DOI)

Summary of main features of CasADi, version 3.4.4

Summary of main features of CasADi, version 3.4.4

In the following is a summary of the main features of CasADi 3.4.4, which was released in May 2018, after the acceptance of this paper. Newly added features, not present in CasADi 3.1 covered so far, are marked with footnotes. More details about these features can be found on the CasADi webpage,, and in the paper Sensitivity Analysis for Nonlinear Programming in CasADi, which is currently in preparation.Footnote 2

1.1 Symbolic framework with algorithmic differentiation (AD)

A state-of-the-art implementation of algorithmic differentiation (AD), implemented within a symbolic framework, forms the backbone of CasADi. Users construct directed acyclic expression graphs using an everything-is-a-sparse-matrix syntax and expressions for derivatives are generated automatically using AD via source-code-transformation. CasADi implements the forward and reverse modes of AD and uses a graph coloring approach to construct large-and-sparse Jacobians and Hessians. Generated expressions are encapsulated in function objects that can be evaluated, numerically or symbolically, in virtual machines (VMs).

Compared to similar frameworks, CasADi scales well to higher dimensions, and offers a rich set of differentiable operations. Supported operations include common matrix-valued operations, serial or parallel function calls, (non)linear systems of equations, initial-value problems in ordinary differential equations (ODE) or differential-algebraic equations (DAE) and spline-based lookup tables. External code can be embedded with derivative information either user-provided or approximated by finite differences.Footnote 3

1.2 Core self-containment, auto-generated front-ends via SWIG

The symbolic core of CasADi is written in modern C++, with no external dependencies. While C++ offers great interoperability with other tools, high performance and multi-platform support, it lacks the interactivity and ease-of-use associated with scripting languages such as Python or MATLAB/Octave. CasADi was therefore designed to allow front-ends to be generated automatically using the open-source tool SWIG. At the time of this writing, Python, MATLAB and Octave were supported through full-featured and documented front-ends. The tool has also been successfully used from JAVA and Haskell.

1.3 License and availability

CasADi’s source code is hosted on Github and released under GNU Lesser General Public License (LGPL) on The relatively permissive LGPL allows CasADi to be used royalty-free in commercial and academic software. The code is built and tested on travis-ci, with full-featured binaries available for common Linux, Mac and Windows systems. In addition, the Python interface is available from pip. CasADi can also be run from a demo server.Footnote 4

1.4 C code generation, just-in-time compilation

A large subset of expressions can be exported as self-contained C code without memory allocation. This is useful for embedded applications or to speed up computations using just-in-time compilation (JIT). The C code can be compiled into shared libraries or be called directly from either MATLAB/Octave via a generated MEX interface or from the command line.

1.5 Plugin infrastructure

The core of CasADi supports a number of standard problems in numerical optimization, including initial-value problems in ODE or DAE, linear and nonlinear systems of equations, nonlinear programs (NLPs) and quadratic programs (QPs). The user specifies such problems in a uniform way and the solution is delegated to a solver plugin, loaded as a dynamically linked library (DLL) at runtime. Solver plugins include solvers that are distributed with CasADi and interfaces to third-party software packages.

1.6 Linear systems of equations

Linear systems of equations can be embedded into symbolic expressions via “backslash” nodes. Derivatives of such operations are calculated via chain rules for linear system solves. Supported plugins include LDLT and QRFootnote 5 as well as interfaces to CSPARSE and LAPACK.

1.7 Nonlinear systems of equations

Nonlinear systems of equations can be formulated and solved by defining rootfinder instances in CasADi. Derivatives of such objects are calculated analytically using the implicit function theorem and the chain rule for linear system solves. Supported plugins include standard Newton methods and KINSOL from the SUNDIALS suite.

1.8 Initial-value problems in ODE/DAE with automatic sensitivity analysis

Initial-value problems in ODE or DAE can be calculated using explicit or implicit Runge–Kutta methods or interfaces to IDAS/CVODES from the SUNDIALS suite. Derivatives of arbitrary order are calculated using automatically generated forward and adjoint sensitivity equations.

1.9 Quadratic programming

QPs can be formulated either using a traditional syntax, by explicitly providing the linear and quadratic terms, or using a syntax which mirrors that of NLP solvers. Solvers for quadratic programming include a primal-dual active-set methodFootnote 6 and interfaces to CPLEX, GUROBI, HPMPC, OOQP and qpOASES. A subset of the solvers support mixed-integer QPs.

1.10 Nonlinear programming with automatic sensitivity analysis, Optistack

NLPs can be solved using block structure or general sparsity exploiting sequential quadratic programming (SQP) or interfaces to IPOPT/BONMIN, BlockSQP, WORHP, KNITRO and SNOPT. Solution sensitivities can be calculated automatically by applying the implicit function theorem to the first order optimality conditions.Footnote 7 A subset of the solvers support mixed-integer NLPs.

Optistack, a simple but powerful abstraction layer, simplifies the formulation and solution of NLPs. It manages the creation and optimal-value retrieval of decision variables, allows a mathematical notation to specify constraints, and may identify problematic constraints when a solver reports infeasibility.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Andersson, J.A.E., Gillis, J., Horn, G. et al. CasADi: a software framework for nonlinear optimization and optimal control. Math. Prog. Comp. 11, 1–36 (2019).

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI:


Mathematics Subject Classification