Summer School on Direct Methods for Optimal Control of Nonsmooth Systems

Lectures: Moritz Diehl and Armin Nurkanović

Guest Lecturer: Christian Kirches (TU Braunschweig)

Exercises: Jonathan Frey,  Florian Messerer, and Anton Pozharskiy

Contact. In case you have any questions feel free to contact:



This four-day intensive course aims to provide both theoretical background and hands-on practical knowledge in formulating and numerical methods to solve optimal control problems with nonsmooth differential equation models with switches and state jumps. Nonsmooth dynamical systems arise in robotics, chemical engineering, biology, mechatronics, or aerospace, as soon as some if-else statements, switches, and state jump are encoded in the systems’ dynamics. For example, contacts and friction in robotic systems lead to jumps and switches.

This course provides an introduction and overview of recent advances in numerical methods for solving optimal control problems with switched, nonsmooth and hybrid dynamical systems. We will provide a recap of direct methods for optimal control problems with smooth differential equations, which serve as a basis for tailored methods for the nonsmooth case. We discuss some non-obvious pitfalls and limitations that arise with the application of standard methods to nonsmooth optimal control problems. An overview and classification of the different types of nonsmooth and hybrid systems will be provided. The course will also cover the time-freezing reformulation, which enables exactly reformulating systems with state jumps into switched systems, simplifying their numerical and theoretical treatment. We provide a detailed exposition of tailored methods for the time discretization of nonsmooth systems, with a focus on the Finite Elements with Switch Detection (FESD) method. In contrast to standard methods, it enables the correct computation of numerical sensitivities and high simulation accuracy. After the time-discretization of optimal control problems with nonsmooth systems, one usually has to solve Mathematical Programs with Complementarity Constraints (MPCCs). The course will cover the theory and solution methods for MPCCs.  

Location and Schedule 

The course takes place from Tuesday, September 12, 2023, to Friday, September 15, 2023, from 9:00-17:30, in the main historical university building in the city center of Freiburg (Kollegiengebäude I, HS 1015, Platz der Universität 3, D-79098 Freiburg). 


The course is self-contained and can be followed by all quantitative scientists with basic mathematical background (calculus, optimization, and linear algebra). It is recommended for both industrial and academic practitioners of control and optimization as well as for master and PhD students of engineering, computer science, mathematics, and physics.


All exercises are offered in both MATLAB and Python. For our exercises, we will use CasADi and nosnoc (which is based on CasADi). nosnoc has both a MATLAB and a python version.

Solution templates:

Solution to exercises




  • nosnoc for MATLAB requires CasADi version 3.5.5 or later, and MATLAB version R2021b or later,
  • nosnoc for python requires CasADi version 3.5.5 or later, and Python version 3.8 or later.

Social events

We have the he following social events:

  • Our summer school begins on Monday, September 11th at 19:00 with our Welcome Reception at the Waldsee restaurant. You are welcome to join us and enjoy the finger food buffet with a variety of dishes.

  • The dinner will take place on Thursday, September 14th at 19:00 at the Restaurant Zum Roten Bären. This is one of the oldest restaurants in Germany, located in the old town of Freiburg.

  • There will be two 30-minute coffee breaks each day. This is the perfect opportunity to get to know the other participants and the organizers.

  • Our event will end on Friday, September 15th with a Farewell Reception at 15:30 in the historic main building of the University of Freiburg in the city center, where the coffee breaks and lectures will also take place.  

  • Social gathering at Platz der Alten Synagoge 


Please note that lunch is not included, but there are many options near the course location, as we are in the center of Freiburg's old town. You can also go to the Mensa Repartstrasse across from KG1. However, you will need a guest card to pay (cash payment is not possible), or even easier, you can pair up with some of the local participants and they can pay for you with their card. You can find the menu here.

Detailed content overview

Course topics and lecture slides 



  Monday, 11.9. Tuesday, 12.9. Wednesday, 13.9. Thursday, 14.9. Friday, 15.9.
9:00-9:30   Nonlinear
Programming Theory and Algorithms 
(M. Diehl)
Introduction to Nonsmooth Differential Equations
(A. Nurkanovic)
Theory of Mathematical Programs with Complementarity Constraints 
Relaxation and smoothing-based algorithms for MPCCs
(C. Kirches)
10:30-11:00 Coffee break Coffee break Coffee break Coffee break
11:00-11:30 Numerical Simulation and Direct Collocation
(A. Nurkanovic)

Modelling with Filippov Systems - Stewart and Step Formulation
(A. Nurkanovic)
Time-Freezing for Optimal Control
(M. Diehl)
Pivoting-based algorithms for MPCCs
(C. Kirches)
12:30-13:00 Lunch break Lunch break

Group photo

Lunch break

Lunch break
14:00-14:30 Modelling with Differential-Algebraic Equations (DAE)
(M. Diehl)
FESD for Filippov systems
(M. Diehl)
Time-Freezing 2 -
Rigid Bodies with Friction and Inelastic Impacts
(A. Nurkanovic)
Formulating nonsmooth optimal control problems and summary
(M. Diehl and A. Nurkanovic)
15:30-16:00 Coffee break Coffee break Coffee break Farewell reception
16:00-16:30 Exercise 1 - CasADi, Nonlinear Programming and Direct Collocation Exercise 2 - Optimal Control of Nonsmooth Systems with NOSNOC Exercise 3 - Optimal Control with Time-Freezing  
19:00-22:00 Welcome reception   Social gathering Workshop dinner  





This course has received funding from the European Union's Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement No. 953348 and from the Bundesministerium für Wirtschaft und Klimaschutz (BMWK.IIC6) via the project "EnEff:Wärme: WOpS - Wärmefluss-Optimierung zur Sektorenkopplung in Fernwärmenetzen mitttels MPC unter Berücksichtigung eines strommarktorientierten Betriebes, Teilvorhaben: Modellierung, Simulation und Betriebsführung", with the project number 03EN3054A.