Skip to content

Repository files navigation

Model Predictive Control using CasADi

Persian-Language Workshop on Model Predictive Control with MATLAB and CasADi

Developed and delivered through the Process Control Laboratory, K. N. Toosi University of Technology.

Lecturers: Hamzeh Kashi Yarandi & MohammadReza Ghobadzadeh
Language: Persian
Primary tools: MATLAB, CasADi, IPOPT

About the Workshop

This workshop connects the mathematical foundations of optimal control and nonlinear programming with the practical implementation of receding-horizon control using MATLAB and CasADi.

The workshop begins with an overview of Model Predictive Control (MPC) and its application landscape, develops the CasADi concepts required for numerical implementation, and concludes with a hands-on nonlinear MPC implementation for point stabilization of a mobile robot.

To avoid unnecessary duplication, foundational material that overlaps with the Numerical Optimal Control Workshop is linked as a shared prerequisite rather than copied into this repository.

Recorded Lectures

Session Topic Video
01 Workshop Overview & MPC Landscape Watch on YouTube
02 CasADi Foundations & Algorithmic Differentiation Watch on YouTube
Shared Prerequisites from the Numerical Optimal Control Workshop See prerequisite path
03 MPC Formulation & Hands-on Nonlinear MPC Implementation Watch on YouTube

Full MPC playlist: Model Predictive Control using CasADi

Recommended Learning Path

  1. Session 1 — Workshop Overview & MPC Landscape
  2. Session 2 — CasADi Foundations & Algorithmic Differentiation
  3. Complete the Shared Prerequisites from the Numerical Optimal Control Workshop:
    • CasADi symbolics, function objects, root finding, and ODE/DAE tools
    • Numerical optimization and nonlinear programming
    • Direct Single Shooting
    • Direct Multiple Shooting
  4. Session 3 — MPC Formulation & Hands-on Implementation

Core Topics

  • Model Predictive Control and receding-horizon optimization
  • Optimal Control Problem (OCP) and Nonlinear Programming (NLP) viewpoints
  • CasADi and efficient symbolic computation
  • Computational graphs and Algorithmic Differentiation
  • Numerical optimization and direct shooting methods as MPC prerequisites
  • Point stabilization and trajectory-tracking concepts
  • State and input constraints
  • Single Shooting MPC
  • Multiple Shooting MPC
  • Prediction horizon and sampling time
  • Quadratic state and control penalties
  • Closed-loop MPC simulation
  • Horizon shifting and warm-start initialization
  • Selected advanced directions including distributed, tube, and learning-based MPC

Repository Structure

Model-Predictive-Control-using-CasADi/
├── README.md
├── ACKNOWLEDGEMENTS.md
├── .gitignore
├── Session-01-Overview-and-MPC-Landscape/
│   └── README.md
├── Session-02-CasADi-and-Algorithmic-Differentiation/
│   └── README.md
├── Shared-Prerequisites/
│   └── README.md
└── Session-03-Nonlinear-MPC-Implementation/
    ├── README.md
    ├── MPC_sing_shooting.m
    ├── MPC_mul_shooting.m
    ├── shift.m
    └── Draw_MPC_point_stabilization_v1.m

Software Requirements

  • MATLAB
  • CasADi for MATLAB
  • IPOPT through CasADi

Make sure CasADi is installed and available on your MATLAB path before running the examples. For example:

addpath('C:\path\to\casadi')
import casadi.*

The repository intentionally does not contain machine-specific CasADi paths.

Hands-on MPC Codes

The main implementation codes are provided in Session 03:

  • MPC_sing_shooting.m — nonlinear MPC using a Single Shooting formulation
  • MPC_mul_shooting.m — nonlinear MPC using a Multiple Shooting formulation
  • shift.m — applies the first control move and shifts the control sequence for the next MPC iteration
  • Draw_MPC_point_stabilization_v1.m — visualization of the closed-loop trajectory, predictions, and control inputs

Related Workshop

The shared numerical optimal-control foundations used by this workshop are available in:

Numerical Optimal Control Workshop
https://github.com/Hamzehkashi/Numerical-Optimal-Control-Workshop

See Shared Prerequisites for the recommended session-by-session path.

Acknowledgements and Educational References

This workshop was developed with reference to established educational resources in numerical optimal control, MPC, and CasADi. See ACKNOWLEDGEMENTS.md for details.

License and Reuse

No repository-wide open-source license is currently applied. Some workshop material draws on or adapts concepts and examples from third-party educational resources. Users should consult ACKNOWLEDGEMENTS.md and the original sources before redistributing or reusing third-party-derived material.

About

Persian-language Model Predictive Control (MPC) workshop with hands-on MATLAB/CasADi implementations, developed at the Process Control Laboratory, K. N. Toosi University of Technology.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages