mlgreyest

Identify a multilinear time-invariant (MTI) state-space model from measured data.

Source: src/mlgreyest.m

Overview

mlgreyest(data,r,structuralRestrictions,mtiBase,options) fits a discrete-time explicit multilinear time-invariant (eMTI) model

𝐱(k+1)=⟨[[𝐒F,𝚽F]]|[(1βˆ’bv1v1),…,(1βˆ’bvnvvnv)]⟩ \mathbf{x}(k+1) = \left\langle {\left[{\!\left[{\mathbf{S}_{F},\mathbf{\Phi}_{F}}\right]\!}\right]}\bigg | {\left[ \left(\begin{matrix}1-bv_1\\ v_1\end{matrix}\right), \dots, \left(\begin{matrix}1-bv_{n_v}\\ v_{n_v}\end{matrix}\right) \right] } \right\rangle

𝐲=⟨[[𝐒G,𝚽G]]|[(1βˆ’bv1v1),…,(1βˆ’bvnvvnv)]⟩ \mathbf{y} = \left\langle{\left[{\!\left[{\mathbf{S}_{G},\mathbf{\Phi}_{G}}\right]\!}\right]}\bigg | {\left[ \left(\begin{matrix}1-bv_1\\ v_1\end{matrix}\right), \dots, \left(\begin{matrix}1-bv_{n_v}\\ v_{n_v}\end{matrix}\right) \right] } \right \rangle

to measured data. The model parameters are stored in structure matrices 𝐒F∈[βˆ’1,1]nvΓ—RF,𝐒G∈[βˆ’1,1]nvΓ—RG\mathbf{S}_F\in[-1,1]^{{n_v} \times R_F},\mathbf{S}_G\in[-1,1]^{{n_v}\times R_G}, and in the parameter matrices 𝚽Fβˆˆβ„nxΓ—RF,𝚽Gβˆˆβ„nyΓ—RG\mathbf{\Phi}_F\in\mathbb{R}^{n_x \times R_F},\mathbf{\Phi}_G\in\mathbb{R}^{n_y \times R_G}.

The identification result is returned as an mss object where the mtiTensor is a CPNTensor. If the model base b∈{0,1}b\in\{0,1\} is not passed explicitly to mlgreyest, the default mtiBase of the returned model is the monomial base (b=0b=0).

In an mss, the CPNTensor is stored as one structure matrix 𝐒\mathbf{S} is (nx+nu)Γ—R\left(n_{x}+n_{u}\right)\times R and one parameter matrix 𝚽\mathbf{\Phi} is (nx+ny)Γ—R\left(n_{x}+n_{y}\right)\times R for the whole model, such that R≀RF+RGR\leq R_F+R_G.

Calling mlgreyest without any Name-Value options (default) will identify values for 𝚽F\mathbf{\Phi}_F and/or 𝐒F\mathbf{S}_F from measured states.

Data modes

State-trajectory mode (default). data.y is the measured state trajectory, so the model order equals the number of measured channels and the initial state is data.y(1,:). Only a state equation is identified. Focus selects whether the freely simulated trajectory ("simulation") or the one-step-ahead prediction from the measured states ("prediction") is fitted.

Output-identification mode (idFromOutputs=true). data.y are output measurements and the state is hidden: it is simulated forward from InitialState, whose length defines the state dimension. A state equation and an output equation are identified. Only the nonlinear methods support this mode, and only Focus="simulation" β€” without measured states there is nothing to predict from, so a different Focus is overridden with a warning.

Structural restrictions

Two different things are accepted in the third position as structuralRestrictions.

Channel of the restriction tensor Effect on that entry
structureMatrixTrue free, bounded to [0.5,1][0.5,\,1]
structureMatrixFalse free, bounded to [0,0.5][0,\,0.5]
structureMatrixContinuous free, bounded to [options.lowerBoundS, options.upperBoundS]
structure entry in no channel fixed at 0.50.5 (literal base neutral element)
parameterMatrixOne / MinusOne / Continuous free, bounded to [lowerBoundPhi, upperBoundPhi]
parameter entry in no channel fixed at 00

Syntax

Syntax
[sys,J] = mlgreyest(data,r) returns a monomial base mss with identified values for 𝐒F\mathbf{S}_F and 𝚽F\mathbf{\Phi}_F from measured states using an ALS algorithm. r defines the number of columns of 𝐒F\mathbf{S}_F and 𝚽F\mathbf{\Phi}_F.
[sys,J] = mlgreyest(data,[],structuralRestrictions) with structuralRestrictions provided as a numeric / logical structureMatrix returns a monomial base mss with 𝐒F=\mathbf{S}_F=structuralRestrictions and identified values for 𝚽F\mathbf{\Phi}_F from measured states.
[sys,J] = mlgreyest(data,r,[],mtiBase) returns an mss in the specified mtiBase with identified values for 𝐒F\mathbf{S}_F and 𝚽F\mathbf{\Phi}_F from measured states using an ALS algorithm.
[sys,J] = mlgreyest(data,r,[],mtiBase,'Method',"lsqnonlin") returns an mss in the specified mtiBase with identified values for 𝐒F\mathbf{S}_F and 𝚽F\mathbf{\Phi}_F from measured states using lsqnonlin.
[sys,J] = mlgreyest(data,r,[],mtiBase,'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',x0,...) returns anmss in the specified mtiBase with identified values for 𝐒\mathbf{S} and 𝚽\mathbf{\Phi} from measured outputs and an initial state x0 using lsqnonlin.
[sys,J,x0Est] = mlgreyest(data,[],structuralRestrictions,true,'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',x0,'estimateInitialState',true,...) returns a literal base mss in the specified mtiBase which together with x0Est approximates the input-output given by data. The identified values for 𝐒\mathbf{S} and 𝚽\mathbf{\Phi} lie within the bounds provided through the CPNTensor provided as structuralRestrictions.

Input Arguments

data

r

structuralRestrictions

mtiBase

options

Solver

Option Type Default Description
Method string "als" "als", or the nonlinear solvers "lsqnonlin" or "fmincon". ALS is state-trajectory only.
Focus string "simulation" "simulation" or "prediction"; overridden to "simulation" in output mode.
Display string "off" "on"/"off" for ALS; any optimoptions value ("iter", "final", …) for the nonlinear methods.
Nonnegative logical false only relevant in combination with Method="als": identification returns nonnegative 𝐒\mathbf{S} and 𝚽\mathbf{\Phi}.
UseParallel logical false Nonlinear solvers only.

Initialization and stopping

Option Type Default Description
Initialize string / CPNTensor "random" "random", "zero", only in combination with nonlinear solvers: "ga", or a CPNTensor.
MaxIterations double 400 ALS sweeps, or nonlinear solver iterations.
AlsTolerance double 0.1 ALS: stop once the cost drops below it.
MaxInitialization int16 5 ALS: how often a stalled random start may be redrawn.
ToleranceInitialization double 0.5 ALS: restart a stalled run only while the cost is still above this.
MaxFunctionEvaluations double 100000 Nonlinear solvers only.
OptimalityTolerance double 1e-6 Nonlinear solvers only.

Bounds (nonlinear methods)

Option Type Default Description
lowerBoundS / upperBoundS double -1 / 1 Bounds on the structure matrix entries.
lowerBoundPhi / upperBoundPhi double -10 / 10 Bounds on the parameter entries.

Output identification (Nonlinear solvers only)

Option Type Default Description
idFromOutputs logical false true: data.y are outputs, the state is hidden.
InitialState double [] Initial state x0; its length defines the state dimension.
estimateInitialState logical false true: fit x0 jointly, InitialState being only its guess.
columnIndexStateEq double [] Structure-matrix columns of the state equation.
columnIndexOutputEq double [] Structure-matrix columns of the output equation.

Output Arguments

sys

J

x0Est

Examples

The examples below generate their own data with msim, so they can be run as they stand (the iddata constructor needs the System Identification Toolbox).

Identify structure and parameters with the ALS

% a rank-2 monomial model, 2 states and 1 input
S = [0.6 0.2;      % x1
     0.3 0.9;      % x2
     0.4 0.1];     % u1
P = [0.5 0.2;      % x1(k+1)
     0.1 0.4];     % x2(k+1)
sys0 = mss(S,P,[1 2],3,1,[1 2],[],'mtiBase',false);

t  = (0:59)';
u  = 0.5 + 0.4*sin(t/3);
[~,~,x] = sys0.msim(u,t,[0.3 0.6]);
data = iddata(x,u,1);                       % measured STATE trajectory

[sys,J] = mlgreyest(data,2,[],false,'Method',"als",'Display',"off");
fprintf('final cost %.3e\n', J(end));

Add 'Nonnegative',true to keep every identified value non-negative (each subproblem is then solved with lsqnonneg), or 'Focus',"prediction" to fit the one-step-ahead prediction instead of the free simulation.

Fit only the parameters of a known structure

sys = mlgreyest(data,[],S);             % S from the example above

Identify in the literal base

[sys,J] = mlgreyest(data,2,[],true,'Method',"als",'Initialize',"random");

Identify a state and an output equation from outputs only

% state equation on columns 1-2, output equation on columns 3-4
S = [ 1.0   0.0   0.6   1.0 ;   % x1
      0.0   1.0   1.0   0.0 ;   % x2
      0.4  -0.3   0.0   0.2 ];  % u1
P = [ 0.7   0.2   0     0   ;   % x1(k+1)
      0.3   0.5   0     0   ;   % x2(k+1)
      0     0     1.5   0.5 ;   % y1
      0     0     0.8   1.2 ];  % y2
sys0 = mss(S,P,[1 2],3,1,[1 2],[3 4],'mtiBase',true);

t  = (0:59)';
u  = 0.5 + 0.4*sin(t/3);
x0 = [0.3; 0.6];
y = sys0.msim(u,t,x0');
data = iddata(y,u,1);                       % measured OUTPUTS, state hidden

[sys,J,x0Est] = mlgreyest(data,[2 2],[],true, ...
    'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',x0, ...
    'Display',"off",'MaxIterations',80,'MaxFunctionEvaluations',5000);

r = [2 2] requests disjoint column blocks. Use a scalar r to let both equations share the same columns, or name the columns explicitly:

[sys,J] = mlgreyest(data,[],[],true, ...
    'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',x0, ...
    'columnIndexStateEq',[1 2],'columnIndexOutputEq',[2 3 4]);   % may overlap

Restrict the search with a CPNTensor

restriction = sys0.mtiTensor;               % same size as the model to be identified

[sys,J,x0Est] = mlgreyest(data,[],restriction,true, ...
    'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',x0, ...
    'Focus',"simulation",'Display',"off",'MaxFunctionEvaluations',20000);

The tensor is also the warm start, so a restriction tensor that already carries good values converges in very few iterations.

To warm-start from different values on the same free-variable layout, pass a second tensor of the same size as Initialize:

perturbedTensor = copy(sys0.mtiTensor);
perturbedTensor.structureMatrixContinuous(perturbedTensor.structureMatrixContinuous>0)=0.8;
[sys,J] = mlgreyest(data,[],restriction,true, ...
    'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',x0, ...
    'Initialize',perturbedTensor, 'Display', 'iter');

β€œA CPNTensor Initialize inherits every restriction of the restriction tensor” It supplies only values; which entries are free is decided by the CPNTensor structural restrictions, which it therefore requires.

Estimate the initial state as well

guess = [0.4; 0.4];                          % only a guess now
[sys,J,x0Est] = mlgreyest(data,[],restriction,true, ...
    'Method',"lsqnonlin",'idFromOutputs',true,'InitialState',guess, ...
    'estimateInitialState',true,'MaxFunctionEvaluations',20000);

The initial state becomes an extra block of optimization variables, bounded to [0,1][0,1], and is returned as x0Est.

Practical notes

See Also


MyToolbox Documentation | Generated automatically by CI/CD pipeline