This repository contains MATLAB code accompanying the paper
Online Bayesian Learning of Agent Behavior in Differential Games by Francesco Bianchin, Robert Lefringhausen, Sandra Hirche.
The code implements an online Bayesian, game-theoretic approach to infer and
predict agent behaviour in multi-agent dynamical systems.
The key idea is to cast Hamilton–Jacobi–Bellman (HJB) optimality conditions as
linear-in-parameters residuals, enabling fast sequential conjugate Gaussian
updates and uncertainty-aware prediction from limited, noisy observations
(without history stacks).
We consider two-player, continuous-time differential games and address two main objectives:
-
Online Bayesian parameter estimation
- Gaussian priors on unknown objective parameters (value-function and cost terms)
- Recursive Bayesian regression using a stream of noisy observations
- Applicable to nonlinear dynamics and nonquadratic value functions via differentiable basis expansions
-
Behaviour prediction
- Use posterior parameter estimates to predict future state and control trajectories
- Propagate uncertainty forward via Monte Carlo simulation to obtain predictive distributions
The repository includes:
- a linear–quadratic (LQ) reference-tracking differential game, and
- a nonlinear 1D differential game used as a conceptual and numerical illustration in the paper.
The focus is clarity and reproducibility, rather than toolbox-style generality.
Citation
Bianchin, F., Lefringhausen, R. and Hirche, S., 2026. Online Bayesian Learning of
Agent Behavior in Differential Games. arXiv preprint arXiv:2601.05087.
We consider a two-player continuous-time differential game with dynamics
and infinite-horizon cost functionals
At a feedback Nash equilibrium, the value functions satisfy coupled Hamilton–Jacobi–Bellman optimality conditions together with the stationary feedback laws
To obtain a tractable inverse problem, the unknown objectives are approximated using differentiable feature maps,
while the quadratic control cost admits an exact linear representation
Substituting these representations into the HJB and feedback conditions yields, at each time step, a linear regression model
where
Posterior uncertainty is propagated forward through the induced feedback policies using Monte Carlo simulation to obtain predictive distributions over future states and control inputs.
.
├── example_LQ_bayes_identification_prediction.m
│ Main LQ differential game example
│
├── example_NL_bayes_identification_prediction.m
│ 1D nonlinear differential game example
│
├── core/
│ Core algorithms (Riccati solvers, value-function computation, etc.)
│
├── utils/
│ Utility functions (sampling, Bayesian updates, regressors, helpers)
│
├── visualization/
│ Plotting and visualization routines
│
└── README.md
File:
example_LQ_bayes_identification_prediction.m
This script simulates a two-player continuous-time linear–quadratic differential game with reference tracking.
It demonstrates:
- Online Bayesian estimation of value-function parameters and diagonal cost matrices
- Reconstruction of feedback controllers from posterior means
- Behaviour prediction:
- future state trajectories
- future control trajectories
- uncertainty propagation via Monte Carlo sampling
- The closed-loop ODE is written in terms of the deviation from the reference:
and this deviation is used implicitly throughout the script.
- Cross-control cost terms are set to zero (R12 = R21 = 0).
File:
example_NL_bayes_identification_prediction.m
This script reproduces the 1D nonlinear two-player differential game used in the paper.
The nonlinear dynamics take the form:
- MATLAB (tested with 2025b version)
- Control System Toolbox
- Optimization Toolbox (required for lsqnonlin)
- Statistics and Machine Learning Toolbox
- No third-party dependencies
-
Clone the repository and add it to your MATLAB path.
-
Run one of the example scripts:
example_LQ_bayes_identification_predictionor
example_NL_bayes_identification_prediction -
Figures will be generated automatically. Plotting can be disabled via flags inside the scripts.
This code is intended for:
- readers of the accompanying paper,
- researchers working on learning and inference in differential games,
- users interested in Bayesian identification and prediction in continuous-time control.
The focus is clarity and reproducibility, not toolbox generality.
If you use this code in your work, please cite the associated paper:
Bianchin, F., Lefringhausen, R. and Hirche, S., 2026. Online Bayesian Learning of Agent Behavior in Differential Games. arXiv preprint arXiv:2601.05087.
For questions or issues related to the code, please contact the authors: francesco.bianchin@tum.de
