Products & Services Solutions Academia Support User Community Company

Learn more about Simulink Design Optimization   

Configuring Parameter Estimation in the GUI

Creating an Estimation Task

This section describes how to use the GUI to estimate parameters. After you import the transient data, as described in Importing Data into the GUI, you must create an estimation task and configure the estimation settings. To create a container that stores the estimation settings:

  1. In the Control and Estimation Tools Manager, right-click the Estimation node in the workspace directory tree and select New.

  2. Select the New Estimation node.

    The Control and Estimation Tools Manager now resembles the next figure.

Specifying Data for Parameter Estimation

Prerequisite for Specifying Data

To specify a data set for estimation, you must have already imported the data in the GUI and created an Estimation Task, as described in Creating an Estimation Task. If your data contains noise or outliers, you must also preprocess the data, as described in Preprocessing Data in the GUI.

How to Specify Data in the GUI

After you select the New Estimation node, the Data Sets tab appears. Here you select the data set that you want to use in the estimation.

Select the Selected check box to the right of the New Data data set.

Then, specify the weight of each output from this model by setting the Weight column in the Output data weights table.

The relative weights are used to place more or less emphasis on specific output variables. The following are a few guidelines for specifying weights:

Specifying Parameters to Estimate

Choosing Which Parameters to Estimate First

Simulink Design Optimization software lets you estimate scalar, vector and matrix parameters. Estimating model parameters is an iterative process. Often, it is more practical to estimate a small group of parameters and use the final estimated values as a starting point for further estimation of parameters that are trickier. When you have a large number of parameters to estimate, select the parameters that influence the output the most to be estimated first. Making these sorts of choices involves experience, intuition, and a solid understanding of the strengths and limitations of your Simulink model.

After you estimate a subset of parameters and validate the estimated parameters, select the remaining parameters for estimation.

How to Specify Parameters for Estimation in the GUI

To select parameters for estimation:

  1. In the Control and Estimation Tools Manager, select the Variables node in the workspace directory tree to open the Estimated Parameters pane.

  2. In the Estimated Parameters pane, click Add to open the Select Parameters dialog box.

    The dialog box lists all the variables in the model workspace and the MATLAB workspace that the model uses. You can use the mouse to select the parameters to estimate.

    You can also enter parameters, separated by commas, in the Specify expression field of the Select Parameters dialog box. The parameters can be stored in one of the following:

    • Simulink software parameter object

      Example: For a Simulink parameter object k, type k.value.

    • Structure

      Example: For a structure S, type S.fieldname (where fieldname represents the name of the field that contains the parameter).

    • Cell array

      Example: Type C{1} to select the first element of the C cell array.

    • MATLAB array

      Example: Type a(1:2) to select the first column of a 2-by-2 array called a.

    Sometimes, models have parameters that are not explicitly defined in the model itself. For example, a gain k could be defined in the MATLAB workspace as k=a+b, where a and b are not defined in the model but k is used. To add these independent parameters to the Select Parameters dialog box, see Specifying Parameter Dependency.

  3. Select the last seven parameters: freq1, freq2, freq3, gain1, gain2, gain3, and mean_speed, and then click OK.

      Note   You need not estimate the parameters selected here all at once. You can first select all the parameters that you are interested in, and then later select the ones to estimate as described in the next step.

    The Control and Estimation Tools Manager now resembles the next figure.

    To learn how to specify the settings in the Default settings area of the pane, see Specifying Initial Guesses and Upper/Lower Bounds.

  4. In the New Estimation node of the Control and Estimation Tools Manager GUI, select the Parameters tab . In this pane, you select which parameters to estimate and the range of values for the estimation.

    1. Select the parameters you want to estimate by selecting the check box in the Estimate column.

    2. Enter initial values for your parameters in the Initial Guess column.

      The default values in the Minimum and Maximum columns are -Inf and +Inf, respectively, but you can select any range you want. For more information, see Specifying Initial Guesses and Upper/Lower Bounds.

        Note   When you specify the Minimum and Maximum values for the parameters here, it does not affect your settings in the Variables node. You make these choices on a per estimation basis. You can move data to and from the Variables node into the Estimation node.

    For this example, select gain1, gain2, gain3 and mean_speed for estimation and set gain1 to 10, gain2 to 100, gain3 to 50, and mean_speed to 500. Alternatively, use any initial values you like.

    If you have good reason to believe a parameter lies within a finite range, it is usually best not to use the default minimum and maximum values. Often, there are computational advantages in specifying finite bounds if you can. It can be very important to specify lower and upper bounds. For example, if a parameter specifies the weight of a part, be sure to specify 0 as the absolute lower bound if better knowledge is unavailable.

    The Control and Estimation Tools Manager now resembles the next figure.

Specifying Initial Guesses and Upper/Lower Bounds

After you select parameters for estimation in the Variables node of the Control and Estimation Tools Manager GUI, the Estimated Parameters tab in the Control and Estimation Tools Manager looks like the following figure.

For each parameter, use the Default settings pane to specify the following:

You use the typical value in two ways:

Specifying Parameter Dependency

Sometimes parameters in your model depend on independent parameters that do not appear in the model. The following steps give an overview of how to specify independent parameters for estimation:

  1. Add the independent parameters to the model workspace (along with initial values).

  2. Define a Simulation Start function that runs before each simulation of the model. This Simulation Start function defines the relationship between the dependent parameters in the model and the independent parameters in the model workspace.

  3. The independent parameters now appear in the Select Parameters dialog box. Add these parameters to the list of parameters to be estimated.

      Caution   Avoid adding independent parameters together with their corresponding dependent parameters to the lists of parameters to be estimated. Otherwise the estimation could give incorrect results. For example, when a parameter x depends on the parameters a and b, avoid adding all three parameters to the list.

For an example of how to specify independent parameters, see Example: Specifying Independent Parameters for Estimation.

Example: Specifying Independent Parameters for Estimation

Assume that the parameter Kint in the model srotut1 is related to the parameters x and y according to the relationship Kint=x+y. Also assume that the initial values of x and y are 1 and -0.7 respectively. To estimate x and y instead of Kint, first define these parameters in the model workspace. To do this:

  1. At the MATLAB prompt, type

    srotut1

    This opens the srotut1 model window.

  2. Select View > Model Explorer from the srotut1 window to open the Model Explorer window.

  3. In the Model Hierarchy tree, select the srotut1 > Model Workspace node.

  4. Select Add > MATLAB Variable to add a new variable to the model workspace. A new variable with a default name Var appears in the Contents of: Model Workspace pane.

  5. Double-click Var to make it editable and change the variable name to x. Edit the initial Value to 1.

  6. Repeat steps 4 and 5 to add a variable y with an initial value of -0.7. The Model Explorer window should resemble the following figure.

  7. To add the Simulation Start function defining the relationship between Kint and the independent parameters x and y, select File > Model Properties in the Simulink model for srotut1.

  8. In the Model Properties window, click the Callbacks tab.

  9. To enter a Simulation start function in StartFcn*, type the name of a new M-file, for example, srotut1_start.

  10. Create a new M-file with this name. The contents of the M-file should define the relationship between the parameters in the model and the parameters in the workspace. For this example, the M-file should resemble the following:

    wks = get_param(gcs, 'ModelWorkspace')
    x = wks.evalin('x')
    y = wks.evalin('y')
    Kint = x+y;
    

      Note   You must first use the get_param function to get the variables x and y from the model workspace before you can use them to define Kint.

  11. When you select parameters for estimation in the Variables node, x and y appear in the Select Parameters dialog box.

Specifying Initial States

When to Specify Initial States Versus Estimate Initial States

Often, sets of measured data are collected at various times and under different initial conditions. When you estimate model parameters using one data set and subsequently run another estimation with a second data set, your parameter values may not match. Given that the Simulink Design Optimization software attempts to find constant values for parameters, this is clearly a problem.

You can estimate the initial conditions using procedures that are similar to those you use to estimate parameters. You can then use these initial condition estimates as a basis for estimating parameters for your Simulink model. The Control and Estimation Tools Manager has an Estimated States pane that lists the states available for initial condition estimation. To learn how to estimate initial states, see Estimating Initial States.

How to Specify Initial States in the GUI

After you select parameters for estimation, as described in Specifying Parameters to Estimate, you can specify initial conditions of states in your model. By default, the estimation uses initial conditions specified in the Simulink model. If you want to specify initial conditions other than the defaults, use the State Data tab. You can select the State Data tab in the New Data node under the Transient Data node in the workspace directory tree.

To specify the initial condition of a state for the engine_idle_speed model:

  1. Select the Data cell associated with the state.

  2. Enter the initial conditions. In this example, enter -0.2 for State - 1 of the engine_idle_speed/Transfer Fcn. For State - 2, enter 0.

Selecting Views for Plotting

Types of Plots

You can choose the plot type from the Plot Type drop-down list. The following types of plots are available for viewing and evaluating the estimation:

Basic Steps for Creating Plots

Before you begin estimating the parameters, you must create the plots for viewing the progress of the estimation.

To create plots for viewing the estimation progress, follow the steps below:

  1. Right-click the Views node in the Control and Estimation Tools Manager and select New.

  2. In the workspace directory tree, select New View to open the View Setup pane.

  3. In the Select plot types table, select the Plot Type from the drop-down list. In this example, select Cost function.

  4. Select Measured and simulated as the Plot Type for Plot 2. This plot will be used in Performing Validation.

  5. In the Options area, select the check-box for both Plot 1 and Plot 2.

  6. Click Show Plots. This displays an empty cost function plot and a plot of the measured data.

When you perform the estimation, the plot updates automatically.

Specifying Estimation Options

Accessing Estimation Options

In the New Estimation node in the workspace directory tree, click the Estimation tab.

Click Estimation Options. This action opens the Options- New Estimation dialog box where you can specify the estimation method, algorithm options and cost function for the estimation.

The following sections describe the estimation method settings and cost function:

Supported Estimation Methods

Both the Method and Algorithm options define the optimization method. Use the Optimization method area of the Options dialog box to set the estimation method and its algorithm.

For the Method option, the four choices are:

The following table summarizes the Algorithm options for the Nonlinear least squares and Gradient descent estimation methods:

MethodAlgorithm OptionLearn More
Nonlinear least squares
  • Trust-Region-Reflective (default)

  • Levenberg-Marquardt

In the Optimization Toolbox documentation, see:
Gradient descent
  • Active-Set (default)

  • Interior-Point

  • Trust-Region-Reflective

In the Optimization Toolbox documentation, see:

Selecting Optimization Termination Options

Specify termination options in the Optimization options area.

Several options define when the optimization terminates:

By varying these parameters, you can force the optimization to continue searching for a solution or to continue searching for a more accurate solution.

Selecting Additional Optimization Options

At the bottom of the Optimization options pane is a group of additional optimization options.

Additional options for optimization include:

Specifying Goodness of Fit Criteria (Cost Function)

The cost function is a function that estimation methods attempt to minimize. You can specify the cost function at the bottom of the Optimization options area.

You have the following options when selecting a cost function:

How to Specify Estimation Options in the GUI

You can set several options to tune the results of the estimation. These options include the optimization methods and their tolerances.

To set options for estimation:

  1. Select the New Estimation node in the workspace directory tree.

  2. Click the Estimation tab.

  3. Click Estimation Options to open the Options dialog box.

  4. Click the Optimization Options tab and specify the options.

Specifying Simulation Options

Accessing Simulation Options

To optimize the response signals of a model, Simulink Design Optimization software runs simulations of the model.

To set options for simulation:

  1. Select the New Estimation node in the workspace directory tree.

  2. Click the Estimation tab.

  3. Click Estimation Options to open the Options dialog box.

  4. Click the Simulation Options tab and specify the options, as described in the following sections:

Selecting Simulation Time

You can specify the simulation start and stop times in the Simulation time area of the Simulation Options tab.

By default, Start time and Stop time are automatically computed based on the start and stop times specified in the Simulink model.

To set alternative start and stop times for the optimization, enter them under Simulation time. This action overwrites the simulation start and stop times specified in the Simulink model.

Simulation Time for Data Sets with Different Time Lengths.   Simulink Design Optimization software can simulate models containing empirical data sets of different time lengths. You can use experimental data sets for estimation that contain I/O samples collected at different time points.

The following example shows a single-input, two-output model for which you want to estimate the parameters.

The model uses two output data sets containing transient data samples for parameter estimation:

The simulation time t is computed as:

This new set ranges from tmin to tmax. The values tmin and tmax represent the minimum and maximum time points in t respectively.

When you run the estimation, the model is simulated over the time range t. Simulink extracts the simulated data for each output based on the following criteria:

Selecting Solvers

You can specify the solver in the Solver options area of the Simulation Options tab.

When running the simulation, the dynamic system is solved using one of several Simulink solvers. You can specify several solver options using the Solver options area in the Options dialog box. The Type of solver can be variable-step or fixed-step. Variable-step solvers keep the error within specified tolerances by adjusting the step-size the solver uses. Fixed-step solvers use a constant step-size. When your model's states are likely to vary rapidly, a variable-step solver is often faster. See the Simulink documentation for information about solvers.

Variable-Step Solvers.   When you select Variable-step as the solver Type, you can choose any of the following as the Solver:

Variable-Step Solver Options.   When you select Variable-step as the Simulink solver Type, you can also set several other parameters that affect the step-size of the simulation:

By default, the values for these options are automatically chosen. To choose your own values, enter them in the appropriate fields.

Fixed-Step Solvers.   When you select Fixed-step as the solver Type, you can choose any of the following as the Solver:

When you select Fixed-step as the solver Type, you can also set Fixed step size, which determines the step-size the solver uses during the simulation. By default, a value for this option is automatically chosen.

Specifying Display Options

You can specify the display options by clicking Display Options in the Estimation tab in the Control and Estimation tools Manager. This opens the following dialog box.

Clearing a check box implies that feature will not appear in the display table as the estimation progresses. To learn more about the display table, see Displaying Iterative Output in the Optimization Toolbox documentation.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS