## LTV and LPV Modeling

### Types of LTV and LPV Models

There are two main categories of linear time-varying (LTV) and linear parameter-varying (LPV) models:

Technically, gridded models are a particular type of analytic models where the data function is data driven rather than formula driven. Conceptually, however, the two types of model have different origins and correspond to different modeling workflows and approximation strategies.

Quasi-LPV models are LPV models where the scheduling map or parameter trajectory p(t) is endogenous rather than exogenous, that is, depends on the state x and input u of the model. This creates a feedback loop between the LPV model and the scheduling map.

The lpvss object cannot represent an entire quasi-LPV model with its scheduling map. However, you can simulate the response of quasi-LPV models by specifying the scheduling function $p\left(t\right)=h\left(t,x,u\right)$ as the parameter trajectory. Quasi-LPV models can represent virtually any nonlinear system but do not turn nonlinear systems into linear ones. Moving nonlinearities into the scheduling map can create instabilities and hide difficulties when not done carefully (see Hidden Couplings in Gain-Scheduled Control). These difficulties generally do not arise, however, when p(t) changes slowly compared to the dominant system dynamics (see the Gain-Scheduled LQG Controller example for an illustration). Examples involving quasi-LPV simulations include: LPV Model of Magnetic Levitation System, LPV Model of Bouncing Ball, LPV Model of Engine Throttle, Design and Validate Gain-Scheduled Controller for Nonlinear Aircraft Pitch Dynamics, and Control Design for Wind Turbine.

### Limitations of LPV Models

LPV approximations are most useful for systems whose behavior is nearly linear on a short time scale but nonlinear or time-varying on a longer time horizon. They tend to be less useful for systems with fast, highly nonlinear dynamics. Quasi-LPV models are most useful when the dynamics of the scheduling feedback loop are slow or benign, and least useful when these dynamics dominate those of the LPV model itself (or of any gain-scheduled control loop based on the LPV model alone).

Gridded LPV models based on linearized dynamics cannot represent hard nonlinearities such as saturations and dead zones (see Hidden Couplings in Gain-Scheduled Control for an example). They can nevertheless be coupled with static nonlinearities to recover such behaviors.

### Offsets and Initial Conditions

Offsets are an important part of LTV and LPV models. The linearization of the nonlinear model

$\begin{array}{cc}\stackrel{˙}{x}=f\left(x,u\right),& y=g\left(x,u\right)\end{array}$

around an operating point (x0,u0) is

$\begin{array}{c}\stackrel{˙}{x}=\underset{{\delta }_{0}}{\underbrace{f\left({x}_{0},{u}_{0}\right)}}+A\left(x-{x}_{0}\right)+B\left(u-{u}_{0}\right)\\ y=\underset{{y}_{0}}{\underbrace{g\left({x}_{0},{u}_{0}\right)}}+C\left(x-{x}_{0}\right)+D\left(u-{u}_{0}\right),\end{array}$

where

$\begin{array}{cccc}A=\frac{\partial f}{\partial x}\left({x}_{0},{u}_{0}\right),& B=\frac{\partial f}{\partial u}\left({x}_{0},{u}_{0}\right),& C=\frac{\partial g}{\partial x}\left({x}_{0},{u}_{0}\right),& D=\frac{\partial g}{\partial u}\left({x}_{0},{u}_{0}\right).\end{array}$

For the linearization to be a good approximation of the nonlinear maps, it must include the offsets δ0, x0, u0, and y0. The linearize (Simulink Control Design) command returns both A, B, C, D and the offsets when using the StoreOffset option. This is the basis for constructing most gridded LTV and LPV models. The ltvss and lpvss objects automatically manage and propagate offset through interconnection operations (feedback, connect, seriesparallel, lft) and transformations such as c2d, d2c, and d2d.

Offsets and initial conditions matter for time response simulation. To obtain correct results and good approximations of the nonlinear behavior, it is important to:

1. Consider whether the input signal or step change is absolute or relative to the offset u0.

2. Correctly initialize the state vector. When the operating conditions (x0,u0) are equilibrium conditions, initializing the state vector to x0 and applying a step change relative to u0 ensures the simulation starts from the steady state (x0,u0) and approximates the nonlinear behavior around this condition. Use RespConfig to specify these values in step. See Design and Validate Gain-Scheduled Controller for Nonlinear Aircraft Pitch Dynamics, LPV Model of Bouncing Ball, LPV Approximation of Boost Converter Model, LTV Model of Two-Link Robot, and LPV Model of Engine Throttle for examples.

3. Specify the parameter trajectory, either explicitly for exogenous parameters (see LPV Approximation of Boost Converter Model, Control Design for Spinning Disks, Analysis of Gain-Scheduled PI Controller, and Gain-Scheduled LQG Controller), or implicitly as a function of t, x, u for quasi-LPV simulations (see LPV Model of Bouncing Ball, LPV Model of Engine Throttle, Design and Validate Gain-Scheduled Controller for Nonlinear Aircraft Pitch Dynamics, and Control Design for Wind Turbine). For a critical comparison of these two approaches, see LPV Model of Magnetic Levitation System and Hidden Couplings in Gain-Scheduled Control.

### Incremental Form of LTV and LPV Models

When linearizing along a trajectory (x0(t),u0(t),y0(t)) satisfying the nonlinear equations

$\begin{array}{cc}{\stackrel{˙}{x}}_{0}\left(t\right)=f\left({x}_{0}\left(t\right),{u}_{0}\left(t\right)\right),& {y}_{0}\left(t\right)=g\left({x}_{0}\left(t\right),{u}_{0}\left(t\right)\right),\end{array}$

the linearized model can be expressed as

$\begin{array}{cc}{\stackrel{˙}{\delta }}_{x}=A\left(t\right){\delta }_{x}+B\left(t\right){\delta }_{u},& {\delta }_{y}=C\left(t\right){\delta }_{x}+D\left(t\right){\delta }_{u},\end{array}$

where

$\begin{array}{ccc}{\delta }_{x}=x-{x}_{0},& {\delta }_{u}=u-{u}_{0},& {\delta }_{y}=y-{y}_{0}\end{array}$

are the deviations from the reference trajectory. See the LTV Model of Two-Link Robot example for an illustration.

This incremental or delta form looks simpler than the linearized form used for ltvss and lpvss. However, it is not a valid representation of LPV models in general. Consider, for example, an LPV model constructed from a family of steady-state operating conditions (x0(p),u0(p),y0(p)) satisfying for all p:

$\begin{array}{cc}0=f\left({x}_{0}\left(p\right),{u}_{0}\left(p\right)\right),& {y}_{0}\left(p\right)=g\left({x}_{0}\left(p\right),{u}_{0}\left(p\right)\right).\end{array}$

For fixed p, you can write the linearized dynamics around (x0(p),u0(p),y0(p)) as

$\begin{array}{cc}{\stackrel{˙}{\delta }}_{x}=A\left(p\right){\delta }_{x}+B\left(p\right){\delta }_{u},& {\delta }_{y}=C\left(p\right){\delta }_{x}+D\left(p\right){\delta }_{u},\end{array}$

with

$\begin{array}{ccc}{\delta }_{x}=x-{x}_{0}\left(p\right),& {\delta }_{u}=u-{u}_{0}\left(p\right),& {\delta }_{y}=y-{y}_{0}\left(p\right).\end{array}$

This is no longer correct when p varies with time, that is, for an LPV trajectory that takes the system from one steady-state condition to another. In this case, you have:

$\begin{array}{c}{\stackrel{˙}{\delta }}_{x}=\stackrel{˙}{x}-\frac{d}{dt}{x}_{0}\left(p\left(t\right)\right)\\ \approx \underset{=0}{\underbrace{f\left({x}_{0}\left(p\right),{u}_{0}\left(p\right)\right)}}+A\left(p\right){\delta }_{x}+B\left(p\right){\delta }_{u}-\frac{d}{dt}{x}_{0}\left(p\left(t\right)\right)\\ =A\left(p\right){\delta }_{x}+B\left(p\right){\delta }_{u}-\frac{\partial {x}_{0}}{\partial p}\stackrel{˙}{p}.\end{array}$

The incremental form now has an extra term involving the time derivative of x0(p(t)), a quantity that is not readily available. This is why the linearized form is preferred.

### State Consistency and State Transformation

When constructing LPV models from arrays of state-space models, ensure that the models are expressed in consistent state coordinates. For example, reordering the states for some models but not others creates state inconsistencies that invalidate the interpolated LPV model. In general, fixed state transformations preserve state consistency, while independent state transformations such as modal decompositions of individual models do not.

This does not mean that time-varying or parameter-varying transformations are disallowed. Given the LTV model

$\begin{array}{cc}\stackrel{˙}{x}=A\left(t\right)x+B\left(t\right)u,& y=C\left(t\right)x+D\left(t\right)u,\end{array}$

the time-varying state transformation x = T(t)z produces the equivalent model

$\begin{array}{l}\stackrel{˙}{z}=T{\left(}^{t}\left(A\left(t\right)T\left(t\right)-\frac{dT}{dt}\right)z+T{\left(}^{t}B\left(t\right)u\\ y=C\left(t\right)T\left(t\right)z+D\left(t\right)u.\end{array}$

However, the extra term $\frac{dT}{dt}$ explains why independent state transformations are problematic. If T(t) changes abruptly between time samples tk, the transformed model has an additional term $T{\left(t\right)}^{-1}\frac{dT}{dt}z$ that can be large and is not accounted for when transforming each model individually using Tk = T(tk):

$\begin{array}{cc}\stackrel{˙}{z}={T}_{k}{}^{-1}{A}_{k}{T}_{k}z+{T}_{k}{B}_{k}u,& y={C}_{k}{T}_{k}+{D}_{k}u.\end{array}$

In general, a varying state transformation is fine only when it varies slowly with time or parameters and the term $T{\left(t\right)}^{-1}\frac{dT}{dt}z$ can be neglected.

### Gridded Models and Choice of Sampling Grid

A common way of representing LPV models is as an interpolated array of linear state-space models. For example, the aerodynamic behavior of an aircraft (see Design and Validate Gain-Scheduled Controller for Nonlinear Aircraft Pitch Dynamics) is often scheduled over a grid of incidence angle (α) and wind speed (V) values. For each scheduling parameter, a range of values is chosen, such as α = -20:5:20 degrees, V = 700:100:1400 m/s. For each combination of (α,V) values, a linear approximation of the aircraft behavior is obtained. The local models are connected as shown in this figure.

Each point represents a local LTI model, and the connecting curves represent the interpolation rules. The abscissa and ordinate of the surface are the scheduling parameters (α,V).

When using gridded LTV or LPV models to approximate nonlinear dynamics, you must determine what grid density to use and how to best distribute the grid points. The denser the grid, the more accurate the approximation, but also the more memory needed to store the matrices and offsets at all grid points. To reduce memory usage, you can prune the grid while keeping an eye on the accuracy of the LPV approximation for representative use cases (simulations for specific parameter trajectories).

You can start with a dense grid for which the LPV approximation has the desired accuracy. Using sample, you can then sample the LPV dynamics and look for parameter ranges where the local LTI dynamics do not change much. Using ssInterpolant, you can also try various grid densities and observe how the LPV model fidelity deteriorates. Finally, structural information can guide this process. For example, if the matrices and offsets depend linearly on some parameters, the two extreme values of this parameter are enough to capture parameter variations over an entire interval (assuming linear interpolation). By contrast, the more nonlinear the parameter dependence is, the more grid points are needed.

For gain-scheduled control design, it is customary to use a coarser grid for the controller than for the LPV plant model. Mismatched grids are seamlessly handled by the software. See Design and Validate Gain-Scheduled Controller for Nonlinear Aircraft Pitch Dynamics, LPV Model of Magnetic Levitation Model from Batch Linearization Results, and Control Design for Wind Turbine for examples of this practice.

### Optimizing LPV Models for Fast Simulation and Code Generation

LPV models can provide low-complexity approximations of high-fidelity models that support fast simulation and code generation. When the original model is a high-fidelity nonlinear model, batch linearization over a dense grid of operating conditions provides the raw material for building a gridded LPV approximation. When the original model is an analytic LPV model, it can be turned into a gridded LPV model using ssInterpolant. Using ssInterpolant, you can then resample the gridded LPV model to reduce memory usage as indicated above. Finally, the gridded LPV model can be discretized with c2d, since discrete-time models tend to simulate faster and be more amenable to code generation and deployment. See LTV Model of Two-Link Robot and LPV Approximation of Boost Converter Model for examples.

### Other Considerations

LTV and LPV models do not commute even in the SISO case. In a gain-scheduled PI controller, for example, placing the gain-scheduled integral gain before or after the integrator is not the same, as illustrated in the Analysis of Gain-Scheduled PI Controller example.