How to Estimate Model Parameters from Test Data with Simulink
From the series: “How To” Video Series for Biomedical and Pharmaceutical Applications
Learn how to improve your Simulink® model accuracy by automatically estimating model parameters from test data in just a few clicks.
Published: 22 Sep 2021
Hello, everyone, Paul here from MathWorks. Today I'm going to show you how you can improve your Simulink model accuracy by automatically estimating model parameters from test data. We'll be continuing with the simple bioreactor model that we built last time, but I encourage you to consider how these techniques might be applied to your own model. If you attended the batch process optimization webinar, you may recall that we had a data folder containing several spreadsheets with the nutrient and biomass time histories, resulting from an experimental campaign that included six different constant temperature batch runs.
To begin, we'll arbitrarily select one of these runs and load the data into MATLAB. We'll then use this data to estimate the kinetic parameters k1, k2, and k3 that best fit our model output signals to these time histories. As with MATLAB, Simulink has several interactive apps to help you get started with capabilities such as control design, generation, and verification validation and testing. We'll be using the parameter estimator app. After creating a new experiment, we see the app has automatically selected the nutrient and biomass signals from our model. We then just need to specify the corresponding time history data that we would like these output signals to best fit.
In our case, this is the nutrient and biomass time histories we loaded into the workspace. Next, we'll specify that we want to estimate the k1, k2 and k3 parameters and then press Estimate. The estimation report illustrates the progress of the estimation after each iteration. Once converged, we can use the new parameter values to compare the simulated output from our model with the measured output from our test data file. We can then repeat this process for the other constant temperature batch runs to examine the kinetic parameter temperature dependency.
However, instead of going through this interactive process every time, as with most MATLAB apps, we can automatically generate a MATLAB function to perform this analysis programmatically. Examining this code, we see that our test data is being set using a local function named get data. If you scroll to the bottom, you'll see the time series test values we provided have been hard coded into this function. To make the parameter estimation function more flexible, let's replace the calls to get data with time series created from a data table that will pass in as an additional input. We can then call this function in a loop to estimate the kinetic parameters using the data files from the other constant temperature batch runs.
But first, we'll use the data store to easily gather information about all the available spreadsheets. To speed up our analysis, we'll use a computer cluster to process all the data files in parallel. You can use the cluster profile manager to discover other clusters running on your network, or create a cluster in the cloud. Here you can see I've started a cluster with 16 workers on a remote machine. This means I can process all six data files simultaneously. To ensure each worker has access to the required files, I've attached them to the cluster pool. The only other change I need to make is to use a parallel four loop instead of a regular for loop. Once we submit the job by running the section, MATLAB automatically transfers the necessary files and distributes the tasks to the available workers. The workers then return the results as they complete their task.
Finally, since we stored the result from each run, we can plot the kinetic parameters as a function of temperature. This result in a figure very similar to what we saw in the batch process optimization webinar. However, notice this time, we did not have to rearrange our model equations to explicitly solve for the kinetic parameters. I hope this quick demonstration illustrated how easy it is to begin optimizing your models in Simulink.
Please visit the Simulink design optimization product page to learn more about other capabilities, such as using techniques like sensitivity analysis and Monte Carlo simulations to explore your design space or automatically tuning model parameters to meet time and frequency requirements. Likewise, please visit the MATLAB Parallel Server product page to learn how you can record once and then use it in multiple execution environments. Thanks for watching.