Ultra-Local Model for System Identification and Output Prediction
This example show how to use the Ultra-Local Model (ULM) block in Simulink® for system identification and output prediction. The Ultra-Local Model block estimates a local linear control-affine model for a single-input single-output (SISO) plant at runtime. Popular applications of ULM include model-free control, where you augment a nominal controller with a ULM-based disturbance compensator, which is discussed in details in a separate example Intelligent PID using Ultra Local Model for Ball on Beam Balance. This example, however, serves as a tutorial on how ULM works and how to choose block parameters to obtain good identification and prediction results.
Ultra-Local Model Overview
The input-output behavior of a nonlinear SISO system is often described in the following generic form:
.
Here, is an unknown nonlinear function, is the plant output, is the plant input, is the m-th order derivative of plant output, and is the l-th order derivative of plant input.
The ULM method approximates the above plant using a simplified linear control-affine model as follows:
,
Here,
is the order of ULM model. In practice, a first or second order ULM model is sufficient to describe the plant local behavior.
subsumes unmodeled dynamics and/or external disturbances. Therefore, must be continuously updated at runtime to approximate the local plant behavior.
is the input gain and is chosen such that the three quantities , , and are of the same order of magnitude. is usually a constant and it does not have to be precise.
In other words, the ULM model approximates the local behavior of a nonlinear plant as a single or double integrator plus a time-varying quantity that captures local uncertainties and disturbances. The ULM block can identify from the plant input and output data online, using first-order or second order Algebraic Estimation methods (see Ultra-Local Model for Disturbance Estimation and Compensation).
Online Identification of First-Order Ultra-Local Model
This section shows how to use the ULM block to estimate for a first-order ULM model.
Ground Truth
For the sake of simplification, the true plant used in this tutorial is a linear system:
Because the plant shares the same structure as the first-order ULM model, such as
Model order n = 1
Time-varying quantity
The input gain
This example demonstrates ULM block does a good job estimating .
Connect Ultra-Local Model Block
To examine how the ULM block is connected to the plant for online identification, open the Simulink model ulmFirstOrder.slx
that estimates the first-order ULM.
mdl = 'ulmFirstOrder'; ulm_block = [mdl '/Ultra-Local Model']; open_system(mdl);
ULM block takes measured plant input and output signals as inputs and produces and , which is a one-step prediction of plant output . In this example, you use sine wave as input signal but it can be other types of excitation signals as well, such as step or random perturbation.
ULM Block Parameters
This section discusses some guidelines regarding how to tune the ULM block parameters and achieve good estimation of . There are four main design parameters: model order, input gain, estimator sample time, and integration window (steps).
Model Order (n)
Generally, the ULM model order can be less than or equal to the true plant order such that . In practice, using first or second order ULM model is often sufficient to approximate local behavior. In this tutorial, choose because the true plant order is 1.
In addition, when ULM is used as a part of model-free control structure to provide disturbance compensation, the choice of ULM model order also depends on choice of the nominal controller. For example, if the nominal control law is proportional-only (P) or proportional-integral (PI), ULM model order is sufficient. However, if the nominal control law is proportional-derivative (PD) or proportional-integral-derivative (PID), ULM model order of is required.
Input Gain ()
A precise guess for input gain is not strictly required for ULM to work. Generally speaking the choice of is required to approximately balance the three quantities , , and in their magnitude. Any mismatch between and the true value in the plant is more or less captured by .
In addition, the definition of is the same as the critical gain used in the Active Disturbance Rejection Control (ADRC) block. For recommendations how to obtain good initial guess of this parameter, see Ultra-Local Model for Disturbance Estimation and Compensation.
Examine the impact of input gain on the estimation results.
% Set the "alpha" parameter the same as the ground truth value set_param(ulm_block,'alpha','2'); % simulate out1 = sim(mdl); % Set the "alpha" parameter with a small difference from the truth set_param(ulm_block,'alpha','1.5'); % simulate out2 = sim(mdl); % Set the "alpha" parameter with a large difference from the truth set_param(ulm_block,'alpha','1'); % simulate out3 = sim(mdl); % plot ground truth figure; hold on; grid on plot(out1.F); % plot estimated Fhat plot(out1.Fhat); plot(out2.Fhat); plot(out3.Fhat); % legend xlabel('Time(sec)') ylabel('Estimated Fhat') legend({'F (truth)','alpha = 2','alpha = 1.5','alpha = 1'},'Location','southeast');
% reset alpha to truth set_param(ulm_block,'alpha','2');
As expected, the deviation of from the true increases when input gain becomes further away from the truth. The periodical fluctuation in comes from as the excitation signal is a sine wave.
Estimator Sample Time ()
Estimator sample time is the sample time at which ULM updates estimation of . Faster sample time means that the collected run-time data used for estimation are closer to the local operating condition, which in turn improves estimation accuracy. Since from ULM is often used as part of control law, ULM only needs to run as fast as the controller demands.
Examine the impact of the estimator sample time on the estimation results.
% Set fast sample time set_param(ulm_block,'Ts','0.001'); % simulate out1 = sim(mdl); % Set medium sample time set_param(ulm_block,'Ts','0.01'); % simulate out2 = sim(mdl); % Set slow sample time set_param(ulm_block,'Ts','0.1'); % simulate out3 = sim(mdl); % plot ground truth figure; hold on grid on plot(out1.F); % plot estimated Fhat plot(out1.Fhat); plot(out2.Fhat); plot(out3.Fhat); % legend xlabel('Time(sec)') ylabel('Estimated Fhat') legend({'F (truth)','Ts = 0.001','Ts = 0.01','Ts = 0.1'},'Location','southeast');
% reset Ts set_param(ulm_block,'Ts','0.01');
As expected, the deviation of from the true increases when Estimator sample time becomes slower.
Integration Window (steps)
is estimated using an algebraic estimation algorithm. The algorithm collects the plant input and output signals during an integration window from time to current time to compute . is the integration window that you can specify in the ULM block. The block requires parameter to work properly. Generally, cannot be too small because a small would reduce numerical integration accuracy as well as robustness toward the measurement noise. cannot be too large either because a large uses more historical data that might prevent from accurately reflecting the local plant behavior.
Examine the impact of the integration window steps on the estimation results.
% Set a small integration window set_param(ulm_block,'numIntegrationSteps','5'); % simulate out1 = sim(mdl); % Set a medium integration window set_param(ulm_block,'numIntegrationSteps','20'); % simulate out2 = sim(mdl); % Set a large integration window set_param(ulm_block,'numIntegrationSteps','50'); % simulate out3 = sim(mdl); % plot ground truth figure hold on grid on plot(out1.F); % plot estimated Fhat plot(out1.Fhat); plot(out2.Fhat); plot(out3.Fhat); % legend xlabel('Time(sec)') ylabel('Estimated Fhat') legend({'F (truth)','N = 5','N = 20','N = 50'},'Location','southeast');
% reset N set_param(ulm_block,'numIntegrationSteps','20');
As expected, gives the best estimation result as it balances between numerical accuracy and local behavior.
One-Step Prediction
In addition to , ULM block also produces , the one-step prediction of plant output at time based on the estimated . You can enable the optional outport yhat in the ULM block using the Output estimated yhat option in the block parameters. Typically, is helpful in one of the following two ways.
Use to Check Accuracy of
By comparing with measured, you can tell how well is estimated by the ULM block. This is very useful because you usually don't know the ground truth of in practice.
Examine the impact of the integration window steps on the estimation results by looking at .
% plot ground truth figure();hold on;grid on plot(out1.y); % plot estimated Fhat plot(out1.yhat); plot(out2.yhat); plot(out3.yhat); % legend xlabel('Time(sec)') ylabel('One-Step Estimation (yhat)') legend({'y (truth)','N = 5','N = 20','N = 50'},'Location','southeast');
It is clear that produces the best prediction result among the three values as we already know from the previous analysis when ground truth of is known.
Use for One-Step Prediction
Some control laws require one-step prediction and the port in the ULM block can provide such information. To predict it accurately, however, you need to enable the Luenberger observer by specifying the observer gain in the ULM block dialog.
% enable Luenberger observer by specifying observer gain L set_param(ulm_block,'ObsvGain','5'); % Set a small integration window set_param(ulm_block,'numIntegrationSteps','5'); % simulate out1 = sim(mdl); % Set a medium integration window set_param(ulm_block,'numIntegrationSteps','20'); % simulate out2 = sim(mdl); % Set a large integration window set_param(ulm_block,'numIntegrationSteps','50'); % simulate out3 = sim(mdl); % plot ground truth figure();hold on;grid on plot(out1.y); % plot estimated Fhat plot(out1.yhat); plot(out2.yhat); plot(out3.yhat); % legend xlabel('Time(sec)') ylabel('One-Step Estimation (yhat)') legend({'y (truth)','N = 5','N = 20','N = 50'},'Location','southeast');
% reset N set_param(ulm_block,'numIntegrationSteps','20');
Compared to the previous plot, the the Luenberger observer improves one-step prediction in all the three cases.
% Close the model
close_system(mdl,0);
Online Identification of Second-Order Ultra-Local Model
This section shows how to use ULM block to estimate for a second-order ULM model.
Ground Truth
Consider a second-order linear system as follows:
The plant shares the same structure as the first-order ULM model, such as
Model order n = 2
Time-varying quantity
The input gain
Simulation and Results
To tune the parameters, you can use the recommendations from the preceding sections. Open the Simulink model that estimates the second-order ULM.
mdl = 'ulmSecondOrder'; ulm_block = [mdl '/Ultra-Local Model']; open_system(mdl);
The ideal value for input-gain is .
%set the parameter alpha to true value set_param(ulm_block,'alpha','2');
Model order second-order ULM case is known and set to 2. The best performing sample time and integration window is = 0.01 and = 85.
% Set medium sample time set_param(ulm_block,'Ts','0.01'); % Set a small integration window set_param(ulm_block,'numIntegrationSteps','85');
Similar to first-order case, you can use the ULM block as one step predictor for second-order case. Enable the Luenberger observer and specify the observer gain in the ULM block parameters.
% enable Luenberger observer by specifying observer gain L set_param(ulm_block,'ObsvGain','5');
With all parameters defined, simulate the model and plot the results.
% simulate
out = sim(mdl);
Plot ULM model estimate .
% plot ground truth figure();hold on;grid on plot(out.F); % plot estimated Fhat plot(out.Fhat); % legend xlabel('Time(sec)') ylabel('Estimated Fhat') legend({'F (truth)','N = 85'},'Location','southeast');
Plot the estimator output for second-order case.
% plot ground truth figure();hold on;grid on plot(out.y); % plot estimated yhat plot(out.yhat); % legend xlabel('Time(sec)') ylabel('One-Step Estimation (yhat)') legend({'y (truth)','N = 100 & L = 5'},'Location','southeast');
Similar to first-order case, the Luenberger observer improves one-step prediction.
% Close the model
close_system(mdl,0);
References
[1] Fliess, Michel, and Cédric Join. "Model-free control." International journal of control 86.12 (2013): 2228-2252.