KFUPM logo
King Fahd University of Petroleum & MineralsSystems and Control Engineering Department

SCE 513 · Systems Identification · Final presentation

Deep Koopman-Based Reachability Analysis for Data-Driven Predictive Control of Unknown Nonlinear Systems

A Python reproduction of Algorithm 1 (Ketema et al., 2025) and a calibrated-tube extension for MPC

Abdurrahman Adebisi Aderinto · ID 202527250
Supervisor: Prof. Mujahed Al Dhaifallah

Ketema, Tilahun, Zawka & Geletu · IFAC J. Syst. Control 34 (2025) 100339

→ next · N notes · P presenter view · F full screen

01

The reproduction

Objective: re-implement the paper's reachability method in Python and test its claims on held-out data.

Algorithm 1The paper's core procedure: propagates the set of possible outputs P steps ahead through a learned Koopman model.
ZonotopeA centrally symmetric polytope, c + G·[−1, 1]m. Linear maps and Minkowski sums keep it a zonotope, so set propagation stays exact and cheap.
Independent implementationNo author code used. Built from the paper's equations; my zonotope algebra is verified against pypolycontain.
The problemAlgorithm 1, in codeReproduction & code flowResultsσ, live
01Reproduction

Where can an unknown plant's output go next?

The problem

  • u,yUnknown plant. We don't have the equations, just recorded inputs u and outputs y with bounded noise.
  • RGoal: an output tube R1 … RP that contains y(k), for the next P steps, so a model predictive controller (MPC) can keep its constraints. It must be valid (contains the true output) and tight (as narrow as possible).

The paper's recipe · Ketema et al., 2025

1

Lift

An LSTM maps a window of past (u, y) to observables Φ, features in which the dynamics are approximately linear

2

Fit

EDMD (extended dynamic mode decomposition) fits, by least squares, a linear model Φ⁺ = AΦ + Bu, y = HΦΦ; Φ⁺ is the next lifted state, HΦ maps it back to the outputs

3

Propagate

Algorithm 1 propagates zonotopes through the model to get the output sets

Scope set by Prof. Al DhaifallahAlgorithm 1 only (R1) · accuracy on independent test data (R2) · own code, not MATLAB (R5)
01Reproduction

Algorithm 1: lift the set, propagate it, inflate by the uncertainty

6

Lift the output set into Φ

R Phi k equals H Phi plus applied to R y k minus Z theta, Minkowski sum with P null Z sigma

The pseudo-inverse HΦ+ only recovers 2 of the lifted directions, so the other get a ±σ box. The paper uses σ = .

7

Step forward, then pad

R y k plus 1 equals H Phi K applied to R Phi k times Z u, plus process noise, sensor noise and Z delta

One linear Koopman step, then Minkowski sums (⊕) with process noise, sensor noise and Zδ, which we read as the min–max box of the training residuals.

Rykline 6
→
RΦkline 7
→
Ryk+1repeat for k = 0 … P−1

Notation · Ryk, RΦk: output and lifted sets at step k · K = [A B]: Koopman matrices · Zu: input set · Zθ, ZωΦ: sensor and process noise · Pnull = I − HΦ+HΦ: directions the outputs cannot see · Zσ: the ±σ box.

This is the actual code from reachability.py, pulled in when the deck is built, so the line numbers are real.

01Reproduction

Reproduction pipeline: one command, fixed seed, bit-exact re-runs

$ make reproduce python scripts/run_pipeline.py · configs/default.yaml · seed · ≈ 3 min
01

generate

CSTR · traj. × steps

trajectories.npz
01b

split

by trajectory:

split.npz
02

train

LSTM lifter; EDMD solved in closed form inside the loss

best.pt
03

sweep

configs, picked on validation

T1 · F2
04

evaluate

test split only, enforced by a guard in the script

T2 · T3 · F3 · F8
05

reach

Algorithm 1 at σ =  and σ = 0

T4 · F4
06

figures

all figures made from saved results

results/figures
Code each stage calls · src/koopman_reach/ · T, F: tables and figures of the report
system.py
data.py
data.py
lstm_koopman.py
edmd.py
lstm_koopman.py
itmf.py
metrics.py
zonotope.py
reachability.py
plotting.py

1Plant repaired

The equations as printed overflow (e427), so I ported cstrDiscr from the CORA reachability toolbox, the model both papers actually simulate.

2Held-out protocol

The paper doesn't use test data. I split by trajectory and read the test split only once.

3Own zonotope algebra

I wrote it in NumPy and checked it against another library (pypolycontain) in tests.

4Reproducible

tests; a clean re-run is bit-exact. Every choice the paper leaves open is documented: deviations from the paper.

01Reproduction

How the code is organised: one package, seven layers

L6Studies & reporting

scripts/01–06 + run_pipeline.pyscripts/07–19 · study.pyreports & paper: tables from code

L5MPC use & stress tests

closed-loop tube MPC (convex QP vs nonlinear program)input-shift testpre-fit diagnostic

L4Calibrated tubes

calib.py · tube buildersconformal_tubes/ · numpy-only library

L3Set-based reachability

zonotope.py · checked vs pypolycontainreachability.py · Lemma 1 + Algorithm 1

L2Validation

itmf.py · information-theoretic checks: MI, ΔH, KLmetrics.py · 1-step & free-run accuracy

L1Predictors

edmd.pylstm_koopman.pyseq2seq.pyARX · poly-EDMD

L0Plants & data

system.py · CORA cstrDiscrdata.py · split, windows, z-scoreconfigs/default.yaml5 more plants + measured tanks
Reproduction (SCE 513)Extension (publication)Shared
Data flows up. Each layer only uses the ones below it.
Frozen at v1.0-sce513. For the extension I only added modules and didn't touch L0–L3, so make reproduce remains bit-exact.
tests guard both tracks (make test).
01Reproduction

Identification: test error at the measurement-noise floor

|
one-step RMSE on y1 | y2 · measurement-noise floor
R2 >
on held-out test trajectories · free run stable: spectral radius of A = < 1, so long predictions stay bounded
×
lower one-step error than an affine (linear + offset) baseline on the nonlinear output y2
New · the paper doesn't report test accuracyTest trajectory 0: measured outputs and the Koopman predictions

Test trajectory #0, y1 top, y2 bottom: measured ▲, Koopman one-step ○ and free run (blue), output-centric model (orange).

01Reproduction

Scorecard: what reproduced and what didn't

Paper figure or claimPaperThis reproductionStatus
Fig. 2 · loss vs hyper-parametersflat fieldflat, one outlier ( networks)Trend reproduced
Fig. 3 · mutual informationsignificantsignificant for all state–observable pairsReproduced
Fig. 3 · entropy difference, KLconstant along rowsvaries with the observableNot reproduced
Fig. 4 · containmentoutputs inside the sets100 % at every step, also held-outReproduced
Fig. 4 · set sizehalf-width ≈ in y2 at σ =  (one step)Not reproduced
Accuracy on test data (R2)not reportednoise floor, R2 > New result
Four causes behind all the gapsthe plant as printed · normalisation and binning not given · loss not given · and σ‖HΦAPnull‖, which I show live next →
01ReproductionLive

At σ =  every output is contained, but the sets are wide

Rk, k = 1 … (interval hull)R0 fresh trajectoriestrajectory #0
σ · box size on the unobserved directions
0as printed
y2 half-width after one step
±0.5

/ contained

Checked exactly (LP) at σ = 0. The sets only get bigger as σ grows, so it holds for every σ. Containment is guaranteed by construction.

02

The extension

RESEARCH QUESTION

If every predictor carries the same 95 % guarantee, does deep Koopman lifting give tighter output tubes?

Width set by a hand-picked σ→ calibrate it from data
100 % is automatic→ target a stated coverage 1 − ε = 95 %
No simpler baseline→ compare predictors under one guarantee
02Extension

One calibrated number κ turns any predictor into a 95 % tube

1

Predict

R k of kappa is the set of y with absolute deviation from c k at most a k plus kappa b k

Each predictor returns a centre ck, a fixed width ak and a scalable width bk, for k = 1 … P.

2

Score

score is the max over steps and outputs of the scaled excess deviation

For each of N = new trajectories, the score s is the smallest κ whose tube covers all P outputs.

3

Calibrate (split conformal)

κ̂ = the smallest of the scores (ε = 0.05). Analogy: a courier quoting a 95 % delivery time from past deliveries.

4

Guarantee

kappa hat gives probability at least one minus epsilon that every step lies in the tube

Covers the whole trajectory, for any predictor. Assumptions: marginal (on average over runs), exchangeable data, open loop.

This is all the code the guarantee needs, numpy only: src/conformal_tubes/core.py, also released as the conformal-tubes package.

Predictors compared: ARX (linear, past window) · B3 (deep Koopman, ours) · poly-EDMD (polynomial features) · seq2seq (LSTM, all P steps at once) · Algorithm 1 (lean reading).

02ExtensionLive

Same coverage guarantee, very different tubes

Coverage target 1 − ε95 %
trajectory 1 / 8
Half-width · median of 10 seeds · log scale

Half-width: tube radius in z-score units, lower is tighter. Coverage: share of test trajectories inside the tube at every step.

Reading
02Extension

The catch with the tightest tube: fragile coverage, harder MPC

Coverage under bang-bang inputs (extremes only)

Calibrated on the training input law, tested on bang-bang inputs · mean of plants × seeds · ○ worst plant

Without the shift all three are on target: ARX , B3 , seq2seq . Only seq2seq loses its guarantee when the inputs change.

Closed-loop tube MPC on Van der Pol · x1 ≤

seeds × episodes · violations without a tube (nominal) → with the calibrated tube

ModelViolating episodesCost increase

open-loop coverage of the seq2seq tube on closed-loop data (B3 , ARX )

Structure matters tootubes that are affine in u keep the tightened MPC a convex QP, while a seq2seq tube turns it into a nonlinear program.
✓Takeaways

What I take away

01Reproduction

  • Identification reproduced, with noise-level accuracy and a stable free run.
  • Containment reproduced (100 %), but it holds by construction.
  • Set size not reproduced. It's driven by σ‖HΦAPnull‖, which the paper doesn't report.

02Extension

  • Calibrate first, and only compare widths at the same coverage.
  • On near-affine plants, plain ARX is enough.
  • On nonlinear plants, deep prediction helps more than deep lifting, but you lose some robustness and convexity.

Thank you. Questions?