We introduce CasADi; a minimalistic computer algebra system written in completely self-contained C++. The aim of the tool is to offer the benifits of a computer algebra to developers of C++ code; without the overhead usually associated with such systems. In particular; we use the tool to implement automatic differentiation; AD.
For maximum efficiency; CasADi works with two different graph representations interchangeably: One supporting only scalar-valued; built-in unary and binary operations and no branching; similar to the representation used by todayâ€™s tools for automatic differentiation by operator overloading. Secondly; a representation supporting matrixvalued operations; branchings such as if-statements as well as function calls to arbitrary functions (e.g. ODE/DAE integrators).
We show that the tool performs favorably compared to CppAD and ADOL-C; two state-of-the-art tools for AD by operator overloading. We also show how the tool can be used to solve a simple optimal control problem; minimal fuel rocket flight; by implementing a simple ODE integrator with sensitivity capabilities and solving the problem with the NLP solver IPOPT. In the last example; we show how we can use the tool to couple the modelling tool Jmodelica with the optimal control software ACADO Toolkit.
Keywords: computer algebra system; automatic differentiation; algorithmic differentiation; dynamic optimization; Modelica