This repository provides the code code that was employed to arrive at the results presented in Optimal Instrumental Variable Selection for Closed-loop Data-Driven Predictive Control by
Rogier Dinkla1, Tom Oomen1,2, Sebastiaan P. Mulders1, and Jan-Willem van Wingerden1.
Affiliations:
1 Delft Center for Systems and Control, Faculty of Mechanical Engineering, Delft University of Technology, The Netherlands
2 Control Systems Technology Group, Department of Mechanical Engineering, Eindhoven University of Technology, The Netherlands
-
MATLAB R2024b (or compatible) with toolboxes:
Toolbox Version Control System Toolbox v24.2 Robust Control Toolbox v24.2 Statistics and Machine Learning Toolbox v24.2 System Identification Toolbox v24.2 Parallel Computing Toolbox v24.2 - Check installation: Run
verin MATLAB to verify toolbox availability - License: Proprietary (academic license used; see MathWorks licensing options)
- Check installation: Run
-
CasADi v3.6.7
- License: LGPL v3.0 (open source)
- Purpose: Symbolic differentiation. Used for symbolic computations to obtain a SPC-type controller (see
src/MC_sim/get_solver.m).
-
Crameri colormaps v7.0+ (required for paper figures)
- License: MIT (open source, see MATLAB file exchange -> Zenodo)
- Purpose: Perceptually uniform scientific colormaps (linear colour gradients among other features).
- Data was generated and processed using the DelftBlue supercomputer. Use of a comparable high-performance computer (HPC) is optional. Code is tailored to the potential use of an HPC with SLURM scheduling.
- License: MIT License (see LICENSE.md)
- Copyright: (c) 2026 Data-Driven Control, TU Delft
- Edit SLURM cluster configuration settings in
INIT.mbefore running (optional — only needed if using a SLURM cluster) - Run the
INIT.mfile from the project directory. The output should resemble (using Windows here)
================= CasADi v3.6.7 ==================
-------------- SYSTEM DETECTION ---------------
MATLAB release : 2024b
Platform : windows
------------ SELECTING DEPENDENCIES -----------
CasADi: Selected Windows 64-bit binary
----------- INSTALLING DEPENDENCIES -----------
>> Downloading from GitHub... Done
>> Extracting files... Done
>> Verifying installation... Done
============== Crameri colour maps ===============
>> Downloading from GitHub... Done
>> Extracting files... Done
>> Verifying installation... Done
From the project directory in MATLAB, run:
addpath(genpath('src'));Specify the following parameters in MATLAB and save them to src/SlurmSettings.mat:
ProfileName = ''; % Enter profile name used for the SLURM cluster (e.g., 'MyClusterProfile')
account = ''; % Enter account e.g. 'institution-department'
partition = ''; % Enter partitions to use, comma-separated if multiple (e.g., 'partition1,partition2')
save(fullfile('src','SlurmSettings.mat'),'account','partition','ProfileName');N.B.: The above parameters may be left empty if no SLURM cluster is used, but the file must be saved as shown.
The code project uses CasADi v3.6.7:
- Download CasADi from casadi.org (version 3.6.7)
- Extract the contents to:
bin/casadi-v3.6.7/ - Add the directory to the path:
addpath(fullfile('bin','casadi-v3.6.7'));
- Verify CasADi was installed properly by running:
x = casadi.SX.sym('x'); fprintf('CasADi loaded successfully.\n');
- Download Crameri colormaps
- Extract the contents to:
bin/crameri_colours/ - Add to path:
addpath(fullfile('bin','crameri_colours'));
- Verify installation by running the below command (should open an illustration of available colormaps).
crameri
Option A: Run Simulations -> Process Data -> Visualize results
- step 1) Run
main_dRe()- This generates a batch of Monte Carlo simulations for varying Re (innovation noise variance).
- The parent directory for all of this data should be of the form
data/sys1/ref0_prbs/dRe/Re_1e-05_1e-01_15_p_20_N_1e03_f_20_YYYYMMDD_HHmm/
- step 2) Run
main_processing- This produces a
processed_data.matfile in the parent directory mentioned directly above.
- This produces a
- step 3) Edit the timestamp of the repository referenced by the
subdir1variable inplot_figs_paper.m. - step 4) Run
plot_figs_paper- This will produce all of the plots from the paper.
Option B: Download (Processed) Data -> Visualize results
- step 1) Download raw & processed data from Zenodo:
- step 2) Create the folder data/sys1/ref0_prbs/dRe/Re_1e-05_1e-01_15_p_20_N_1e03_f_20_20260327_1942 and extract the contents of the zipfile thereto.
- step 3) Run
plot_figs_paper
Important parameters that the user can change for different data sets are
| Parameter | Default | Description |
|---|---|---|
Re |
0.01 | Innovation noise variance |
N |
1000 | Number of columns in Hankel data matrix |
p |
20 | Past horizon (learning window length) |
f |
20 | Future horizon (prediction/control window) |
Ncl |
1500 | Closed-loop simulation length |
seed |
1 | Random seed for reproducibility |
sys |
1 | System configuration (1 = Landau1995, primary) |
ref0 |
'prbs' | Initial reference signal type: 'make*' or 'prbs' |
Qk, Rk, dRk |
100, 1, 1 | Controller cost weights |
*'make' specifies an initial reference that is based on the reference used in [25]. The output reference trajectory that is employed by the different controllers is always based on such a reference and not a 'prbs' variant.
A single Monte Carlo simulation can be run using the main function. Alternatively, batches of Monte Carlo simulations that perform a parameter sweep are performed by the functions
main_dRe- Parameter sweep over Re (innovation noise variance).main_dp- Parameter sweep over p (past window length).main_dN- Parameter sweep over N (number of Hankel matrix columns).
Each of the main_d<X> functions by default performs 100 Monte Carlo simulations per value of Re, p, or N.
For execution on a SLURM cluster:
- Configure SLURM settings via
src/SlurmSettings.mat(see installation section above) - Running
main_dRe,main_dp, ormain_dNwill automatically:- Detect SLURM settings from
SlurmSettings.mat - Submit and manage job runtime via
run_X_ParCluster.m - Save results to an appropriately named data directory
- Detect SLURM settings from
[25] A. Chiuso, M. Fabris, V. Breschi, and S. Formentin, "Harnessing uncertainty for a separation principle in direct data-driven predictive control," Automatica, vol. 173, p. 112070, Mar. 2025, doi: 10.1016/j.automatica.2024.112070.