Towards a Computer Algebra System with Automatic Differentiation for Use with Object-Oriented Modelling Languages

Authors

  • J. Andersson, B. Houska, M. Diehl

Reference

  • In Proceedings of the
    3rd International Workshop on Equation-Based Object-Oriented Modeling Languages and Tools,
    Oslo, Norway, pages 99 - 105, 2010.

Abstract

The Directed Acyclic Graph (DAG), which can be generated by object oriented modelling languages, is often the most natural way of representing and manipulating a dynamic optimization problem. With this representation, it is possible to step-by-step reformulate an (infinite dimensional) dynamic optimization problem into a (finite dimensional) non-linear program (NLP) by parametrizing the state and control trajectories. 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 matrix-valued 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.

Download

Bibtex

@INPROCEEDINGS{Andersson2010,
author = {J. Andersson and B. Houska and M. Diehl},
title = {Towards a Computer Algebra System with Automatic Differentiation for Use with Object-Oriented Modelling Languages},
booktitle = {In Proceedings of the 3rd International Workshop on Equation-Based Object-Oriented Modeling Languages and Tools, Oslo, Noway},
year = {2010},
pages = {99–105}
}