MoDMPC Toolbox Demonstration File
A. Stenman,* M. W. Braun,**
and D. E. Rivera**
*Division of Automatic Control, Department of Electrical Engineering
Linköping University, SE-581 83 Linköping, Sweden
**Department of Chemical and Materials
Engineering
Control Systems Engineering Laboratory,
Arizona State University, Tempe, Arizona 85287-6006
1 Introduction
The goal of this file is to provide the user with a hands-on demonstration
of how to use the MoD V&V GUI for MATLAB, and the MoDMPC Toolbox for
Simulink. This example will make use of a Non-Adiabatic (or Diabatic)
Continuous Stirred Tank Reactor (CSTR) simulation. The main idea
is to identify a model of the interation between the jacket temperature
of the reactor, and the concentration of the effluent. An informative
input/output dataset had already been generated using a multi-level pseudo-random
sequence excitation signal.
Be sure that you have downloaded the MoDMPC toolbox, unzipped
it, and placed the toolbox directory and all of the subfolders in your
MATLAB path.
If you need a decompression utility, try WinZip.
Here is a list of the demo Simulink files, and the data used to run
them:
-
cstr1.mdl/demo1e.mat/demo1v.mat/demo1n.mat
-
cstr2.mdl/demo1e.mat/demo1v.mat/demo1n.mat
-
cstr2b.mdl/demo2e.mat/demo2v.mat/demo2n.mat
-
cstr3.mdl/demo1e.mat/demo1v.mat/demo1n.mat (note: you need to load
the setpoint trajectory rout.mat into the workspace to run the simulation)
-
cstr4.mdl/demo1e.mat/demo1v.mat/demo1n.mat
-
cstr5.mdl/demo4e.mat/demo4v.mat/demo4n.mat
Each Simulink file runs a different MoDMPC block from the library, as indicated
by the name.
2 Using the Model-on-Demand Visualization and Validation GUI
In this section, we'll load the input/output data and look
at the coverage in the time, input/output, and frequency spaces. Then we
will try to predict the output of the validation data, using a few iterations
of MoD to validate our user decisions. Remember that Model-on-Demand estimation
is data driven, so the estimation data must cover the expected operating
regions of the process. The validation data must test the interpolative
ability of the MoD estimator using the estimation dataset, so robust user
decisions can be made. This is why it's important to "visualize"
both datasets first!
2.1 Loading the Data and NARX Matrix
To start, click the "Load Estimation Data" button, and select "demo1e.mat"
from the "demos" directory as shown below. Press "open" to complete
the operation:

In a similar manner, select "demo1v.mat", after pressing the the "Load
Validation Data" button, and then press "open".
To load the NARX structure matrix, press "Load NARX Matrix", and select
"demo1n.mat".
2.2 Visualizing the Data in the Time Domain
First, let's see what the data looks like in the time domain.
To do this we will first specifiy the correct number of inputs (1) and
outputs in the data (1), and the sampling time (0.1 hour) at which it was
recorded by editing the text boxes shown below. We would also like
to see how the validation data compares, and we can check that option,
so both datasets are plotted together.
Having made these selections, press the "Plot Time Domain" button to
generate the following figure.

If the data properties have not been specified such that they make sense
with the datafile, an error message will appear in the GUI.

2.3 Visualizing the Data in the Input/Output Domain
We can get a sense for how well the data covers the possible input/output
combinations within the expected operating regions of the input and output.
To do this simply select the "plot input by output" option, and press "Plot
Space Domains".

To get a sense for the second order information in the data, we can
look at the differenced input/output spaces. To plot the differenced
versions of the options selected in the Space Domains area, press "Plot
Dif. Space Domains".

2.4 Visualizing the Data in the Frequency Domain
Next, we can observe how
much support the estimation data provides for predicting the validation
data in the frequency domain. For this, we will select the options
to plot the input power spectra, the output power spectra, and the ETFE.
We will also disregard the DC component, so we can get a good look at the
rest of the frequencies.

2.5 Making Decisions about the MoD Estimator
To begin, we would like to see how well MoD predicts the output of the
entire validation set (infinite-step ahead prediction). So "Inf"
is typed in the prediction horizon text box. Next, we would like
to specify how little or how much data can be considered by the candidate
bandwidth selection. kmin
(the lower limit on the number of data to be considered) is set to 10 as
an initial guess and kmax is set
to 200 (since we have a relatively small database, we can consider nearly
all the data). We will use a local polynomial of order one (the only
specification allowed by the MoDMPC Simulink Library), and we will choose
not to include the 95% confidence intervals for now. The standard
Akaike's Information Criteria (AIC), will be used to judge the candidate
bandwidths. A variance penalty of 3 will be used for the AIC.
Lastly, we will use the global goodness-of-fit option.

Pressing the "Validate" button, we get the wait bar and then see the
following plots:

Note that the MoD Estimator selected an ill-conditioned model just before
time 3. The number of datapoints used at this time was 36.
So we know that kmin
should probably be raised to something above this. Let's choose
45, and validate again.

At this point, kmin has
been set high enough to provide well-conditioned local models for prediction
through the regressor spaces of the validation data. Note that this
value may still need to be raised if "bursts" are evident during control
experiments of Simulink models. By inspection of the plot, we see
that the MoD estimator does not predict the last 4 to 5 hours as well as
the first 10 hours. This is partly due to the way the input signal
was designed (to emphasize high frequency). We can look at a 15 step
ahead prediction to see how the initial time prediction of MoD performs
with this data.

Now that we are satisfied with the validation, we will use the "Save
Parameters" button to save ALL the parameters under one structure.
Then we can load this structure back into the workspace, so we can run
a MoDMPC block. As an example, we have saved the variable "demoparms".
3 Running the "cstr.mdl" demo
Now that we have made our user decisions (and they work), we can try out
MoDMPC Block #1 in "cstr1.mdl". Open "cstr1.mdl" via Simulink.

First, 2x click on the button "2x Click to Initialize". Next,
bring up the "MoDMPC 1" parameters by double clicking on the MoDMPC 1 block.
Type in the name of the parameters structure you specified in 2.5,
we'll use "demoparms". Be sure to load the parameter set into the
workspace (i.e. type "load demoparms"). The rest of the controller
options have been prespecified, such that the controller will run with
good performance.

The Simulink window is now started. Note that there are scopes
on the control and manipulated variables, so you may watch the results
as they are generated. Once the simulation is done, the button "2x
click to plot data" may be pressed to generate a figure of the results,
along with RMS control error calculations.

In a similar manner, the other demos included with the toolbox can be
used to understand the specifics of each type of controller block, along
with the help file.