Main Content

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:

y(m)=f(y(m-1),y,u(l),u).

Here, f(.) is an unknown nonlinear function, y is the plant output, u is the plant input, m is the m-th order derivative of plant output, and l 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:

y(n)=F(t)+α*u(t),

Here,

  • n[1,2] is the order of ULM model. In practice, a first or second order ULM model is sufficient to describe the plant local behavior.

  • F(t)Rsubsumes unmodeled dynamics and/or external disturbances. Therefore, F(t)must be continuously updated at runtime to approximate the local plant behavior.

  • αR is the input gain and is chosen such that the three quantities y(n), F(t), and α*u(t) 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 F(t)that captures local uncertainties and disturbances. The ULM block can identify F(t) 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 F(t) for a first-order ULM model.

Ground Truth

For the sake of simplification, the true plant used in this tutorial is a linear system:

y˙=(t+3)+2u

Because the plant shares the same structure as the first-order ULM model, such as

  • Model order n = 1

  • Time-varying quantity F(t)=t+3

  • The input gain α=2

This example demonstrates ULM block does a good job estimating F(t).

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 Fˆ and yˆ, which is a one-step prediction of plant output yˆ(t+Ts). 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 Fˆ. 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 nm. In practice, using first or second order ULM model is often sufficient to approximate local behavior. In this tutorial, choose n=1 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 n=1 is sufficient. However, if the nominal control law is proportional-derivative (PD) or proportional-integral-derivative (PID), ULM model order of n=2 is required.

Input Gain (α)

A precise guess for input gain αis not strictly required for ULM to work. Generally speaking the choice of αR+ is required to approximately balance the three quantities y˙, F(t), and α*u(t) in their magnitude. Any mismatch between α and the true value in the plant is more or less captured by Fˆ.

In addition, the definition of αis the same as the critical gain b0used 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel Estimated Fhat contains 4 objects of type line, stair. These objects represent F (truth), alpha = 2, alpha = 1.5, alpha = 1.

% reset alpha to truth
set_param(ulm_block,'alpha','2');

As expected, the deviation of Fˆ from the true F increases when input gain αbecomes further away from the truth. The periodical fluctuation in Fˆcomes from (α-2)*u(t) as the excitation signal u(t) is a sine wave.

Estimator Sample Time (TS)

Estimator sample time TS is the sample time at which ULM updates estimation of Fˆ. 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 Fˆ 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 TS 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel Estimated Fhat contains 4 objects of type line, stair. These objects represent F (truth), Ts = 0.001, Ts = 0.01, Ts = 0.1.

% reset Ts
set_param(ulm_block,'Ts','0.01');

As expected, the deviation of Fˆ from the true F increases when Estimator sample time TS becomes slower.

Integration Window (steps)

Fˆ is estimated using an algebraic estimation algorithm. The algorithm collects the plant input and output signals during an integration window from time t-N*TS to current time t to compute Fˆ. N is the integration window that you can specify in the ULM block. The block requires parameter N3 to work properly. Generally, Ncannot be too small because a small N would reduce numerical integration accuracy as well as robustness toward the measurement noise. Ncannot be too large either because a large N uses more historical data that might prevent Fˆ from accurately reflecting the local plant behavior.

Examine the impact of the integration window steps N 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel Estimated Fhat contains 4 objects of type line, stair. These objects represent F (truth), N = 5, N = 20, N = 50.

% reset N
set_param(ulm_block,'numIntegrationSteps','20');

As expected, N=20 gives the best estimation result as it balances between numerical accuracy and local behavior.

One-Step Prediction

In addition to Fˆ, ULM block also produces yˆ, the one-step prediction of plant output y at time t+TS based on the estimated Fˆ. You can enable the optional outport yhat in the ULM block using the Output estimated yhat option in the block parameters. Typically, yˆ is helpful in one of the following two ways.

Use yˆ to Check Accuracy of Fˆ

By comparing yˆ with measuredy, you can tell how well Fˆ is estimated by the ULM block. This is very useful because you usually don't know the ground truth of F in practice.

Examine the impact of the integration window steps N on the estimation results by looking at yˆ.

% 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel One-Step Estimation (yhat) contains 4 objects of type line, stair. These objects represent y (truth), N = 5, N = 20, N = 50.

It is clear that N=20 produces the best prediction result among the three values as we already know from the previous analysis when ground truth of F is known.

Use yˆ for One-Step Prediction

Some control laws require one-step prediction and the yˆ 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 L0 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel One-Step Estimation (yhat) contains 4 objects of type line, stair. These objects represent y (truth), N = 5, N = 20, N = 50.

% 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 F(t) for a second-order ULM model.

Ground Truth

Consider a second-order linear system as follows:

y¨=(t+3)+2u

The plant shares the same structure as the first-order ULM model, such as

  • Model order n = 2

  • Time-varying quantity F(t)=t+3

  • The input gain α=2

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 α=2.

%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 Ts = 0.01 and N = 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 L0 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 FvsFˆ.

% 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel Estimated Fhat contains 2 objects of type line, stair. These objects represent F (truth), N = 85.

Plot the estimator output y  vsyˆ 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');

Figure contains an axes object. The axes object with xlabel Time(sec), ylabel One-Step Estimation (yhat) contains 2 objects of type line, stair. These objects represent y (truth), N = 100 & L = 5.

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.

See Also

Topics