Simulink Design Optimization 1.1
F14 Parameter Estimation at the Command Line
In this demo, we use experimental data to estimate three parameters (Md, Ta, Zd) of the F14 model. This is accomplished using the command-line interface of Simulink® Design Optimization™.
Contents
- Open the Model and Load Experimental Data
- Plot Measured Data and Simulation Results
- Create Objects to Represent the Experimental Data Sets
- Create Objects to Represent Parameters
- Create Objects to Represent Estimated Initial States
- Create the Estimation Object
- Set up Estimation Options
- Run the Estimation
- Plot Measured Data and Final Simulation Results
- Look at the Estimated Parameter and Initial State Values
- An Alternative Using the GUI
Open the Model and Load Experimental Data
First open the model and load the experimental data. The data corresponds to the input and outputs of the model.
model = 'f14'; open_system(model) set( find_system(model, 'FindAll', 'on', 'BlockType', 'Scope'), 'Open', 'off ' ) load f14_estim.mat
Plot Measured Data and Simulation Results
Let's first compare the response of the model with the experimental data. It can be seen that the model response using the current parameter values does not match the experimental output data.
[T,X,Y] = sim(model, time, [], [time iodata(:,1)]); plot(time, iodata(:,2:3), T, Y, '--'); title('Simulated and Measured Responses before Estimation') legend('Measured angle of attack', 'Measured pilot g force', ... 'Simulated angle of attack', 'Simulated pilot g force');
Create Objects to Represent the Experimental Data Sets
The first step in the parameter estimation process is to create a new data set to store our experimental input/output data.
hExp = ParameterEstimator.TransientExperiment(model); set(hExp.InputData(1), 'Data', iodata(:,1), 'Time', time); set(hExp.OutputData(1), 'Data', iodata(:,2), 'Time', time, 'Weight', 5); set(hExp.OutputData(2), 'Data', iodata(:,3), 'Time', time);
Create Objects to Represent Parameters
Next we select the model parameters that will be estimated. We also set bounds on these parameters based on our understanding of the system.
hPar(1) = ParameterEstimator.Parameter('Ta'); % Initial value: Ta = 0.5 set(hPar(1), 'Minimum', 0.01, 'Maximum', 1, 'Estimated', true) hPar(2) = ParameterEstimator.Parameter('Md'); % Initial value: Md = -1 set(hPar(2), 'Minimum', -10, 'Maximum', 0, 'Estimated', true) hPar(3) = ParameterEstimator.Parameter('Zd'); % Initial value: Zd = -80 set(hPar(3), 'Minimum', -100, 'Maximum', 0, 'Estimated', true)
Create Objects to Represent Estimated Initial States
Initial states of the model can also be estimated.
hIc(1) = ParameterEstimator.State('f14/Actuator Model'); set(hIc(1), 'Minimum', 0, 'Estimated', true)
Create the Estimation Object
The last step before starting the estimation is to create an estimation object to store all our experiment data and various other settings.
hEst = ParameterEstimator.Estimation(model, hPar, hExp); hEst.States = hIc;
Set up Estimation Options
Various optimization options can be set before running an estimation.
hEst.OptimOptions.Method = 'lsqnonlin'; hEst.OptimOptions.GradientType = 'refined'; hEst.OptimOptions.Display = 'iter';
Run the Estimation
We are now ready to start the estimation.
estimate(hEst);
Norm of First-order
Iteration Func-count f(x) step optimality CG-itera
tions
0 1 118351 9.34e+005
1 2 41164.2 0.971863 2.36e+005 0
2 3 12430.8 0.92363 4.73e+004 0
3 4 3771.98 1.02982 9.51e+003 0
4 5 1095.55 0.847798 2.54e+003 0
5 6 267.859 0.501876 781 0
6 7 23.8135 0.363035 124 0
7 8 1.33361 1.05347 41 0
8 9 0.0323366 0.393464 1.69 0
9 10 0.00672323 0.0384312 0.018 0
10 11 0.00248547 0.0121901 0.00132 0
11 12 0.00145679 0.00855552 0.00032 0
Local minimum found.
Optimization completed because the size of the gradient is less than
the selected value of the function tolerance.
Plot Measured Data and Final Simulation Results
Now that we have estimated the model parameters, we can compare the simulation outputs against the experimental data. It can be seen that the model response using the estimated parameter values nicely matches the experimental output data.
[T,X,Y] = sim(model, time, [], [time iodata(:,1)]); plot(time, iodata(:,2:3), T, Y, '--'); title('Simulated and Measured Responses after Estimation') legend('Measured angle of attack', 'Measured pilot g force', ... 'Simulated angle of attack', 'Simulated pilot g force');
Look at the Estimated Parameter and Initial State Values
Let's also take a look at the estimated parameter and initial state values.
find(hEst.Parameters, 'Estimated', true) find(hEst.States, 'Estimated', true)
(1) Parameter data for 'Ta':
Parameter value : 0.05
Initial guess : 0.5
Estimated : true
Referenced by:
(2) Parameter data for 'Md':
Parameter value : -6.885
Initial guess : -1
Estimated : true
Referenced by:
(3) Parameter data for 'Zd':
Parameter value : -63.99
Initial guess : -80
Estimated : true
Referenced by:
(1) State data for f14/Actuator Model block:
The block has 1 continuous state(s).
State value : 0.0001404
Initial guess : 0
Estimated : true
An Alternative Using the GUI
We can also estimate the model parameters using the GUI. To launch the GUI with a project preconfigured for F14 parameter estimation, open the spe_f14.mdl model and double click the subsystem in the lower left hand corner of the model.
Store