Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

 

Simulink Design Optimization 1.1

Engine Parameter Estimation at the Command Line

In this demo, we use experimental data to estimate various parameters of an engine idle speed model. This is accomplished using the command-line interface of Simulink® Design Optimization™.

Contents

Open the Model and Load Experimental Data

First open the model. The experimental data is automatically loaded when we open the model. The data corresponds to the input and outputs of the model.

model = 'engine_idle_speed';
open_system(model)
set( find_system(model, 'FindAll', 'on', 'BlockType', 'Scope'), 'Open', 'off
' )

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(gcs);
set(hExp.InputData(1),  'Data', iodata(:,1), 'Time', time);
set(hExp.OutputData(1), 'Data', iodata(:,2), '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('gain1', 'Minimum', 100);
hPar(2) = ParameterEstimator.Parameter('gain2', 'Minimum', 0);
hPar(3) = ParameterEstimator.Parameter('gain3', 'Minimum', 0);
hPar(4) = ParameterEstimator.Parameter('mean_speed', 'Minimum', 600);
set(hPar, '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);

Setup Estimation Options

Various optimization options can be set before running an estimation.

hEst.OptimOptions.Method       = 'lsqnonlin';
hEst.OptimOptions.GradientType = 'basic';
hEst.OptimOptions.Display      = 'iter';

Compare Simulation vs. Experiment Before Estimation

Let's first compare the response of the model with the experimental data.

[T,X,Y] = sim(model, time, [], [time iodata(:,1)]);
plot(time, iodata(:,2), T, Y, '--');
title('Simulated and Measured Responses before Estimation')
legend('Measured engine speed', 'Simulated engine speed');

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    1.59582e+008                     1.06e+006
     1          2    1.37036e+008             10      9.81e+005            0
     2          3    9.73586e+007             20      8.18e+005            0
     3          4    3.96227e+007             40      4.93e+005            0
     4          5    5.65115e+006        70.7572      2.88e-009            0

Local minimum found.

Optimization completed because the size of the gradient is less than
the selected value of the function tolerance.



Look at the Estimated Parameter Values

Let's also take a look at the estimated parameter values.

find(hEst.Parameters, 'Estimated', true)
(1) Parameter data for 'gain1':

       Parameter value : 124.4
         Initial guess : 100

             Estimated : true

          Referenced by:
(2) Parameter data for 'gain2':

       Parameter value : 24.59
         Initial guess : 0

             Estimated : true

          Referenced by:
(3) Parameter data for 'gain3':

       Parameter value : 20.44
         Initial guess : 0

             Estimated : true

          Referenced by:
(4) Parameter data for 'mean_speed':

       Parameter value : 730.4
         Initial guess : 600

             Estimated : true

          Referenced by:

Compare Simulation vs. Experiment After Estimation

Now that we have estimated the model parameters, we can compare the simulation outputs against the experimental data.

[T,X,Y] = sim(model, time, [], [time iodata(:,1)]);
plot(time, iodata(:,2), T, Y, '--');
title('Simulated and Measured Responses after Estimation')
legend('Measured engine speed', 'Simulated engine speed');
Contact sales
Free technical kit
Trial software
E-mail this page

Get Pricing and
Licensing Options