Skip to content

Repository files navigation

Learning for Control – Viability Kernel Approximation (MPC Safety Constraints)

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.


Project Overview

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.


Methodology

Data Generation (Reachability Analysis)

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).


Learning the Viability Kernel

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

MPC with Learned Constraint

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

Systems

Dynamics are implemented using CasADi with URDF-based models for the double pendulum.


Experiments

We compare three MPC formulations:

  1. MPC without terminal constraint
  2. MPC with learned viability constraint

Metrics:

  • feasibility rate
  • constraint violations
  • trajectory quality
  • robustness under perturbations

Technologies

  • Python
  • CasADi (optimal control)
  • PyTorch
  • NumPy
  • nonlinear control & optimization tools

Objectives

  • Learn a control-invariant set from data
  • Approximate viability kernel using neural networks
  • Improve MPC recursive feasibility
  • Compare learned vs classical MPC formulations

Author

Marco Misseroni
MSc Mechatronics Engineering – Electronics and Robotics University of Trento

About

The aim of this project is to learn an approximate control-invariant set that can be used as terminal constraint in an MPC formulation.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages