This libray intends to provide tools and implementations for control-oriented neural state-space models.
Its main features include several models based on Linear Matrix Inequalities (LMI) constraints.
Documentation :
- PyTorch v1.9 >=
- MOSEK solver can be installed using
pip install mosek A personal license file can be asked freely for academics
- cvxpy v1.4
- Lyapunov alpha stability for continuous and discrete time LTI models
-
$\mathcal{H}^\infty$ norm for continuous and discrete time LTI models see Real Bounded Lemma -
$\mathcal{H}^2$ norm for both continuous and discrete time LTI models see System H2 norm - Lipschitz constant estimation for feedfoward neural networks (with no skip connections) see Pauli et al. 2021
From these LMIs one can obtain models with certified properties such as stability, contraction or dissipativity, and incremental boundedness
- Recurrent Equilibrium Networks (REN) implemented in dsicrete-time only for now see Revay et al. 2023
- An incrementally bounded (and stable but not globally contractive) of GrNSSM based on real bounded lemma for Taylor Linearizations
- Parameterized Explicit and semi-Implicit linear state-space models using aforementioned LMIs
Finally, the parametrizations involving Positive (Semi-) Definite (PSD) matrices are built using the geotorch library. Since the right inverse methods now involve solving a LMI, cvxpy is now needed, an extended version is then included in this library.
Beyond identifying single models, the library lets you wire models and controllers into differentiable closed loops — the foundation for Internal Model Control (IMC), reinforcement learning and MPC-style training.
The key idea: every component is a Block with named input/output ports, and a
closed-loop interconnection is itself a state-space model, so it plugs straight into
the existing RK4Simulator and LitNode trainer with no changes.
ctrlnmod.blocks—Blockbase class (generalisingSSModel) plus primitives (Sum,Gain,Constant,Saturation).ctrlnmod.controllers—Controllerbase class; the feedback-linearizing controllers (ILOFController,ILSFController, ...) and a genericNeuralController.ctrlnmod.diagram— theDiagramengine (state aggregation, topological evaluation and algebraic-loop detection viaWiringGraph), ready-madeSeries,Parallel,FeedbackInterconnection, and anIMCblock.
from ctrlnmod.diagram import IMC
from ctrlnmod.integrators import RK4Simulator
imc = IMC(plant, model) # plant + internal model + neural controller
imc.trainable_blocks("controller") # freeze the plant, learn the controller
sim = RK4Simulator(imc, ts=2e-2) # a diagram IS an SSModel
_, y = sim(reference, x0) # differentiable closed-loop rolloutA full runnable example is in examples/imc_differentiable_loop.py.
In order to train networks on data coming from several experiments and trajectories the class ExperimentsDataset encapsulates different experiments and is readily compatible with DataLoader.
A minimalist working example for the simple pendulum can be found in example_pendulum.py
This library is the summary of my PhD's work and is still currently under development.
- Manage compatibility with torchdiffeq integrators
- Implement stability-based initializations strategies
- And enabling hessian logging with PyHessian
Feel free to contribute and you can contact me at alexandre DOT hache AT outlook DOT fr