Skip to content

MathBioCU/WSINDY-MPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WSINDy for Model Predictive Control with Applications to Fusion, Drones, and Chaos

Cristian López, Mckenna Partridge, Sebastian De Pascuale, Jeremy Lore, Andrew Christlieb, Stephen Becker, and David M. Bortz.

https://arxiv.org/abs/2604.23269

Getting Started

As it was done in SINDY-MPC, the code for each example YYY is in the corresponding example folder /EX_YYY. We use codes from SINDy (/utils), E-SINDy (/EnsembleSINDy-main), and WSINDy (/WSINDy_ODE). Data generation, parameter selection, objective functions, constraint functions, and plotting routines will be in the corresponding example folder.

  1. Go into an example folder WSINDY-MPC/EX_YYY.

  2. Run script EX_YYY_SI_SINDYc_methods. This script contains the SINDYc, E-SINDYc code from Fasel et al., WSINDYc code from Messenger and Bortz and López et al., and E-WSINDYc methods. For other methods, e.g., DMDc and NARX, replace SINDYc_methods accordingly. The trained models are saved in the folder WSINDY-MPC/DATA/.

  3. Run MPC for all available models, e.g. SINDYc, E-SINDYc, WSINDYc, E-WSINDYc, DMDc, NARX, Oracle, by executing MPC_YYY_ModelComparison.m.

  4. Saved figures may be found in WSINDY-MPC/FIGURES/YYY/. Saved results, identified models, or controller outputs may also be stored in WSINDY-MPC/DATA/YYY/ or in an output folder defined by the example script.

Using the Software on a New Problem

  1. Create a new example folder named WSINDY-MPC/EX_YYY, where YYY is the name of the new system or application. You may use one of the existing example folders as a template.

  2. Define the system dynamics, input variables, state variables, training trajectory, validation trajectory, MPC parameters, cost function, constraints, and plotting routines.

The files that usually need to be created or modified for a new problem are:

EX_YYY_SI_SINDYc_methods.m      : Runs SINDYc-based system identification.
getTrainingData.m               : Generates or loads the training data.
getValidationData.m             : Generates or loads validation data for model testing.
getMPCparams.m                  : Sets MPC horizon, time step, weights, bounds, and solver options.
ObjectiveFCN.m                  : Computes control objective using true system model.
ConstraintFCN.m                 : Evaluates MPC constraints for the true system, if used.
ObjectiveFCN_models.m           : Computes control objective for different models
ConstraintFCN_models.m          : Evaluates MPC constraint functions for different models
MPC_YYY_ModelComparison.m       : Runs MPC and compares all available model types, if included.
build_YYY_codegen.m             : Creates mex files.

The workflow is usually split into two main algorithm scripts:

EX_YYY_SI_SINDYc_methods runs the SINDYc-based system identification algorithm. It loads or generates training data, builds the library, identifies the sparse controlled dynamical model, validates the model, and saves the identified coefficients.

MPC_YYY_ModelComparison runs the MPC algorithm. It loads the identified models, defines the MPC problem, solves the optimal control problem over a prediction horizon, applies the first control input, advances the system, and repeats this process over the closed-loop simulation.

Please first make sure EX_YYY_SI_SINDYc_methods correctly identifies a model from the available data. Then, run MPC_YYY_ModelComparison to test whether the identified model performs well inside the MPC controller.

Running in C code

In the corresponding example folder /EX_YYY, use the build_YYY_codegen file.

Keep the MATLAB version (matlab/R2023b) and gcc/10.3.0 to build the _mex files and to run MPC.

For example, after the system identification was performed, for drone:

  • Go into an example folder WSINDY-MPC/EX_DRONE/control.
  • Run build_drone_codegen.
  • Run MPC_Drone_ModelComparison_mex.
  • For realizations, run Z_SOLPS_MPC_Dependency_noise_mex.
  • We provide both non-mex and mex versions of the code. For example, for drone: MPC_Drone_ModelComparison and MPC_Drone_ModelComparison_mex

About

WSINDy for Model Predictive Control

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages