This repository contains the code associated to the paper Parallelizable Parametric Nonlinear System Identification via tuning of a Moving Horizon State Estimator by Léo Simpson, Jonas Asprion, Simon Muntwiler, Johannes Köhler and Moritz Diehl.
Please refer to the paper for explanations of the content of the code here.
-
The files in the folder
SCRIPTS/contain Python script that correspond to the experiments described in the paper, with the exception ofexample1(noplot).pyandexample2(noplot).py, which are not related to the examples of the paper, but more examples to use the code.-
example1(noplot).pytest our the algorithm on a simple linear SISO system. -
example2(noplot).pytest our the algorithm on a simple linear MIMO system. -
illustration_MHE(plot).pycreates an illustration for MHE, Fig. 1 of the paper. -
counterex(plot).pyruns the experiment leading to Fig. 2 of the paper. Basically a very simple example, but with a lot of realizations with growing horizons, which shows the convergence or not of the methods. -
illustration_3D_Lorenz(plot).pycreates a 3D illustration of the Lorenz oscillator, Fig. 3 of the paper. -
trajectories_Lorenz(plot).pycreates a plot for some trajectories of the Lorenz oscillator together with the associated measurement: Fig. 4 of the paper. -
estimates_Lorenz(generate).pyis the long experiment leading to Fig. 5 of the paper. It estimates parameters in the Lorenz system for 4*10 different datasets (10 realizations for 4 true parameters). The results are saved in a pickle file. -
estimates_Lorenz(plot).pyloads the pickle file generated byestimates_Lorenz(generate).pyand creates Fig. 5 of the paper.
-
-
The files in the folder
SOURCE/contain Python scripts that correspond to the algorithms used in this work. It should be noted that a large amount of the code uses CasADi (a package for automatic differentation), so it is sometimes difficult to track what is exactly going on (some methods create casadi-functions, that are passsed to other methods, etc).-
nlp.pycreate a data-structure for formulating Nonlinear Programs (NLPs) with CasADi (similar to OptiStack, but hand-made). -
ipopt.pyfor the functions related to IPOPT solving some optimization problems. -
opti.pyfor our optimization algorithm, based on iteratively solve some esaier problems, through linearization. -
lti_method.pyimplement our method, but specifically in the case of LTI system. In this case, the method can be made way faster, because only the sample covariance of the data subsequences is used. So even for large amount of subsequences (e.g.$10^6$ ), the method remains fast. -
misc_method.pya large amount of miscellaneous functions used in the other files to implement the method. It is usually to functions to create useful casadi functions (e.g. for the arrival cost, the constraints in MHE, etc). -
initial_guess.py: solve the arrival-cost-free MHE problems to estimate x0 and on its covariance matrix (which will be used as initial guess for the arrival costs). -
method.pymainly a wrapper to assemble the different important functions (such as initial guess, building the arrival cost, building the NLP, solving the NLP, etc) to implement the method described in the paper. It also treats all the if conditions due to the different options (LTI vs NL, arrival cost or not, etc). -
vanilla_method.pythis creates a vanilla implementation of the problem by simply giving it to IPOPT without any special treatment. This is not currently used in the scripts, but might be useful. -
simple_MHE.pysimple MHE implementation. Actually not used in the algorithm, but used in the scriptillustration_MHE(plot).pyto create an illustration of MHE.
-
-
The files in the folder
UTILS/contain utility functions used in the scripts:-
models.pyfor creatinf the models -
simulation.pyfor simulating the models -
data_prepare.pyfor data pre-processing functions -
plotting.pyfor functions related to plotting
-
-
In the folder
FIGURES/one might find the figures generated by the scripts inSCRIPTS/, and presented in the paper.