# System identification

## Overview#

LPVcore contains state-of-the-art identification algorithms for several model structures. On this page, a brief overview is given of the classes and functions that can be used to perform identification. First, the classes representing model structures with identifiable parameters is given. Then, the available algorithms and corresponding functions for identification of these model structures is presented. Finally, a table containing references to each algorithm is given.

## Model structures#

### lpvidpoly#

The lpvidpoly class represents a DT or CT polynomial model structure similar to idpoly of the System Identification Toolbox. More specifically, the following model structure is supported:

$A(\rho, \xi) \hat{y} = y + v, \\[4pt] F(\rho, \xi) y = B(\rho, \xi) u, \\[4pt] D(\rho, \xi) v = C(\rho, \xi) e,$

with $A, B, C, D, F$ polynomials similar to $A, B$ from lpvio. All polynomials except $B$ are monic. $e$ is a white noise signal with a given variance. Based on the general model structure, ARX, ARMAX, OE, and BJ model structures can be constructed by setting certain polynomials to identity. For example, the following code snippet shows the construction of a DT LPV-OE model structure with a noise variance of 0.1 and a sampling time of 1 second:

rho = preal('rho', 'dt');
NoiseVariance = 1E-1;
Ts = 1; % seconds
B = {1 - rho, rho^2};
F = {1, rho, rho^2};
model = lpvidpoly([], B, [], [], F, NoiseVariance, Ts);

Many methods that work with idpoly objects have been extended to function properly for lpvidpoly objects. For example, the nparams function can be used to find the number of (free) model parameters:

model = lpvidpoly(...);
nparams(model);
nparams(model, 'free')

For a complete overview of the available functions, type doc lpvidpoly.

##### important

The expected format for the polynomials (a cell array of pmatrix objects) differs from the convention used by idpoly. For example, idpoly expects a $N_y$-by-$N_y$ cell array of row vectors for the specification of $A$, where each element of the row vector corresponds to a coefficient. In contrast, lpvidpoly does not expect the size of the cell array to reflect the number of inputs or outputs. Instead, the size of each cell array entry (pmatrix object) should be consistent with the number of inputs or outputs.

### lpvidss#

The lpvidss class represents an LPV-SS representation with innovation noise model similar to the idss class of the System Identification Toolbox:

$\xi x = A(\rho) x + B(\rho) u + K(\rho) e, \\[4pt] y = C(\rho) x + D(\rho) u + e.$

Furthermore, the following model structure with general noise model is also supported:

$\xi x = A(\rho) x + B(\rho) u + G(\rho) v, \\[4pt] y = C(\rho) x + D(\rho)u + H(\rho) e,$

where the white noise processes $e$ and $v$ are normally distributed according to a specified variance. The following code snippet constructs a DT lpvidss model structure with innovation noise model with variance 0.1 and sampling time 1 second:

rho = preal('rho', 'dt');
NoiseVariance = 1E-1;
Ts = 1; % seconds
A = randn(3) * rho;
B = ones(3, 1) + ones(3, 1) * rho^2;
K = ones(3, 1);
C = ones(1, 3);
D = zeros(1);
model = lpvidss(A, B, C, D, 'innovation', K, [], NoiseVariance, Ts);

## Algorithms#

### Template system representations#

All system identification methods in LPVcore rely on the specification of a template system representation object. The purpose of such an object is to specify information such as the scheduling dependence and non-free model parameters (for gray-box identification). The template system representation objects are standard lpvrep objects: algorithms estimating IO models often require a template system representation in the form of an lpvidpoly object, while algorithms estimating SS models often require an lpvidss object.

The values of the model parameters of the template system representation may or may not be used in the algorithm itself: this depends on the chosen initialization method. The documentation for a particular algorithm indicates under which conditions the value of the model parameters are considered as an initial guess.

### Prediction Error Method (PEM)#

Two types of approaches for PEM are available in LPVcore:

1. Gradient-based PEM for the identification of LPV-IO and LPV-SS model structures.
2. Pseudo-linear least squares PEM for the identification of LPV-IO model structures.

For lpvidpoly model structures, a PEM identification can be invoked using the lpvpolyest command. The estimation is configured through the use of the lpvpolyestOptions object. Both aforementioned commands function in a similar way to polyest and polyestOptions as found in the System Identification Toolbox.

For lpvidss model structures, a PEM identification can be invoked using the lpvssest command.

### Subspace#

LPVcore contains a work-in-progress (WIP) version of a subspace algorithm for the estimation of an lpvidss model structure with innovation noise model. The algorithm is called LPV-PBSIDopt (original paper: link). Compared to the original paper, the version in LPVcore offers more flexibility:

1. The output equation (i.e., the $C$ and $D$ matrices) is allowed to be scheduling dependent.
2. Each scheduling dependent matrix can have its own number and type of basis functions.

To accomplish the additional flexibility, the implementation requires additional derivations not contained in the original paper. Therefore, a PDF file containing these derivations is included here for the interested reader:

Extensions of LPV-PBSIDopt for LPVcore (PDF)

### Local LPV-LFR identification#

This section is still a work-in-progress!

The local LPV-LFR identificaton approach is available under the function hinfid. It requires the following inputs:

1. A cell array of LTI models.
2. A cell array of values of the frozen extended scheduling signal corresponding to the operating points of the provided LTI models.
3. An lpvlfr model object providing the structure of the scheduling dependence and the initial values of the coefficients.
4. Optionally, an hinfstructOptions options set, since the hinfid method relies on the hinfstruct command to perform the optimization. This option set is directly passed to the hinfstruct command.

A typical workflow of identifying an LPV-LFR model from local data is the following:

1. Identify the local LTI models using, e.g., the System Identification Toolbox.
2. Define the model structure in terms of the scheduling dependence, and construct an lpvlfr model based on this.
3. Pass the identified local LTI models along with the operating points and lpvlfr model to hinfid.
##### important

A model structure for LPV-LFR system representation is not yet available. Thus, setting model parameters non-free is not possible.