Official repository for the paper:
Neural Autoencoder-Based Structure-Preserving Model Order Reduction and Control Design for High-Dimensional Physical Systems.
Marco Lepri, Davide Bacciu, Cosimo Della Santina.
The paper has been accepted for publication in IEEE Control Systems Letters, 2024. You can find it here.
TL;DR: We combine deep autoencoders with structure-preserving model order reduction to learn compressed representations of high-dimensional physical systems, while at the same time conserving their Hamiltonian structure. We also derive a mode-based controller using the learnt system representation and showcase its capabilities in closed-loop control of a simulated soft/deformable robot.
Flat AE | Graph AE |
---|---|
You can find the results discussed in the paper, as well as additional results, in this repository in the /results
folder.
In particular, videos of the simulations can be found in the compressed archives for each individual system. Results on the latent state analysis are instead located in the ./latent-analysys
subfolder.
Before using the code, make sure to have MATLAB & Simulink installed, as well as a recent python version. Pytorch
and torch_geometric
are also required to run the model training.
With conda, you can install both using
conda install pyg -c pyg
or see the official documentation for more details.
The /matlab
folder contains all the required code to collect the training and test data.
To collect the training data, open MATLAB, move to the /matlab
folder and execute the ./gather_training_data.m
script. This generates a /data
folder with one subfolder for each system (e.g. /data/sys1/
) containing the mass-spring model informations and the simulations data.
Once the data is collected, this is ready to use for the models training (see below).
To collect the test data, first you need to collect the training data. Once that is done, open MATLAB, move to the /matlab
folder and execute the ./gather_training_data.m
script. This generates a /results
folder with one subfolder for each system (e.g. /results/sys1/
) containing the dats for each simulation.
To train a model on the collected data, execute the ./train_model.py
script.
python train_model.py [-s SEED] config_file datatset filename
It takes the following parameters:
config_file
: a json configuration file specifying the (hyper)parameters of the models. Note that the name of the parameters must match the name of the argumants taken by the relative model constructor. You can find example model configuration files in the/configs
folder.dataset
: the name of the dataset to train the model on, e.g.sys1
. Note that this must be equal to a subfolder in the/data
directory.filename
: name of the file where the model parameters are saved. This is also the prefix for the files containing the learning curves.seed
: an optional seed for the RNG
Similarly, to perform a grid search, execute the ./grid_search.py
script.
python grid_search.py [-s SEED] config_file dataset save_prefix
In this case, the configuration file requires a grid_search
field where the names of the hyperparameters are specified. Those must correspond to fields in the configuration file where multiple values are provided (e.g. a list of learning rates). save_prefix
is instead the prefix for the files generated by the grid search. These include the learning curves for each model (files ${I}_tr
and ${I}_vl
) and the summary.
Note: the /results
folder already contains the grid search results and final models for the five systems considered in the paper.
To use the trained models to perform reduced simulations, open MATLAB and use execute the simulate_reduced.m
script. In order to do so, make sure to have the matlab
folder (and it subfolders) included in your search path (e.g. with addpath('matlab')
). Then prepare the workspace by defining three variables:
sys_idx
: number of the system to simulate (1 to 5)sim_idx
: number of the simulation to perform (8 to 37)model_name
: name of the model to use ('ae' or 'gae')
Note: The script requires the folders and subfolders to have the structure created when gathering the test data. Make sure to execute that script first and do not change the folder structure.
Once the reduced simulations are completed, you can reconstruct the full-space state and energy with the reconstruct_position.py
, reconstruct_velocity.py
and reconstruct_energy.py
scripts. These requires the system number and the name of the model used for the simulations.
To perform the experiments with the latent state controller, open MATLAB and execute the control_experiments.m
script. In order to do so, make sure to have the matlab
folder (and its subfolders) included in your search path.