NonLinear Programming with CasADi#

CasADi-NLP (csnlp, for short) is a library that provides classes and utilities to model, solve and analyse nonlinear (but not only) programmes (NLPs) for optimization purposes.

PyPI version MIT License Python 3.9

Tests Docs Downloads Maintainability Test Coverage Ruff

Features#

csnlp builds on top of the CasADi framework [1] to model the optimization problems and perform symbolic differentiation, and heavily relies on the IPOPT solver [8] (though the package allows the user to seamlessly switch to other solvers supported by CasADi). While it is similar in functionality (and was inspired by) the casadi.Opti stack (see this blog post for example), it is more tailored to research as

  1. it is more flexible, since it is written in Python and allows the user to easily access all the constituents of the optimization problem (e.g. the objective function, constraints, dual variables, bounds, etc.)

  2. it is more modular, since it allows the base csnlp.Nlp class to be wrapped with additional functionality (e.g. sensitivity, Model Predictive Control, etc.), and it provides parallel implementations in case of multistarting in the csnlp.multistart module.

The package offers also tools for the sensitivity analysis of NLPs, solving them with multiple initial conditions, as well as for building MPC controllers. The library is not meant to be a faster alternative to casadi.Opti, but rather a more flexible and modular one for research purposes.

Installation#

Using pip#

You can use pip to install csnlp with the command

pip install csnlp

csnlp has the following dependencies

Using source code#

If you’d like to play around with the source code instead, run

git clone https://github.com/FilippoAiraldi/casadi-nlp.git

The main branch contains the main releases of the packages (and the occasional post release). The experimental branch is reserved for the implementation and test of new features and hosts the release candidates. You can then install the package to edit it as you wish as

pip install -e /path/to/casadi-nlp

Author#

Filippo Airaldi, PhD Candidate [f.airaldi@tudelft.nl | filippoairaldi@gmail.com] at Delft Center for Systems and Control in Delft University of Technology.

Copyright (c) 2024 Filippo Airaldi.

Copyright notice: Technische Universiteit Delft hereby disclaims all copyright interest in the program “csnlp” (Nonlinear Progamming with CasADi) written by the Author(s). Prof. Dr. Ir. Fred van Keulen, Dean of ME.

Indices and tables#

References#

[1]

Joel A E Andersson, Joris Gillis, Greg Horn, James B Rawlings, and Moritz Diehl. CasADi: a software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019.

[2]

Alberto Bemporad and Manfred Morari. Control of systems integrating logic, dynamics, and constraints. Automatica, 35(3):407–427, 1999.

[3]

Francesco Borrelli, Alberto Bemporad, and Manfred Morari. Predictive control for linear and hybrid systems. Cambridge University Press, 2017.

[4]

Christof Büskens and Helmut Maurer. Sensitivity analysis and real-time optimization of parametric nonlinear programming problems. In Martin Grötschel, Sven O. Krumke, and Jörg Rambau, editors, Online Optimization of Large Scale Systems, pages 3–16. Springer, Berlin, Heidelberg, 2001.

[5]

Marco C. Campi, Simone Garatti, and Maria Prandini. Scenario Optimization for MPC, pages 445–463. Springer International Publishing, Cham, 2019.

[6]

James Blake Rawlings, David Q Mayne, and Moritz Diehl. Model Predictive Control: Theory, Computation, and Design. Nob Hill Publishing, Madison, USA, 2 edition, 2018.

[7]

Georg Schildbach, Lorenzo Fagiano, Christoph Frei, and Manfred Morari. The scenario approach for stochastic model predictive control with bounds on closed-loop constraint violations. Automatica, 50(12):3009–3018, 2014.

[8]

Andreas Wächter and Lorenz T. Biegler. On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming. Mathematical Programming, 106(1):25–57, Mar 2006.