Main Content

Estimate Constrained Values of a Lookup Table

Objectives

This example shows how to estimate constrained values of a lookup table in theParameter Estimator. Apply monotonically increasing constraints to the lookup table output values, and use theParameter Estimatorto estimate the table values.

About the Data

In this example, uselookup_increasing.mat, which contains the measured I/O data for estimating the lookup table values. The MAT-file includes the following variables:

  • xdata1— Input data consisting of 602 uniformly sampled data points in the range[-5,5].

  • ydata1— Output data corresponding to the input data samples.

  • time1— Time vector.

Use the I/O data to estimate monotonically increasing output values of the lookup table in thelookup_increasing金宝app®model.

Lookup Table Increasing Constraints Models

Open the lookup table model.

open_system('lookup_increasing.slx')

This command opens the Simulink® model, and loads the estimation data in the MATLAB® workspace.

lut_incr_model.png

Lookup Table Output

View the table output values by double-clicking theLookup Tableblock.

The table contains 11 output values at breakpoints[-5:5], specified in the Function Block Parameters dialog box. To learn more about how to specify the table values, seeEnter Breakpoints and Table Data.

TheTable datafield shows that the table output values are the cumulative sum of the values stored in variableydelta. Thus, ifynare the 11 table output values,ydeltais (y1,y2y1,y3y2, ...,y11y10). The initialydeltavalues are loaded fromlookup_increasing.mat.

The initial table output values are not monotonically increasing. To ensure monotonically increasing table output values, the difference between adjacent table output values should be positive. To do so, estimateydeltain theParameter Estimatorusing the measured I/O estimation data, and constrainydelta(2:end)to be positive during estimation.

Estimate the Monotonically Increasing Table Values Using Default Settings

  1. Open a parameter estimation session.

    In the Simulink model, selectParameter Estimatorfrom theAppstab, in the gallery, underControl Systemsto open a session with the namelookup_increasingin theParameter Estimator.

  2. Create an experiment and import the I/O data.

    On theParameter Estimationtab, clickNew Experiment. Type[time1,ydata1]inOutputsand[time1,xdata1]inInputsof the Edit Experiment dialog box. ClickOK. A new experiment with nameExpis created in theExperimentsarea of the app. Rename the experimentEstimationDataby right-clicking the default experiment name,Exp, and selectingRename. For more information, seeImport Data for Parameter Estimation.

  3. Run an initial simulation to view the measured data, simulated model values, and the initial table values by typing the following commands at the MATLAB®prompt.

    sim('lookup_increasing'图(1);plot(xdata1,ydata1,'m*',xout,yout,'b^') holdon; plot(-5:5,cumsum(ydelta),'k','LineWidth',2) xlabel('Input Data'); ylabel('Output Data'); legend('Measured data','Initial simulated data','Initial table output')

    The initial table output values and simulated data do not match the measured data.

  4. Select parameter for estimation.

    On theParameter Estimationtab, click选择Parameters. The Edit: Estimated Parameters dialog box opens. In theParameters Tuned for all Experimentspanel, clickSelect parametersto open the Select Model Variables dialog box. Check the box next toydelta, and clickOK.

    Theydeltavalues are selected for estimation by default in the Edit: Estimated Parameters dialog box.

  5. Apply a monotonically increasing constraint on the table output values. For more details about the table, seeLookup Table Output.

    In the Edit: Estimated Parameters dialog box, click the arrow next to theydeltavalues. In the expanded menu, setMinimumydeltavalues to[-Inf,zeros(1,10)]. Thus, while the first value inydeltacan by anything, subsequent values which are the difference between adjacent table output values, must be positive.

  6. SelectEstimationDataexperiment for estimation.

    On theParameter Estimationtab, clickSelect Experiment. By default,EstimationDatais selected for estimation. If not, check the box under theEstimationcolumn, and clickOK.

  7. Estimate the table values using default settings.

    On theParameter Estimationtab, clickEstimate.

    TheParameter Trajectoryplot shows the change in the parameter values at each iteration.

    The Estimation Progress Report shows the iteration number, number of times the objective function is evaluated, and value of the cost function at the end of each iteration.

    The estimated parameters are saved in a new variable,EstimatedParams, in theResultsarea of the app. To view the estimated parameters, right-clickEstimatedParamsand selectOpen.

    The estimatedydelta(2:end)values are positive. Thus, the output of the table, which is the cumulative sum of the values stored inydelta, is monotonically increasing.

Validate the Estimation Results

After you estimate the table values, as described inEstimate the Monotonically Increasing Table Values Using Default Settings, you use another measured data set to validate and check that you have not over-fit the model. You can plot and examine the following plots to validate the estimation results:

  • Residuals plot

  • Measured and simulated data plots

  1. Create an experiment to use for validation and import the validation I/O data.

    On theParameter Estimationtab, clickNew Experiment. Type[time2,ydata2]inOutputsand[time2,xdata2]inInputsof the Edit Experiment dialog box. Name the experimentValidationDataby right-clicking the default experiment name,Exp, in theExperimentsarea of the app, and selectingRename. For more information, seeImport Data for Parameter Estimation.

  2. Select the experiment for validation.

    ClickSelect Experimentson theParameter Estimationtab. TheValidationDataexperiment is selected for estimation by default. ClearEstimationand select the box forValidation.

  3. Select the results to validate.

    On theValidationtab, clickSelect Results to Validate. ClearUse current parameter values, selectEstimatedParams, and clickOK.

  4. Select the plots to display during validation.

    TheParameter Estimatordisplays the experiment plot after validation by default. Add the residuals plot by selecting the corresponding box on theValidationtab.

    ClickValidate.

  5. Examine the plots.

    1. The experiment plot shows the data simulated using estimated parameters agrees with the measured validation data.

    2. To view the residuals plot, clickResidual plot: ValidationDatatab.

      The residuals, which show the difference between the simulated and measured data, lie within 15% of the maximum output variation. This indicates a good match between the measured and simulated table data values.

    3. Plot and examine the validation data, simulated data, and estimated table values.

      sim('lookup_increasing') figure(2); plot(xdata2,ydata2,'m*',xout,yout,'b^') holdon; plot(-5:5,cumsum(ydelta),'k','LineWidth', 2) xlabel('Input Data'); ylabel('Output Data'); legend('Validation data','Simulated data','Table output values');

      The table output values match both the measured data and the simulated table values. The table output values cover the entire range of input values, which indicates that all the lookup table values have been estimated.

Related Topics