estimate constrained values of a lookup table
objectives
this example shows how to estimate constrained values of a lookup table in the parameter estimator. apply monotonically increasing constraints to the lookup table output values, and use the parameter estimator to estimate the table values.
about the data
in this example, use lookup_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 the lookup_increasing
simulink® 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.
lookup table output
view the table output values by double-clicking the lookup table block.
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, see .
the table data field shows that the table output values are the
cumulative sum of the values stored in variable ydelta
. thus, if
yn
are the 11 table output values, ydelta
is
(y1,
y2–y1,
y3–y2,
...,
y11–y10
).
the initial ydelta
values are loaded from
lookup_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, estimate ydelta
in the parameter estimator
using the measured i/o estimation data, and constrain ydelta(2:end)
to be
positive during estimation.
estimate the monotonically increasing table values using default settings
open a parameter estimation session.
in the simulink model, select parameter estimator from the apps tab, in the gallery, under control systems to open a session with the name lookup_increasing in the parameter estimator.
create an experiment and import the i/o data.
on the parameter estimation tab, click new experiment. type
[time1,ydata1]
in outputs and[time1,xdata1]
in inputs of the edit experiment dialog box. click ok. a new experiment with nameexp
is created in the experiments area of the app. rename the experimentestimationdata
by right-clicking the default experiment name,exp
, and selectingrename
. for more information, see .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') figure(1); plot(xdata1,ydata1,'m*',xout,yout,'b^') hold on; 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.
select parameter for estimation.
on the parameter estimation tab, click select parameters. the edit: estimated parameters dialog box opens. in the parameters tuned for all experiments panel, click select parameters to open the select model variables dialog box. check the box next to
ydelta
, and click ok.the
ydelta
values are selected for estimation by default in the edit: estimated parameters dialog box.apply a monotonically increasing constraint on the table output values. for more details about the table, see lookup table output.
in the edit: estimated parameters dialog box, click the arrow next to the
ydelta
values. in the expanded menu, set minimumydelta
values to[-inf,zeros(1,10)]
. thus, while the first value inydelta
can by anything, subsequent values which are the difference between adjacent table output values, must be positive.select
estimationdata
experiment for estimation.on the parameter estimation tab, click select experiment. by default,
estimationdata
is selected for estimation. if not, check the box under the estimation column, and click ok.estimate the table values using default settings.
on the parameter estimation tab, click estimate.
the parameter trajectory plot 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 the results area of the app. to view the estimated parameters, right-clickestimatedparams
and select open.the estimated
ydelta(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 in estimate 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
create an experiment to use for validation and import the validation i/o data.
on the parameter estimation tab, click new experiment. type
[time2,ydata2]
in outputs and[time2,xdata2]
in inputs of the edit experiment dialog box. name the experimentvalidationdata
by right-clicking the default experiment name,exp
, in the experiments area of the app, and selectingrename
. for more information, see .select the experiment for validation.
click select experiments on the parameter estimation tab. the
validationdata
experiment is selected for estimation by default. clear estimation and select the box for validation.select the results to validate.
on the validation tab, click select results to validate. clear
use current parameter values
, selectestimatedparams
, and click ok.select the plots to display during validation.
the parameter estimator displays the experiment plot after validation by default. add the residuals plot by selecting the corresponding box on the validation tab.
click validate.
examine the plots.
the experiment plot shows the data simulated using estimated parameters agrees with the measured validation data.
to view the residuals plot, click residual plot: validationdata tab.
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.
plot and examine the validation data, simulated data, and estimated table values.
sim('lookup_increasing') figure(2); plot(xdata2,ydata2,'m*',xout,yout,'b^') hold on; 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.