CasADi master class

March 18-20, 2024 – Leuven, Belgium

(download this description as flyer)

Target audience

Academic/industrial CasADi users that want to get a deeper understanding of CasADi, in order to speed up existing applications or create advanced implementations. Unlike the fall course, there is no focus on mathematics.


Originating from KU Leuven’s “Optimization in Engineering Center” under guidance of prof. Moritz Diehl, CasADi [1] is an open-source software framework for nonlinear optimization and algorithmic differentiation. It facilitates rapid - yet efficient - implementation of different methods for numerical optimal control, both in an offline context and for nonlinear model predictive control.


Seminars paired with computer exercises. The seminars provide a view on advanced CasADi techniques. The computer exercises aim to internalize these techniques, and leave the participants well-equipped to apply them on their own applications.

Covered topics

SX and MX expression graphs - benchmarking and debugging - thread-safety and parallelisation - code generation API and C API - memory/speed trade-offs and algorithmic differentiation

(click for more details)

Module 1: CasADi expression graphs and Functions: recap and internals
  • Get a clear mental image on basic CasADi concepts
  • Get acquainted with a consistent vocabulary to talk about CasADi concepts
Module 2: Debugging CasADi expression graphs and Functions
  • Learn how to introspect the numerical evaluation of symbolic expression graphs
Module 3: CasADi for-loop equivalents: map and mapaccum
  • Learn how expression graph sizes can be reduced with map and mapaccum
  • Learn how to apply a CasADi Function on a range of inputs (broadcasting)
  • Learn the different flavours of the map command
Module 4: Saving and loading CasADi objects
  • Learn how to load/save CasADi Functions
  • Learn how to load/save expression graphs
  • Learn how to load/save objects of your class with CasADi members
Module 5: Internals of CasADi expressions graphs and Functions
  • Get an intimate understanding of MX versus SX
  • Learn how the CasADi virtual machine works
  • Get a basic understanding of CasADi source code structure
Module 6: Benchmarking: how to identify computational bottlenecks in your CasADi code
  • Understand how non careful benchmarking can easily lead to wrong conclusions
  • Learn how to hunt for computational bottlenecks in CasADi expression graphs
Module 7: Representation of sparse matrices in CasADi
  • Understand how compressed column storage works
  • Understand how CasADi encodes sparsity
Module 8: Using code generated by CasADi in third-party applications
  • Understand the API of CasADi generated code
  • Practice the usage of generated code with concrete compilation
  • Learn to use generated code with dependencies
Module 9: Calling the CasADi virtual machine from C
  • Understand the difference between code generation and C API
  • Learn how to use the C API from a concrete example
Module 10: Parallelization of CasADi computations
  • Learn how to call CasADi Functions in parallel
  • Learn how to parallelize parts of a CasADi expression graph
Module 11: Algorithmic differentiation of algorithms
  • Derive reverse mode from scratch using only high-school level insight
  • Get acquainted with forward and reverse mode sensitivity functions
  • Understand how forward and reverse mode sensitivity functions can be used to construct Jacobians
  • Understand the impact of CasADi concepts on the cost of a Jacobian
  • Get an idea of heuristics in CasADi governing the choice between forward and reverse mode
Module 12: Using CasADi callbacks for embedding custom code
  • Learn how to deal with code that is not compatible with CasADi
  • Learn how to use finite differences for custom code
  • Learn how to specify exact derivatives for custom code
Module 13: Linking CasADi to compiled C code
  • Learn how to introduce compiled C code into a CasADi graph
  • Understand how CasADi reads meta-data from shared libraries
  • Understand how meta-data can impact performance
  • Learn to use 'jit' option for simple speed-ups
Module 14: A synthesis exercise of advanced CasADi concepts
  • Understand how derivatives of maps are computed
  • Understand how the use of a hierarchy of Functions impacts the runtime of derivatives
The contents of the physical course will be close to the contents of the self-paced hands-on course, with updates from casadi 3.6. What sets the physical course apart is really the networking opportunity, ability to ask live questions, the focus and the peer pressure that provides a stimulus to perform the exercises instead of procrastinating. In practice, I see a large difference in capabilities of students coming out of these courses, in spite of the proximity in contents.


Basic programming skills are assumed. Exercises will build upon boilerplate codes in Python/Matlab, C and C++. Familiarity with CasADi is assumed.


Joris Gillis obtained his PhD in electrical engineering at KU Leuven in 2015. Currently active at MECO, KU Leuven and part-time freelancer, he pursues large-scale applications in optimal control and is highly active as a main developer of CasADi since 2010.


The course will take place at the Park Inn hotel, Martelarenlaan 36, 3010 Leuven, Belgium, starting each day at 9:00 and ending at 18:00. Participants are required to bring their own laptops (Linux/Windows/Mac). A working installation of either Matlab or Python is needed, as well as a C compiler (gcc/clang/msvc).


The registration fee amounts to 1050 EUR excl. VAT (850 EUR for PhD students). Early bird discount (75 EUR) applies until January 28. The registration fee covers for daily mini-breakfasts, refreshments during the breaks, and lunch. A joint dinner is included on Tuesday evening. Lodging is not included.

The number of participants is capped to 20. Registration closes February 25.

Register now

Subscribe to the newsletter if you wish to be kept up to date of further courses. You may also pre-register to a future course to get priority in registration, or follow a pre-recorded course.

Organizer: Joris Gillis,, +32496432937, Yacoda BV, Glabbeeksestraat 37, 3300 Vissenaken, Belgium. BE0642979742

[1] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, M. Diehl, “CasADi – A software framework for nonlinear optimization and optimal control,” Mathematical Programming Computation, 2018.

📣Next hands-on CasADi class: November 18-20