Numerical Optimization

Prof. Dr. Moritz Diehl -

The course’s aim is to give an introduction into numerical methods for the solution of optimization problems in science and engineering. It is intended for students from two faculties, mathematics and physics on the one hand, and engineering and computer science on the other hand. This semester, Numerical Optimization is offered as an semi-online course. The focus is on continuous nonlinear optimization in finite dimensions, covering both convex and nonconvex problems.

Organization of the course

The course is organized as flipped classroom. We provide recordings of the lecture and will meet once a week to discuss the course contents. This course has 6 ECTS credits. It is possible to do a project to get an additional 3 ECTS, i.e., a total of 9 ECTS for course+project. For more information please contact Florian Messerer.

Virtual meetings: We will meet every Friday, 2.15pm to 4.00pm, in a virtual lecture room. These meetings are alternatingly dedicated to either Q&A sessions with Prof. Diehl or exercise sessions with the teaching assistant (see below). We will use Zoom for the meetings. Please note that you can join the meeting via your browser and do not need to install to the Zoom client. You can join via this link (Meeting ID: 858 1034 4638). The password is nUQtQw09? . Except for the kick-off session, none of the meetings will be recorded (edit: we decided to also not record the kick-off session, but you can find all relevant information on this page). For more information on how the university uses Zoom, a guide for students, and a note on data protection please see here.

Ilias: There is also an Ilias course, though most material will be published on the page you are currently viewing. In Ilias, we provide a forum for discussion of any questions you have related to the course, be it organization, content or exercises. Please feel free to open new topics and to answer questions of your fellow students. Further, the mid term quiz will be published on Ilias (see below). You can join the Ilias course via this link.

Lecture recordings: The lecture recordings were already created in a past semester. There are 24 lectures of approximately 90 minutes each. You can find the recordings below in the materials section, and a recommended schedule in the calendar.

Course manuscript: The lectures are accompanied by a detailed course manuscript, which you may find in the materials section below.

Exercises: The exercises are mainly computer based. Computers with MATLAB and CasADi installed are required to solve them (see below for details). The exercises are voluntary (though of course we strongly recommend to solve them). Nonetheless we offer the possibility to hand them in to receive feedback, but for this please respect the deadlines you can find in the calendar below. If you would like feedback on a specific part of the exercise especially, you can state so on your solution sheet. To hand them in, send them in an email to

Q&A sessions: Every second week there will be a virtual Q&A session with Prof. Diehl, where you can ask any questions about the course content. The format is meant to be highly interactive and depends strongly on your participation. We would recommend that while watching the video lectures or reading the course script, you write down any questions that come to your mind, such that you have them readily available for the Q&A sessions.

Exercise sessions: Every other week we will meet for the exercise sessions. They will not be used to show the solutions, but to discuss any questions related to the exercises. These can either be questions about the current exercise sheet or questions about the solution to the last sheet. As the Q&A sessions, this format depends heavily on your participance.

Mid term quiz: Some time before christmas, we will publish a quiz on Ilias, with questions covering the course contents so far. It is obligatory that you pass this quiz until Dec 18, 11.59pm, but you have infinitely many trials for doing so and will receive instant feedback by auto-grading. The quiz will be online at least one week before the deadline. Note that the questions will not necessarily be representative of an exam.

Final evaluation: The final exam is a written exam. Only pen, paper, a calculator and two A4 sheets (i.e., 4 pages) of self-chosen content are allowed (handwritten). For students from the faculty of engineering and the B.Sc. Math, this exam is graded. Students from the M.Sc. Math need to pass the written exam in order to take the graded 11ECTS oral exam.

 *** exam date: 22.3.2021, 10am-12pm *1pm-3pm*. Rooms: Georges-Köhler-Allee 101, SR 00-010/14, SR 01-009/13  (Faculty of Engineering)***

Projects: (more detail in a section below) The optional project (3 ECTS) consists in the formulation and implementation of a self-chosen optimization problem or numerical solution method, resulting in documented computer code, a project report, and a public presentation. Project work starts in the last third of the semester. For students from the faculty of engineering the project is graded independently from the 6ECTS lecture. For students from the B.Sc. Math, the grade for the lecture&project 9ECTS module is solely determined by the written exam. For students from the M.Sc. Math the project is again a prerequisite to the graded 11ECTS oral exam.


 Date  Format  Content  watch this week  deadlines
 Nov 06  Intro


 lec. 1, 2  
 Nov 13  Ex


 lec. 3, 4  
 Nov 20  Q&A

 up to chap 6.6

 lec. 5, 6  ex1 (voluntary)
 Nov 27  Ex

 ex2.pdf, ex1_sol,

 lec. 7, 8  
 Dec 04  Q&A

 up to chap 9.3

 lec. 9, 10  ex2 (voluntary)
 Dec 11  Ex


 lec. 11, 12  
 Dec 18  Q&A

 up to chap 11.2

 lec. 13, 14

 ex3 (voluntary) / mid term quiz in illias (obligatory, until 11:59 pm)

 ***  ***

 *** Christmas ***

 ***  ***
 Jan 08  Ex


 lec. 15, 16  
 Jan 15  Q&A

 up to chap 13.2

 lec. 17, 18  ex4 (voluntary)
 Jan 22  Ex

 ex5.pdf, ex4_sol,

 lec. 19, 20  
 Jan 29  Q&A

 up to chap 15.5

 lec. 21, 22  ex5 (voluntary)
 Feb 05  Ex

 ex5_sol, ex5_sol.pdf

 lec. 23, 24  
 Feb 12  Q&A

 all course content!



     1  Part1 / Part2   full* Introduction to Section 1.3 (Mathematical formulation)
     2  Part1 / Part2  full* Section 1.4 (Definitions) to 2.7 (Mixed-Integer-Programming)
     3  Part1 / Part2  full* Section 3.1 (How to check convexity) to 3.5 (Standard form of convex opt. problems)
     4  Part1 / Part2  full* Section 3.6 (Semidefinite Programming) to Example 4.2 (Dual of LP)
     5  Part1 / Part2  full* Example 4.3 (Dual decomposition) to Chapter 6 introduction
     6  Part1 / Part2  full* Section 6.1 (Linear Least Squares) to 6.5 (L1-Estimation)
     7  Part1 / Part2  full* Section 6.6 (Gauss-Newton method) to 7.2 (Local convergence rates)
     8  Part1 / Part2  full* Section 7.3 (Newton-Type methods) to 8.1 (Local contraction)
     9  Part1 / Part2  full* Section 8.2 (Affine invariance) to 9.1 (Line search)
   10  Part1 / Part2  full* Section 9.2 (Wolfe conditions) to 9.3 (Global convergence of line search)
   11  Part1 / Part2  full* Section 9.4 (Trust-Region methods) to 9.5 (The Cauchi-Point)
   12  Part1 / Part2  full* Section 10.1 (Algorithmic Differentiation) to 10.3 (Backward AD)
   13  Part1 / Part2  full* Section 10.4 to Chapter 11 introduction
   14  Part1 / Part2  full* Section 11.1 (LICQ and linearized feasible cone) to 11.2 (SONC)
   15  Part1 / Part2  full* Section 12.1 (Optimality conditions) to 12.5 (Constrained Gauss-Newton)
   16  Part1 / Part2  full* Section 11.3 (Perturbation analysis) and 12.7 (Local convergence)
   17  Part1 / Part2  full* Section 12.6 (General constrained NT-Algorithm) to 12.9 (Careful BFGS updating)
   18  Part1 / Part2  full* Section 13.1 to 13.2 (Active constraints and LICQ)
   19  Part1 /    -  full* Section 13.3 (Convex Problems)
   20  Part1 / Part2  full* Section 13.4 (Complementarity) to 14.1 (QPs via Active Set Method)
   21  Part1 / Part2  full* Section 14.2 (SQP) to 14.4 (Interior Point methods)
   22  Part1 / Part2  full* Section 14.4 (Barrier problem interpretation, SCP) to 15.5 (Simultaneous optimal control)
   23  Part1 / Part2  full* Problem reformulations and useful function approximations
   24  Part1 / Part2  full* Summary of the course

* Experimental: Both lecture parts merged and file size compressed. Please let us know if you experience any problems.


For a more detailed description of the projects and their requirements, please see these guidelines.

There is a time slot separate from the normal sessions for discussing the projects. Starting on Jan 21st, we will meet each Thursday, 10am-12pm. At that point, you need to have sent your project idea via email (see guidelines), and registered for the SL/PL as required by your examination office (deadline depending on your examination office). The first session will be used to finalize your project ideas, and the following sessions to discuss your progress and the problems you face. The final presentations will be on March 08, and the deadline for the written project is March 18, 23:59.

 Date  Time  Content
 Jan 21  10 - 12  deadline project ideas, first project session
 Jan 28  10 - 12  project session
 Feb 04  10 - 12  project session
 Feb 11  10 - 12  project session
 Feb 25  10 - 12  project session
 Mar 08  9:30 - 12:00  project presentations (schedule below)
 Mar 18  23:59  project report deadline


Project presentation schedule (March 08)

Time per talk: max 8 min (strict!) +2 min questions

 Time  Content
 09:30 - 09:35  Welcome
 09:35 - 09:45  Presentation 1
 09:45 - 09:55  Presentation 2
 09:55 - 10:05  Presentation 3
 10:05 - 10:15  Presentation 4
 10:15 - 10:25  Presentation 5
 10:25 - 11:00  Break
 11:00 - 11:10  Presentation 6
 11:10 - 11:20  Presentation 7
 11:20 - 11:30  Presentation 8
 11:30 - 11:40  Presentation 9
 11:40 - 11:45  Concluding remarks


Matlab and CasADi installation

MATLAB is an environment for numerical computing based on a proprietary language that allows one to easily manipulate matrices and visualize data which will be very helpful in prototyping the algorithms presented during the lectures of this course. The University of Freiburg offers a free-of-cost license to students and staff which can be obtained following the instructions here. In order to be able to complete the exercises of this course, you will need a working installation of MATLAB. Follow the instructions at the provided link in order to install the software package.
CasADi is a symbolic framework for algorithmic differentiation and numerical optimization. In order to install CasADi, follow the instructions here. Download the binaries for your platform and, after having extracted them, add their location to MATLAB's path. To test your installation run the simple example described at the provided link. If successful, save the path by executing the command savepath. In this way, the location of the binaries will be known even after restarting MATLAB.


Supplementary Links and Material for the Q&A Sessions

Mainly meant as reference for those who attended the respective session. Do not worry if you were not there and find the following content confusing.

  • Q&A 1 (6.11.20)
    • Optimal Throw Angle Team Question for Zoom Breakout Sessions: You are standing on top of a 10m high building and want to throw a tennis ball as far as possible, i.e., maximize the distance from the foot of the building to the touch-down point of the ball on the (horizontal) ground. The throwing velocity you can achieve is maximally 20m/s at the moment when the ball leaves your hand. At which angle should you throw the ball, i.e., what angle (in degrees) does the initial direction make with the horizontal? Please fill in your answer after a discussion of 5-10 minutes into the following google sheet together with optional supplementary information. This sheet will be shared among all course participants but taken off from the web after the session (link is removed).
      • picture of black board with the problem formulated as Nonlinear Program (NLP)
      • matlab code solving the NLP with CasADi -> Optimal angle is 39.32 degree.
      • Note: Using numerical methods here might be seen as overkill, as this problem can probably also be easily solved analytically (as some of you did during the Q&A). But in general acquiring solutions analytically is intractable.
  • Q&A 2 (20.11.20)
    • Blackboard pictures:
      • mainly meant as reference for those who attended (don't worry if you were not there and find them confusing)
      • picture 1
      • picture 2
    • Team Question: constraint linearization
  • Q&A  3 (4.12.20)