nosnoc is an open-source MATLAB software package for NOnSmooth Numerical Optimal Control and Model Predictive Control of hybrid and nonsmooth dynamical systems.
- Theory and background: Winter School on Numerical Methods for Optimal Control of Nonsmooth Systems (with video lectures!) and Summer School on Direct Methods for Optimal Control of Nonsmooth Systems
- Documentation: nosnoc.readthedocs.io
For a quick start, we recommend browsing the examples.
For Python users we have nosnoc_py.
nosnoc is about:
- optimal control and MPC for hybrid and nonsmooth systems
- FESD discretization with accurate event handling and sensitivities
- time-freezing reformulations for systems with state jumps
- real-time MPC algorithms for hybrid systems, and fast MPC via CCOpt
- extensive MATLAB example library
nosnoc is a software framework for numerical optimal control and model predictive control (MPC) of hybrid and nonsmooth dynamical systems, including systems with switching, state jumps, impacts, hysteresis, and complementarity structure.
Its main capabilities include:
-
Real-time MPC algorithms for hybrid systems
- hybrid real-time iterations (HyRTI)
- hybrid advanced-step controller (HyASC)
- hybrid advanced-step real-time iteration (HyAS-RTI)
Fast MPC in nosnoc uses CCOpt, which is currently our fastest and most robust solver, especially suited for MPC applications. For getting started, see:
MPC examples. -
Automatic discretization via FESD (Finite Elements with Switch Detection)
- high accuracy and correct sensitivities
- superior treatment of switching events compared to classical time-stepping methods
-
Automatic reformulations of systems with state jumps
- for example, contact problems via time-freezing
- reformulation into Filippov / piecewise smooth / complementarity-based models
- accurate treatment of jumps and mode transitions
-
Homotopy-based and active-set solutions of mathematical programs with complementarity constraints
- multiple relaxation-based algorithms for MPCCs (
mpccsol,CCOpt) - active-set-based methods (
mpecopt) - compatibility with off-the-shelf NLP solvers such as IPOPT, and SNOPT
- multiple relaxation-based algorithms for MPCCs (
With nosnoc, users can formulate and solve problems involving:
- switched systems
- rigid body models with impacts and friction (also with time-freezing)
- piecewise affine and piecewise smooth systems
- Filippov systems
- systems with logical Heaviside step functions
- relay systems
- projected dynamical systems
- first-order sweeping processes
- hybrid systems with hysteresis
See our example library for a range of optimal control and MPC examples.
Users may either provide a dynamic complementarity system (DCS) directly, or formulate the problem in a standard form that is automatically reformulated into a DCS. nosnoc then discretizes the resulting model with FESD and solves the resulting MPCC/NLP.
nosnoc requires:
CasADiversion>= 3.5.5MATLABversion>= R2021b, <= R2026a
-
Install
CasADiand make sure it is on yourMATLABpath. -
Clone this repository:
git clone --recursive https://github.com/nosnoc/nosnoc.git- Open the
nosnocfolder in MATLAB and run:
install_nosnocFor Python support, see the nosnoc_py repository.
CasADifor symbolic modeling and derivative generationIPOPTis shipped withCasADi. More information is available on the IPOPT homepage.
For high-performance MPC and fastest simulation performance, nosnoc supports CCOpt:
CCOpt is used by the fast MPC functionality in nosnoc and is currently our fastest and most robust option.
We are currently in the process of upstreaming CCOpt support into the next release of CasADi, however this is not yet complete.
As such please use the ap/ccopt branch of CasADi found in this fork.
This requires building CasADi from source with the CMake flags -DWITH_CCOPT=ON -DWITH_BUILD_CCOPT=ON, as well as running MATLAB with some additional environment variables.
For details please visit the README for libMad, the ahead-of-time compiled library containing both MadNLP and CCOpt.
The interface of nosnoc is based on the symbolic modeling framework CasADi.
User inputs should therefore be provided as CasADi expressions.
To get started, browse the example library.
If you use nosnoc in research, please cite the software paper:
@article{Nurkanovic2022,
title={nosnoc: A software package for numerical optimal control of nonsmooth systems},
author={Nurkanovi{\'c}, Armin and Diehl, Moritz},
journal={IEEE Control Systems Letters},
volume={6},
pages={3110--3115},
year={2022},
publisher={IEEE}
}Depending on which features of nosnoc you use, please also cite the corresponding algorithmic or software papers.
-
π Real-Time Algorithms for Model Predictive Control of Hybrid Dynamical Systems
BibTeX
@article{Nurkanovic2026a, title = {Real-Time Algorithms for Model Predictive Control of Hybrid Dynamical Systems}, author = {Nurkanovi{\'c}, Armin and Pozharskiy, Anton and Diehl, Moritz}, journal = {arXiv preprint arXiv:2604.18432}, year = {2026} }
-
π CCOpt: an Open-Source Solver for Large-Scale Mathematical Programs with Complementarity Constraints π» CCOpt.jl
BibTeX
@article{Pozharskiy2026, title = {CCOpt: an Open-Source Solver for Large-Scale Mathematical Programs with Complementarity Constraints}, author = {Pozharskiy, Anton and Pacaud, Fran{\c{c}}ois and Diehl, Moritz and Nurkanovi{\'c}, Armin}, journal = {arXiv preprint arXiv:2604.18726}, year = {2026} }
-
π CasADi: a software framework for nonlinear optimization and optimal control π» CasADi
BibTeX
@article{Andersson2019, doi = {10.1007/s12532-018-0139-4}, volume = {11}, pages = {1--36}, number = {1}, year = {2019}, journal = {Mathematical Programming Computation}, author = {J. A. E. Andersson and J. Gillis and G. Horn and J. B. Rawlings and M. Diehl}, title = {{CasADi} -- A software framework for nonlinear optimization and optimal control} }
-
π Ipopt: On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming π» Ipopt
BibTeX
@article{Wachter2006, title={On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming}, author={W{\"a}chter, Andreas and Biegler, Lorenz T}, journal={Mathematical programming}, volume={106}, number={1}, pages={25--57}, year={2006}, publisher={Springer} }
-
π Finite Elements with Switch Detection for Direct Optimal Control of Nonsmooth Systems
BibTeX
@article{Nurkanovic2024, title = {Finite elements with switch detection for direct optimal control of nonsmooth systems}, author = {Nurkanovi{\'c}, Armin and Sperl, Mario and Albrecht, Sebastian and Diehl, Moritz}, journal = {Numerische Mathematik}, pages = {1--48}, year = {2024}, publisher = {Springer} }
-
BibTeX
@article{Nurkanovic2024a, title = {Finite Elements with Switch Detection for numerical optimal control of nonsmooth dynamical systems with set-valued heaviside step functions}, author = {Nurkanovi{\'c}, Armin and Pozharskiy, Anton and Frey, Jonathan and Diehl, Moritz}, journal = {Nonlinear Analysis: Hybrid Systems}, volume = {54}, pages = {101518}, year = {2024}, publisher = {Elsevier} }
-
π Solving Mathematical Programs with Complementarity Constraints Arising in Nonsmooth Optimal Control
BibTeX
@article{Nurkanovic2024b, pages = {1--39}, year = {2024}, journal = {Vietnam Journal of Mathematics}, author = {Nurkanovi{\'c}, Armin and Pozharskiy, Anton and Diehl, Moritz}, title = {Solving mathematical programs with complementarity constraints arising in nonsmooth optimal control}, }
-
π A Globally Convergent Method for Computing B-stationary Points of Mathematical Programs with Equilibrium Constraints (paper on mpecopt, which is used in nosnoc) π» mpecopt
BibTeX
@article{Nurkanovic2025, title={A globally convergent method for computing B-stationary points of mathematical programs with equilibrium constraints}, author={Nurkanovi{\'c}, Armin and Leyffer, Sven}, journal={arXiv preprint arXiv:2501.13835}, year={2025} }
-
BibTeX
@article{Pozharskiy2025, year = {2025}, journal = {Proceedings of the European Control Conference (ECC)}, author = {Pozharskiy, Anton and Nurkanovi{\'c}, Armin and Diehl, Moritz}, title = {First-Order Sweeping Processes and Extended Projected Dynamical Systems: Equivalence, Time-Discretization and Numerical Optimal Control}, }
-
π Finite Elements with Switch Detection for Numerical Optimal Control of Projected Dynamical Systems
BibTeX
@article{Pozharskiy2024c, year = {2024}, journal = {Proceedings of the IEEE Conference on Decision and Control (CDC)}, author = {Pozharskiy, Anton and Nurkanovi{\'c}, Armin and Diehl, Moritz}, title = {Finite Elements with Switch Detection for Numerical Optimal Control of Projected Dynamical Systems}, }
-
BibTeX
@article{Nurkanovic2021, title = {A Time-Freezing Approach for Numerical Optimal Control of Nonsmooth Differential Equations with State Jumps}, author = {Nurkanovi{\'c}, Armin and Sartor, Thomas and Albrecht, Sebastian and Diehl, Moritz}, journal = {IEEE Control Systems Letters}, year = {2021} }
-
BibTeX
@article{Nurkanovic2023, title = {The Time-Freezing Reformulation for Numerical Optimal Control of Complementarity Lagrangian Systems with State Jumps}, author = {Nurkanovi{\'c}, Armin and Albrecht, Sebastian and Brogliato, Bernard and Diehl, Moritz}, journal = {Automatica}, volume = {158}, pages = {111295}, year = {2023} }
-
π Continuous Optimization for Control of Hybrid Systems with Hysteresis via Time-Freezing
BibTeX
@article{Nurkanovic2022a, title={Continuous optimization for control of hybrid systems with hysteresis via time-freezing}, author={Nurkanovi{\'c}, Armin and Diehl, Moritz}, journal={IEEE Control Systems Letters}, volume={6}, pages={3182--3187}, year={2022}, publisher={IEEE} }
Questions, remarks, bug reports, and feature requests are best submitted via a new issue in this repository.
Main developers:
- Anton Pozharskiy β anton.pozharskiy@imtek.uni-freiburg.de
- Armin NurkanoviΔ β armin.nurkanovic@imtek.uni-freiburg.de
- Jonathan Frey β jonathan.frey@imtek.uni-freiburg.de
Success stories and source code contributions are very welcome.