# Core concepts

To facilitate the modeling of LPV systems, LPVcore introduces a set of fundamental classes:

- A
`timemap`

object to represent the*extended scheduling signal*. - A
`pbasis`

parent object to represent scalar*scheduling dependent basis functions*. - A
`pmatrix`

object to represent*scheduling dependent matrix functions*. - A
`lpvrep`

parent object to represent different types of*linear parameter-varying system representations*.

On this page, each class is treated in more detail.

`timemap`

: extended scheduling signal

LPV systems exhibit input-output dynamics that are linear, but whose relation is perturbed by an auxiliary time signal called the scheduling signal. The scheduling signal, denoted here by $p(t) \in \mathbb{P} \subseteq \mathbb{R}^{n_p}$, often represents a physical quantity $p$, such as position or temperature, as a function of time $t$. LPV systems can be formulated both in continuous-time (CT) and discrete-time (DT), in which case $t$ assumes values in $\mathbb{R}$ or $\mathbb{Z}$, respectively.

Sometimes, the LPV system also depends on derivatives (CT) or time-shifted (DT) versions of the scheduling signal. For example, when both the position and velocity of a certain point are considered. Since the velocity is related to the position by differentiation, the position can be seen as the scheduling signal, while the velocity can be seen as an *extension* of this scheduling signal. The position and velocity are together collected in the *extended scheduling signal*, denoted by $\rho$. The extended scheduling signal consists of the scheduling signal itself and all derivatives (CT) and time-shifted (DT) versions that are part of the parameter-varying dynamics.

For example, consider a DT extended scheduling signal that consists of the first $N$ forward- and backward-shifted version of $p$:

$\rho(t) := [ p(t)^{\mathrm{T}}, p(t-1)^{\mathrm{T}}, p(t+1)^{\mathrm{T}}, ..., p(t-N)^{\mathrm{T}}, p(t+N)^{\mathrm{T}} ]^{\mathrm{T}}$

As a CT example, consider an extended scheduling signal that consists of the derivatives of $p$ up to the $N^{\mathrm{th}}$ order:

$\rho(t) := [ p(t)^{\mathrm{T}}, \frac{\mathrm{d} p}{\mathrm{d} t}(t)^{\mathrm{T}}, ..., \frac{\mathrm{d}^N p}{\mathrm{d} t^N}(t)^{\mathrm{T}} ]^{\mathrm{T}}$

In LPVcore, an extended scheduling signal is represented using the `timemap`

object. It allows the user to specify the desired time domain and the derivatives (CT) and time shifts (DT) that make up the extended scheduling signal. Properties on the scalar components of the scheduling signal, such as names, bounds, and rate bounds, are supported as well. The following code snippet creates a `timemap`

object representing the extended scheduling signal $\rho = [ a; b; \frac{\mathrm{d} a}{\mathrm{d} t}, \frac{\mathrm{d} b}{\mathrm{d} t}]$ (explicit time-dependence is dropped for notational convenience):

`rho = timemap([0, 1], 'ct', 'Name', {'a', 'b'})`

For more information on the `timemap`

object, type `doc timemap`

or consult the suggested examples:

`pbasis`

: basis functions

The parent class `pbasis`

represents the family of scheduling dependent basis functions available in LPVcore. A scheduling dependent basis function $\phi$ maps the value of the extended scheduling signal at a point in time to a real scalar, i.e.:

$\phi: \mathbb{R}^{N_{\rho}} \rightarrow \mathbb{R}$

Some examples of parameter-varying basis functions:

- $\phi(\rho(t)) = 1$
- $\phi(\rho(t)) = \rho_i(t)$, for $i = 1, ..., N_{\rho}$
- $\phi(\rho(t)) = \prod_{i=1}^{N_{\rho}} \rho_i(t)^{d_i}$, for some $\{ d_i \in \mathbb{Z} | i = 1, ..., N_{\rho} \}$.
- $\phi(\rho(t)) = \sin(2 \pi \rho_i(t))$, for $i = 1, ..., N_{\rho}$

The above examples are all supported by classes in LPVcore inheriting from `pbasis`

. The first example, the constant $1$, can be constructed from the `pbconst`

object. It takes no arguments:

`phi = pbconst % phi = 1`

The second example, the function $\rho_i(t)$, is constructed from the `pbaffine`

object. It takes one argument: the index of the extended scheduling signal that is selected, or the value $0$ for a constant. For example, the following code snippet constructs $\phi = \rho_1$:

`phi = pbaffine(1) % phi = rho_1`

`pbaffine`

is a parent class of `pbconst`

since it can be seen as a generalization. A further generalization is implemented in the `pbpoly`

class, which represents polynomial functions of the extended scheduling signal (the third example in the list above). It is parameterized using two inputs: a matrix, `degrees`

, representing the degrees of the polynomial, and a vector `coeff`

, representing the coefficient of each monomial. Each row in `degrees`

corresponds to a monomial. For example, the following code snippet constructs $\phi = \rho_1^2 + 2 \rho_2^2$:

`phi = pbpoly([2, 0; 0, 2], [1, 2]) % phi = rho_1^2 + 2 rho_2^2`

Lastly, custom scheduling dependent basis functions that cannot be expressed in polynomial form are supported with the `pbcustom`

object. To use it, create a function handle that has a single input argument named `rho`

. It is important that the argument is named `rho`

since `pbcustom`

relies on this naming convention. The expected format for `rho`

is that it is an $N$-by-$N_{\rho}$ matrix, where $N$ is an arbitrary non-negative integer. Thus, the function handle should support vectorization. To ensure that the format is accepted, LPVcore verifies that each appearance of `rho`

in the function handle is in vectorized format, i.e., `rho(:, x)`

with `x`

the index of the extended scheduling signal. For example, the following code snippet constructs $\phi = \sin(2 \pi \rho_1) + \cos(2 \pi \rho_2)$:

`f = @(rho) sin(2 * pi * rho(:, 1)) + cos(2 * pi * rho(:, 2))`

phi = pbcustom(f)

`pmatrix`

: matrix function

Using the extended scheduling signal represented by the `timemap`

object, and a set of scheduling dependent basis functions represented by `pbasis`

objects, the next step is to assemble a scheduling dependent matrix function of the following form:

$A(\rho(t)) = \sum_{i=1}^{N} A_i \phi_i(\rho(t))$

where $A_i$ are standard MATLAB matrices, $\phi_i$ are the scheduling dependent basis functions, and $\rho$ is the extended scheduling signal.

There are several ways to construct such matrix functions. First, using the `pmatrix`

class. When instantiating an object of this class, 3 input arguments are required:

- The coefficients
`A_i`

. - The basis functions
`phi_i`

. - The extended scheduling signal
`rho`

.

For example, the following code snippet constructs the scheduling dependent matrix function $A(\rho(t)) = \rho_1(t) + 2 \rho_2(t)$, with $\rho = [a; b]$:

`Ai = cat(3, 1, 2)`

phii = { pbaffine(1), pbaffine(2) } % rho_1, rho_2

rho = timemap(0, 'ct', 'Name', {'a', 'b'}) % rho_1 --> a, rho_2 --> b

A = pmatrix(Ai, phii, 'SchedulingTimeMap', rho) % a + 2b

As a simpler alternative to `pmatrix`

, the `preal`

function is available. This function constructs a `pmatrix`

object representing a scalar extended scheduling signal with a specified name, time domain, derivative (CT) or time shift (DT), and other properties. For example, the following code snippet constructs a scheduling dependent matrix function $A(t) = q(t-1)$, with scheduling signal $q$ and extended scheduling signal $\rho(t) = q(t-1)$:

`A = preal('q', 'dt', 'Dynamic', -1)`

The resulting `pmatrix`

object can then be combined with other `pmatrix`

objects to form more complicated expressions. Many MATLAB operations on regular matrices have been extended to the `pmatrix`

class. For example, addition, matrix multiplication, element-wise multiplication, and more. For a complete overview, see the Reference section, type `doc pmatrix`

, or consult the suggested examples:

`lpvrep`

: LPV system representations

LPVcore supports several system representations that are each located under the `LPVcore`

package.
Hence, to create any system representation object, use the syntax `LPVcore.xxx`

.
This package naming is required to avoid shadowing the `lpvss`

class introduced in the Control System Toolbox in R2023a, and is applied to all other system representations object as well for consistency.

`LPVcore.lpvio`

: input-output representation

In this section, an LPV system representation relating an input signal $u$ and an output signal $y$ is presented. The dependence between these two signals is given as follows:

where $A$ and $B$ are polynomials in $\xi$ with coefficients that depend on the extended scheduling signal $\rho$. $\xi$ is the backward time-shift operator $q^{-1}$ (DT) or the differentiation operator $\frac{\mathrm{d}}{\mathrm{d}t}$ (CT). $A$ is a monic polynomial, i.e., the constant term is the non-scheduling dependent identity matrix $I$. The following example denotes a DT SISO system where $A$ and $B$ both have 2 terms:

To construct such a representation in LPVcore, the `LPVcore.lpvio`

class is used. The polynomials $A$ and $B$ are formatted as cell arrays, with each element of the cell array containing a `pmatrix`

object corresponding to a term of the polynomial. For example, the following code snippet constructs the LPV-IO system representation of the example above, with a sampling time of 1 second:

`Ts = 1; % seconds`

rho = preal('rho', 'dt');

A = {1, rho};

B = {rho^2, 1 - rho};

sys = LPVcore.lpvio(A, B, Ts)

`LPVcore.lpvss`

: state-space representation

In this section, the LPV-SS representation is introduced, where the state-space matrices are scheduling dependent, i.e.:

where $A$, $B$, $C$, and $D$ are scheduling dependent matrix functions and $\xi$ is the backward time-shift operator $q^{-1}$ (DT) or the differentiation operator $\frac{\mathrm{d}}{\mathrm{d}t}$ (CT). In LPVcore, the `LPVcore.lpvss`

class is used to create such a representation. For example, the following code snippet constructs a CT LPV-SS system representation:

`rho = preal('rho', 'ct');`

A = -1 + rho;

B = 1;

C = 1 + rho + rho^2;

D = 0;

sys = LPVcore.lpvss(A, B, C, D);

As can be seen, each state-space matrix can have a different dependence on the scheduling signal.

Control synthesis algorithms typically require a state-space model (such as an `LPVcore.lpvss`

object). To convert an input-output model (`LPVcore.lpvio`

object) to state-space form, use the `lpvioreal`

function.

`LPVcore.lpvlfr`

: linear-fractional representation

Another LPV system representation involves the linear fractional representation (LFR). Such an LPV-LFR system can be seen as the interconnection between an LTI system, $G$, and a scheduling dependent matrix function, $\Delta(\rho)$, in the following manner:

The LPVcore class `LPVcore.lpvlfr`

is used to construct a representation of an LPV-LFR system. The following code snippet gives an example with 1 input $u$, 1 output $y$, and 3 components in both interconnection signals $w$ and $z$.

`rho = preal('rho', 'dt');`

Delta = blkdiag(rho, eye(2) * rho^2);

G = drss(10, 4, 4);

sys = LPVcore.lpvlfr(Delta, G);

`LPVcore.lpvgridss`

and `LPVcore.lpvgridfrd`

: gridded representations

LPVcore includes 2 grid-based representations of LPV systems that can be viewed as a collection of *frozen systems* obtained when keeping the scheduling signal constant in time.
Their main purpose is to provide a convenient "container" class for such collections of frozen systems, similar to how state-space and frequency-response data model arrays can be created as Model Arrays in the Control Systems Toolbox.
The added benefit of using LPV gridded representations offered by LPVcore is that these are aware of the underlying scheduling map that relates the grid domain and the scheduling signals.
This allows for easier integration with downstream tasks such as control synthesis based on gridded techniques.

LPVcore contains 2 grid-based representation objects: `LPVcore.lpvgridss`

and `LPVcore.lpvgridfrd`

.
As their names suggest, the representation object at each grid point is a standard state-space model (`ss`

) or frequency-response data model (`frd`

), respectively.
Otherwise, the 2 objects have much in common.
For example, both allow for analysis of the frozen systems they contain using standard MATLAB functions such as `bode`

, `bodemag`

, `sigma`

and the various interconnection commands `feedback`

, `connect`

and more.
Note that interconnecting 2 grid-based representations simply interconnects their frozen systems. Hence, it is required that their grids match exactly.

LPVcore includes multiple interpolation methods that take a grid-based `LPVcore.lpvgridss`

object and convert it into a global model, i.e., a model that is also defined outside of the grid points associated with the frozen systems.
The currently support interpolation methods range from simple piece-wise linear interpolation to optimization-based techniques. See the example script for more details: