This repository contains the implementation developed for the "Learning for Control" course project.
The goal of this project is to learn an approximate control-invariant set (viability kernel) of a dynamical system and use it as a terminal constraint inside a Model Predictive Control (MPC) framework to ensure recursive feasibility and improve closed-loop safety.
The main idea is to approximate the N-step backward reachable set of a target safe set S, and use a learned representation of this set to enforce terminal constraints in MPC problems.
Instead of computing the set analytically (intractable for nonlinear systems), we learn a neural network classifier that predicts whether a state belongs to the viability kernel.
For each sampled initial state x₀, we solve an optimal control problem with horizon N:
- system dynamics constraints
- input and state constraints
- terminal constraint x_N ∈ S
Each sample is labeled:
- 1 → feasible (x₀ can reach S in N steps)
- 0 → infeasible
This produces a dataset of state-label pairs (x, label).
A neural network classifier is trained to approximate the feasibility function:
- Input: system state x
- Output: probability of being feasible
The model learns the boundary of the N-step backward reachable set.
Implementation:
- PyTorch / TensorFlow MLP
- nonlinear activation functions
- supervised classification
The trained network is used as a terminal constraint inside MPC:
- terminal state x_N must satisfy NN(x_N) ≈ 1
This enforces:
- recursive feasibility
- improved stability
- safer trajectories
Dynamics are implemented using CasADi with URDF-based models for the double pendulum.
We compare three MPC formulations:
- MPC without terminal constraint
- MPC with learned viability constraint
Metrics:
- feasibility rate
- constraint violations
- trajectory quality
- robustness under perturbations
- Python
- CasADi (optimal control)
- PyTorch
- NumPy
- nonlinear control & optimization tools
- Learn a control-invariant set from data
- Approximate viability kernel using neural networks
- Improve MPC recursive feasibility
- Compare learned vs classical MPC formulations
Marco Misseroni
MSc Mechatronics Engineering – Electronics and Robotics
University of Trento