mss

Multilinear explicit state-space model (eMTI).

Source: src/model/@mss/mss.m

An mss object stores an explicit multilinear time-invariant (eMTI) model: a state equation and an output equation whose right-hand sides are multilinear functions of the states and inputs. It is the explicit counterpart of the descriptor model mdss.

The model tensor is stored as an mtiTensor ( CPNTensor (default) or TTTensor), and the assignment to signals and equations is performed by explicit index vectors.

Description

An eMTI model consisting of nx+nyn_x+n_y explicit multilinear functions can be represented by contracted tensor products

ฮด๐ฑ=โŸจ๐™ต|๐™ผ(๐ฏ)โŸฉ, \delta\mathbf{x} = \left\langle \mathtt{F} | \mathtt{M}(\mathbf{v})\right\rangle ,

๐ฒ=โŸจ๐™ถ|๐™ผ(๐ฏ)โŸฉ, \mathbf{y} = \left\langle \mathtt{G}| \mathtt{M}(\mathbf{v})\right\rangle,

Here, ๐ฏโˆˆโ„nv\mathbf{v}\in\mathbb{R}^{n_v}, ๐ฒโˆˆโ„ny\mathbf{y}\in\mathbb{R}^{n_{y}} and ฮด๐ฑโˆˆโ„nx\delta \mathbf{x}\in\mathbb{R}^{n_{x}} denotes the state change,

ฮด๐ฑ={๐ฑฬ‡(t)๐š๐š’๐š–๐šŽ๐š‚๐š๐šŽ๐š™๐š‚๐š’๐šฃ๐šŽ=0(continuous-time)๐ฑ(k+1)๐š๐š’๐š–๐šŽ๐š‚๐š๐šŽ๐š™๐š‚๐š’๐šฃ๐šŽ>0(discrete-time). \delta\mathbf{x} = \begin{cases} \dot{\mathbf{x}}(t) & \texttt{timeStepSize} = 0 \quad\text{(continuous-time)}\\ \mathbf{x}(k+1) & \texttt{timeStepSize} > 0 \quad\text{(discrete-time)}. \end{cases}

In an eMTI model the signal vector of length nv=nx+nun_v = n_{x}+n_{u} contains the states ๐ฑโˆˆโ„nx\mathbf{x}\in\mathbb{R}^{n_{x}} and the inputs ๐ฎโˆˆโ„nu\mathbf{u}\in\mathbb{R}^{n_{u}}:

๐ฏ=[๐ฑโŠค,๐ฎโŠค]โŠค. \mathbf{v} = \left[\mathbf{x}^\top,\ \mathbf{u}^\top\right]^\top.

The model tensors ๐™ตโˆˆโ„ร—(nv)2ร—nx\mathtt{F}\in\mathbb{R}^{\times^{(n_v)}2\times n_x} and ๐™ถโˆˆโ„ร—(nv)2ร—ny\mathtt{G}\in\mathbb{R}^{\times^{(n_v)}2\times n_y}, with ร—(nv)2{\times^{(n_v)}2} denoting nvn_v dimensions of length 2, contain the model parameters. While ๐™ต\mathtt{F} and ๐™ถ\mathtt{G} can have an arbitrary rank, the tensor ๐™ผ(๐ฏ)\mathtt{M}(\mathbf{v}) is always rank 1 with a canonical polyadic (CP) decomposition

๐™ผ(๐ฏ)=[(1โˆ’bv1v1),โ€ฆ,(1โˆ’bvnvvnv)]. \mathtt{M}(\mathbf{v})=\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].

The variable bโˆˆ{0,1}b\in\{0,1\} depends on the model base. For models in the monomial base it has the value b=0b=0, and in the literal base b=1b=1.

An equivalent representation of the full model tensors can be achieved with CP decomposed parameter tensors, e.g.ย for the state equation tensor as

๐™ต=[๐…1,โ€ฆ,๐…nv,๐…ฮฆ], \mathtt{F}= {\left[{\mathbf{F}_{1},\dots,\mathbf{F}_{n_v}, \mathbf{F}_{\Phi}}\right]},

with factor matrices ๐…iโˆˆโ„2ร—RF\mathbf{F}_i\in\mathbb{R}^{2\times R_F} for i=1,โ€ฆ,nvi=1,\dots,n_v and a parameter matrix ๐…ฮฆโˆˆโ„nxร—RF\mathbf{F}_{\Phi}\in\mathbb{R}^{n_x\times R_F}. The second matrix dimension denoted as RFR_F is the number of product terms in the state equation.

Exploiting the dimensions of MTI models, the model tensors can be stored using the more compact Canonical Polyadic Normalized (CPN) representation, which is implemented in the MTI-Toolbox. This representation is based on normalization of the factor matrix columns such that

||๐…i(:,r)||1=1 for all r=1,โ€ฆ,RF. \lvert\lvert\mathbf{F}_i(:,r)\rvert\rvert_{1}=1 \text{ for all } r=1,\dots,R_F.

Because for multilinear models the first dimension of the factor matrices ๐…i\mathbf{F}_i is always of length 2, knowing only one row of each normalized factor matrix is enough to reconstruct the other row. This allows representing the model tensor through a so-called structure matrix ๐’Fโˆˆ[โˆ’1,1]nvร—RF\mathbf{S}_F\in[-1,1]^{{n_v} \times R_F}, which contains the second rows of the normalized factor matrices, and a parameter matrix ๐šฝFโˆˆโ„nxร—RF\mathbf{\Phi}_F\in\mathbb{R}^{n_x \times R_F}, which absorbs the scaling factors for the normalized multilinear polynomials.

In CPN representation, an eMTI model is written as

ฮด๐ฑ=โŸจ[[๐’F,๐šฝF]]|[(1โˆ’bv1v1),โ€ฆ,(1โˆ’bvnvvnv)]โŸฉ \delta\mathbf{x} = \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

The evaluation of the individual model equations is equivalent to a sum of products

ฮดxl(๐ฏ)=โˆ‘r=1RFฯ•Fl,rโˆi=1nvpb(sFi,r,vi),l=1,โ€ฆ,nx, \delta x_l(\mathbf{v}) = \sum_{r=1}^{R_F} \phi_{F_{l,r}} \prod_{i=1}^{n_v} p_{b}\!\left(s_{F_{i,r}}, v_{i}\right), \qquad l = 1,\dots,n_x,

ym(๐ฏ)=โˆ‘r=1RGฯ•Gm,rโˆi=1nvpb(sGi,r,vi),m=1,โ€ฆ,ny, y_{m}(\mathbf{v}) = \sum_{r=1}^{R_G} \phi_{G_{m,r}} \prod_{i=1}^{n_v} p_{b}\!\left(s_{G_{i,r}}, v_{i}\right), \qquad m = 1,\dots,n_y,

where the 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} select which signals enter each product term, and 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} hold the weight of the terms.

The scalar factor function pbp_{b} changes with the model base bb. For models in the monomial base (b=0b=0), it is

p0(s,v)=1โˆ’|s|+sv, p_{0}(s,v) = 1-\lvert s\rvert + s\,v ,

and for models in the literal base (b=1b=1), it evaluates as

p1(s,v)=(1โˆ’|s|)(1โˆ’v)+sv=1โˆ’|s|+(s+|s|โˆ’1)v. p_{1}(s,v) = \left(1-\lvert s\rvert\right)\left(1-v\right) + s\,v = 1-\lvert s\rvert + \left(s + \lvert s\rvert - 1\right) v .

The value of si,rs_{i,r} therefore has a different meaning in each base:

si,js_{i,j} monomial factor p0p_{0} literal factor p1p_{1}
11 viv_{i} viv_{i}
00 11 โ€” variable absent from the term 1โˆ’vi1-v_{i}
0.50.5 0.5(1+vi)0.5\left(1+v_{i}\right) 0.50.5 โ€” variable absent from the term
โˆ’0.5-0.5 0.5(1โˆ’vi)0.5\left(1-v_{i}\right) 0.5โˆ’vi0.5-v_{i}
โˆ’1-1 โˆ’vi-v_{i} โˆ’vi-v_{i}

Another way to store the model parameters of MTI models is provided by the Tensor Train (TT) representation, which stores the model tensor through the TT-cores:

๐™ต(i1,i2,โ€ฆ,id)=๐™ต1(i1)๐™ต2(i2)โ€ฆ๐™ตd(id) \mathtt{F}(i_1, i_2, \dots, i_d) = \mathtt{F}_1(i_1) \mathtt{F}_2(i_2) \dots \mathtt{F}_d(i_d)

Here the TTTensor approximates a tensor of order dd by a product of dd third order tensors, known as TT-cores, where the first and the last TT-cores have a degenerated dimension of 1 and thus can be represented as matrices. The middle dimensions connecting the core tensors are known as the TT-ranks of the decomposition and if it is exact, they are the TT-ranks of the original tensor.

Elements of the full tensor ๐™ต\mathtt{F} can be computed by the so-called contraction

f(i1,i2,โ€ฆ,id)=๐™ต1(1,i1,:)๐™ต2(:,i2,:)โ€ฆ๐™ตd(:,id,1) f(i_1,i_2, \dots, i_d) = \mathtt{F}_1(1,i_1,:) \mathtt{F}_2(:,i_2,:) \dots \mathtt{F}_d(:,i_d,1)

In TT representation, an eMTI model is written as

ฮด๐ฑ=โŸจ[[๐™ตฯ•,๐™ตvnv,โ€ฆ,๐™ตv2,๐™ตv1]]|[(1vnv),โ€ฆ,(1v1)]โŸฉ \delta\mathbf{x} = \left\langle {\left[{\!\left[{\mathtt{F}_{\phi}, \mathtt{F}_{v_{n_v}}, \ldots, \mathtt{F}_{v_2}, \mathtt{F}_{v_1}}\right]\!}\right]}\bigg | {\left[ \left(\begin{matrix}1\\ v_{n_v}\end{matrix}\right), \dots, \left(\begin{matrix}1\\ v_1\end{matrix}\right) \right] } \right\rangle

๐ฒ=โŸจ[[๐™ถฯ•,๐™ถvnv,โ€ฆ,๐™ถv2,๐™ถv1]]|[(1vnv),โ€ฆ,(1v1)]โŸฉ \mathbf{y} = \left\langle{\left[{\!\left[{\mathtt{G}_{\phi}, \mathtt{G}_{v_{n_v}}, \ldots, \mathtt{G}_{v_2}, \mathtt{G}_{v_1}}\right]\!}\right]}\bigg | {\left[ \left(\begin{matrix}1\\ v_{n_v}\end{matrix}\right), \dots, \left(\begin{matrix}1\\ v_1\end{matrix}\right) \right] } \right \rangle

The evaluation of the individual model equations in TT representation is equivalent to a product of sums

ฮดxl(๐ฏ)=๐™ตฯ•โ‹…(โˆi=1nv(๐™ตvi(:,1,:)+๐™ตvi(:,2,:)vi))T,l=1,โ€ฆ,nx, \delta x_l(\mathbf{v}) = \mathtt{F_{\phi}} \cdot (\prod_{i=1}^{n_v} (\mathtt{F}_{v_i}(:,1,:) + \mathtt{F}_{v_i}(:,2,:) v_i))^T, \qquad l = 1,\dots,n_x,

ym(๐ฏ)=๐™ถฯ•โ‹…(โˆi=1nv(๐™ถvi(:,1,:)+๐™ถvi(:,2,:)vi))T,m=1,โ€ฆ,ny, y_{m}(\mathbf{v}) = \mathtt{G_{\phi}} \cdot (\prod_{i=1}^{n_v} (\mathtt{G}_{v_i}(:,1,:) + \mathtt{G}_{v_i}(:,2,:) v_i))^T, \qquad m = 1,\dots,n_y,

All these representations are equivalent representations of the same model tensor:

๐™ตโ‰ก[๐…1,โ€ฆ,๐…nv,๐…ฮฆ]โ‰ก[[๐’F,๐šฝF]]โ‰ก[[๐™ตฯ•,โ€ฆ,๐™ตv2,๐™ตv1]] \mathtt{F}\equiv {\left[{\mathbf{F}_{1},\dots,\mathbf{F}_{n_v}, \mathbf{F}_{\Phi}}\right]} \equiv\left[{\!\left[{\mathbf{S}_{F},\mathbf{\Phi}_{F}}\right]\!}\right] \equiv\left[{\!\left[{\mathtt{F}_{\phi}, \dots, \mathtt{F}_{v_2},\mathtt{F}_{v_1}}\right]\!}\right]

Construction

An mss stores the model parameters either as a CPNTensor or as a TTTensor.

The CPNTensor is stored as one structure matrix and one parameter matrix for the whole model:

Which row is which signal, and which row is which equation, is recorded by the index vectors stateIndex, inputIndex, stateEquationIndex and outputEquationIndex, so an mss never assumes a fixed row ordering. The column sets are not passed: they are derived at construction from the nonzero pattern of the parameter rows.

Because the state and output equation share the structure matrix, 
their columns also carry a row for every input. To keep for example the output equation
independent of the inputs, set those entries to the neutral element of the
base โ€” 0 in the monomial base, 0.5 in the literal base.

A model is not portable between bases by flipping mtiBase: that changes the function the same matrices represent. A closed-form transformation of ๐’\mathbf{S} and ๐šฝ\mathbf{\Phi} between the two bases can be performed using mss2mss.

The mtiBase applies to the continuous structure entries of a model where mtiTensor is a CPNTensor.

The TTTensor is stored through the TT-cores for the whole model where the number of cores exceeds the number of system variables by one due to the parameter matrix - First TT-core, ๐™ตฯ•\mathtt{F}_{\phi} is the parameter matrix with dimensions R0ร—nxร—R1R_0 \times n_x \times R_1 where R0=1R_0 = 1 โ€” one row per equation - Middle TT-cores, ๐™ตvnv\mathtt{F}_{v_{n_v}} โ†’\rightarrow ๐™ตv2\mathtt{F}_{v_2} are 3D tensors with dimensions Rkร—2ร—Rk+1R_k \times 2 \times R_{k+1} where k={nv,โ€ฆ,2}k = \{n_v, \dots, 2\} โ€” one 3D tensor per signal - Last TT-core, ๐™ตv1\mathtt{F}_{v_1} is a matrix with dimensions Rnvร—2ร—Rnv+1R_{n_v} \times 2 \times R_{n_v+1} where Rnv+1=1R_{n_v+1} = 1 โ€” Represents the first signal

Analogous relations can be inferred for the output TTTensor ๐™ถ\mathtt{G} as well.

The mtiBase of the TTTensor should always be set to 0, the monomial base, as the literal base construction for the TTTensor is still under development.

Construction from structure and parameter matrices

Take the discrete-time bilinear model

x1(k+1)=0.9x1(k)+0.1x1(k)u1(k),y1(k)=2x1(k), x_{1}(k+1) = 0.9\,x_{1}(k) + 0.1\,x_{1}(k)\,u_{1}(k), \qquad y_{1}(k) = 2\,x_{1}(k),

in the monomial base. It has three distinct terms in total โ€” x1x_{1}, x1u1x_{1}u_{1} and, for the output, x1x_{1} again โ€” but the output can reuse the first column, so r=2r=2:

%                   x1   x1*u1
structureMatrix = [  1     1 ;   % x1
                     0     1 ];  % u1

parameterMatrix = [ 0.9   0.1 ;  % x1(k+1)
                    2     0   ]; % y1

sys = mss(structureMatrix, parameterMatrix, ...
          1, ...   % stateIndex           (1st row of the structure matrix)
          2, ...   % inputIndex           (2nd row of the structure matrix)
          1, ...   % timeStepSize         (>0 = discrete-time)
          1, ...   % stateEquationIndex   (1st row of the parameter matrix)
          2);      % outputEquationIndex  (2nd row of the parameter matrix)

A monomial-base structure entry of 0 means the variable is absent from that term, so column 1 is x1x_1 and column 2 is x1u1x_1u_1. Since the output row is nonzero only in column 1, the constructor derives

sys.columnIndexStateEq    % [1 2]
sys.columnIndexOutputEq   % 1        -- a shared column

Evaluate the model directly with functionValue, outputValue

sys.functionValue(2,3) % 2.4
sys.outputValue(2,3)   % 4

The mss does not store structureMatrix and parameterMatrix internally, but instead a CPNTensor, which holds the structure split into structureMatrix{True,False,Continuous} and the parameters split into parameterMatrix{One,MinusOne,Continuous} over disjoint supports.

Construction from a CPN tensor

An mss can also be built around a CPNTensor that already exists โ€” one returned by an identification, produced by another model operation, or assembled by hand. The tensor then replaces the two matrices and the constructor takes six positional arguments:

sys = mss(mtiTensor, stateIndex, inputIndex, timeStepSize, ...
          stateEquationIndex, outputEquationIndex);

The CPNTensor can for example be constructed through the six split channels in the order structure {True, False, Continuous}, parameter {One, MinusOne, Continuous}. The four True/False/One/MinusOne arguments are masks โ€” only their nonzero pattern matters, the values are converted to logical โ€” while the two Continuous arguments carry the actual numbers. Within each triple the supports must be disjoint.

Take the discrete-time model

x1(k+1)=0.9x1(k)โˆ’(1โˆ’x1(k))u1(k),y1(k)=0.7+0.3x1(k), x_{1}(k+1) = 0.9\,x_{1}(k) - \left(1-x_{1}(k)\right)u_{1}(k), \qquad y_{1}(k) = 0.7 + 0.3\,x_{1}(k),

whose three terms use all six channels โ€” a True factor x1x_1, a False factor 1โˆ’x11-x_1 together with a True factor u1u_1, and a Continuous factor for the output, weighted by a Continuous, a MinusOne and a One parameter:

%                             x1   (1-x1)*u1   x1(cont.)
structureMatrixTrue       = [  1       0          0    ;   % x1
                               0       1          0    ];  % u1
structureMatrixFalse      = [  0       1          0    ;
                               0       0          0    ];
structureMatrixContinuous = [  0       0          0.3  ;
                               0       0          0    ];

parameterMatrixOne        = [  0       0          0    ;   % x1(k+1)
                               0       0          1    ];  % y1
parameterMatrixMinusOne   = [  0       1          0    ;
                               0       0          0    ];
parameterMatrixContinuous = [  0.9     0          0    ;
                               0       0          0    ];

mtiTensor = CPNTensor(structureMatrixTrue, structureMatrixFalse, structureMatrixContinuous, ...
                      parameterMatrixOne, parameterMatrixMinusOne, parameterMatrixContinuous);

sys = mss(mtiTensor, ...
          1, ...   % stateIndex
          2, ...   % inputIndex
          1, ...   % timeStepSize
          1, ...   % stateEquationIndex
          2);      % outputEquationIndex

Everything else behaves exactly as on the matrix path โ€” the column sets are derived the same way, and the model evaluates as written:

sys.columnIndexStateEq    % [1 2]
sys.columnIndexOutputEq   % 3

sys.functionValue(2,3)    % 4.8
sys.outputValue(2,3)      % 1.3

Passing a cell array of TT cores instead of a tensor object selects a TTTensor model, which is always monomial.

Canonical matrices vs.ย stored channels

The structure and parameter matrix are not explicitly stored in the mss, but they can be obtained by sys.structureMatrix and sys.parameterMatrix.

The two getters return the canonical form, for which in each model base a special case is considered. That involves a per-column rescaling of ๐šฝ\mathbf{\Phi}, because the special-cased channels leave a constant factor behind:

base structure special case canonical ๐šฝ\mathbf{\Phi}
monomial a False entry denotes si,r=โˆ’0.5s_{i,r}=-0.5, i.e.ย the factor 0.5(1โˆ’vi)0.5\left(1-v_i\right) folded ๐šฝ\mathbf{\Phi} scaled by 2#False2^{\#\text{False}} per column
literal a donโ€™t-care si,r=0.5s_{i,r}=0.5 is not stored in any channel, and its factor is 0.50.5 folded ๐šฝ\mathbf{\Phi} scaled by 2#donโ€™t-care2^{\#\text{don't-care}} per column

Looking back at our example:

The channels hold the folded values, so a False entry is the plain factor 1โˆ’vi1-v_i rather than the canonical 0.5(1โˆ’vi)0.5\left(1-v_i\right). The canonical getters undo that difference โ€” reading them back gives the matrices the previous section would have been given, with the parameter of column 2 scaled by 212^{1} for its one False factor:

full(sys.structureMatrix)
  ans =

    1.0000   -0.5000    0.3000
         0    1.0000         0
full(sys.parameterMatrix)   
ans =

    0.9000   -2.0000         0
         0         0    1.0000

Constructing a literal-base model through mss performs the folding for you.

Constructing a literal-base model

The same constructor builds a literal-base model when mtiBase is set. Here the state equation is the exclusive-or of a state and an input, evaluated in the relaxed, continuous domain:

x1(k+1)=(1โˆ’x1(k))u1(k)+x1(k)(1โˆ’u1(k)),y1(k)=x1(k). x_{1}(k+1) = \left(1-x_{1}(k)\right)u_{1}(k) + x_{1}(k)\left(1-u_{1}(k)\right), \qquad y_{1}(k) = x_{1}(k) .

%                 (1-x1)*u1   x1*(1-u1)   x1
structureMatrix = [   0           1        1   ;   % x1
                      1           0        0.5 ];  % u1

parameterMatrix = [   1           1        0   ;   % x1(k+1)
                      0           0        2   ];  % y1

sys = mss(structureMatrix, parameterMatrix, 1, 2, 1, 1, 2, mtiBase = 1);

Two conventions of the literal base show up in column 3, the output term:

Here the two equation blocks use disjoint columns (columnIndexStateEq = [1 2], columnIndexOutputEq = 3). Evaluated on the Boolean corners the model reproduces the truth table of the XOR, and it is defined in between:

sys.functionValue(0, 1)       % 1
sys.functionValue(1, 1)       % 0
sys.functionValue(0.3, 0.7)   % 0.58

Construction from a TT Tensor

Consider the continuous-time multilinear model in the monomial base.

[xฬ‡1xฬ‡2]=[0.27x1+0.08u+0.378x1x2+0.045x1u+0.1x2u0.195x1u+0.273x1x2u][y1y2]=[x1x2] \begin{aligned} \begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} &= \begin{bmatrix} 0.27x_1 + 0.08u + 0.378x_1x_2 + 0.045x_1u + 0.1x_2u \\ 0.195x_1u + 0.273x_1x_2u \end{bmatrix} \\ \begin{bmatrix} y_1 \\ y_2 \end{bmatrix} &= \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \end{aligned}

The equation consists of three system variables โ€” x1,x2,ux_1, x_2, u and the outputs of the equation are equal to its states. An mss model can be built around a TTTensor that can be obtained by system identification, produced by another model operation, or assembled by hand. The model can also be converted to discrete-time by using the c2d function with the TTTensor.

F_x_1(:,:,1) = [  0.4     0 ;   % x_1 TT-core
                  0       0.6 ]; 

F_x_2(:,1,:) = [  0.8     0 ;   % x_2 TT-core
                  0.3     0.5 ];
F_x_2(:,2,:) = [  0.1     0 ;   
                  0       0.7 ];

F_u(:,1,:)   = [  0       0 ;   % u TT-core
                  0.9     0 ];
F_u(:,2,:)   = [  0.25    0 ;   
                  0       0.65 ];

F_phi(1,:,:) = [  1       0 ;   % phi TT-core
                  0       1 ];

T = TTTensor({F_phi, F_u, F_x_2, F_x_1});

sys = mss(T, [1 2], 1, 0, [1 2], []);

Simulation

Simulate with msim.

k = (0:5)';
u = double(k >= 3);              % step at k = 3

[y, t, x] = msim(sys, u, k, 1);  % sys: the bilinear model above, x0 = 1

Syntax

Syntax Result
sys = mss() Empty object with an empty mtiTensor.
sys = mss(structureMatrix, parameterMatrix, stateIndex, inputIndex, timeStepSize, stateEquationIndex, outputEquationIndex) Build from the canonical CPN matrices + index vectors.
sys = mss(mtiTensor, stateIndex, inputIndex, timeStepSize, stateEquationIndex, outputEquationIndex) Build from an existing tensor (or a cell array of TT cores) + index vectors.
sys = mss(structureMatrixTrue, structureMatrixFalse, structureMatrixContinuous, parameterMatrixOne, parameterMatrixMinusOne, parameterMatrixContinuous, stateIndex, inputIndex, timeStepSize, stateEquationIndex, outputEquationIndex) Build from the six split channels + index vectors.
sys = mss(Name, Value, ...) Nameโ€“value form; accepts explicit index vectors or scalar amountโ€ฆ counts.

Nameโ€“value pairs

Model tensor โ€” give either the canonical pair or the six split channels. If structureMatrix or parameterMatrix is present, the canonical pair is used and the channel arguments are ignored:

Name Description
structureMatrix Canonical ๐’\mathbf{S}.
parameterMatrix Canonical ๐šฝ\mathbf{\Phi}.
structureMatrixTrue Mask of the viv_i factors.
structureMatrixFalse Mask of the 1โˆ’vi1-v_i factors.
structureMatrixContinuous The remaining structure values.
parameterMatrixOne Mask of the +1+1 parameters.
parameterMatrixMinusOne Mask of the โˆ’1-1 parameters.
parameterMatrixContinuous The remaining parameter values.

Rows โ€” row assignment are given either as index vectors or as scalar counts:

Index vector Scalar count
stateIndex amountState
inputIndex amountInput
stateEquationIndex amountStateEquation
outputEquationIndex amountOutputEquation

Model options:

Name Default Description
timeStepSize [] 0 continuous-time, >0 discrete-time sample time.
mtiBase 0 0 monomial base, 1 literal base.

Every name defaults to [] except mtiBase, which defaults to 0.

Leaving timeStepSize out is accepted but leaves the property empty, so a model that is to be simulated should always set it.

Passing counts instead of index vectors commits the matrices to a defined layout: the structure-matrix rows must be ordered [state; input] and the parameter-matrix rows [state equations; output equations], each block filled sequentially. If the rows follow a different order, pass explicit index vectors.

Other ways to obtain an mss

Function Purpose
ss2mss Convert a MATLAB ss/dss model into an equivalent mss.
mlgreyest Identify an mss from measured data (structure and/or parameters) where the mtiTensor is a CPNTensor.
rmss Random monomial base mss of a given size โ€” handy for tests and examples.
c2d Discretize a continuous-time mss.

Properties

Model tensor

Property Description
mtiTensor Model tensor, an mtiTensor (CPNTensor(default) or TTTensor).
mtiBase Base of the continuous structure entries: 0 monomial, 1 literal. CPN only.
structureMatrix Dependent, hidden. Canonical ๐’\mathbf{S}, (nx+nu)ร—r\left(n_{x}+n_{u}\right)\times r, reassembled from the tensor channels.
parameterMatrix Dependent, hidden. Canonical ๐šฝ\mathbf{\Phi}, (nx+ny)ร—r\left(n_{x}+n_{y}\right)\times r, base-rescaled per column.
cores Dependent, hidden. TT cores, for a TTTensor model.
timeStepSize 0 continuous-time, >0 discrete-time sample time.
discretizationType Method used by c2d/d2c ("none" if never discretized).
lowerBoundary, upperBoundary Optional per-equation bounds on the model functions.

Signal names / units

stateName, stateUnit, inputName, inputUnit, outputName, outputUnit โ€” string vectors that must match the corresponding signal count (nState, nInput, nOutput). manipulatedVariable, measuredDisturbance and unmeasuredDisturbance index the inputs by role.

Index vectors (read-only)

Set at construction; each maps a matrix row, column or TT-cores to a signal or equation:

Property Indexes Meaning
stateIndex, inputIndex rows of structureMatrix / cores of TTTensor which structure row / TT-core refers to xix_i / uiu_i.
stateEquationIndex, outputEquationIndex rows of parameterMatrix which parameter row / first TT-core row refers to a state equation ฮดxi\delta x_i / an output yiy_i. nOutput follows from the latter.
columnIndexStateEq, columnIndexOutputEq columns of both matrices (relevant only for CPNTensor) which terms each equation block uses (relevant only for CPNTensor).

An empty outputEquationIndex gives a model with a state equation only.

Object functions

Function Purpose
msim Simulate the time response to an input trajectory.
functionValue Evaluate the state equation at (๐ฑ,๐ฎ)(\mathbf{x},\mathbf{u}).
outputValue Evaluate the output equation at (๐ฑ,๐ฎ)(\mathbf{x},\mathbf{u}).
stateJacobian / outputJacobian Analytic Jacobians [โˆ‚๐Ÿ/โˆ‚๐ฑโˆ‚๐Ÿ/โˆ‚๐ฎ][\partial\mathbf{f}/\partial\mathbf{x}\ \ \partial\mathbf{f}/\partial\mathbf{u}], [โˆ‚๐ /โˆ‚๐ฑโˆ‚๐ /โˆ‚๐ฎ][\partial\mathbf{g}/\partial\mathbf{x}\ \ \partial\mathbf{g}/\partial\mathbf{u}].
linearize Linearize around an operating point, returning an ss object or the raw A,B,C,D.
c2d / d2c Discretize / continualize (forward Euler stays mss and preserves the mtiBase; backward Euler and Tustin yield an mdss and convert the model to monomial base if the provided model was in literal base).
mss2mss Linear state transformation ๐ฑ=๐“๐ฑฬƒ+๐œ\mathbf{x} = \mathbf{T}\tilde{\mathbf{x}} + \mathbf{c} (scaling and permutation) and/or conversion between monomial and literal model base.
mss2mdss Convert to the descriptor form. Also converts the model to monomial base if the provided model was in literal base.
trivialReduction Merge duplicate and drop unused monomial columns without changing the function.
checkIndexDimensions Assert that the index vectors cover the tensor exactly.
allSignalScalarIndices / allEquationScalarIndices Predicates used by the constructorโ€™s auto-expansion.

Additional theory

Multilinear functions

A function is multilinear if every variable appears with a maximum degree of one in each of its terms; multilinear functions are therefore a superclass of linear and of Boolean functions, and a subclass of the polynomial functions. A multilinear function of nvn_v variables ๐ฏโˆˆโ„nv\mathbf{v}\in\mathbb{R}^{n_v} is the inner product of a coefficient vector with a basis vector that collects all 2nv2^{n_v} multilinear combinations of the variables,

f(๐ฏ)=๐œโŠค๐ฆ(๐ฏ),๐œโˆˆโ„2nv. f(\mathbf{v}) = \mathbf{c}^{\top}\, \mathbf{m}(\mathbf{v}), \qquad \mathbf{c}\in\mathbb{R}^{2^{n_v}} .

Two choices of that basis vector are in use, and they are what the mtiBase of an mss selects between:

๐ฆ(๐ฏ)=(1vn)โŠ—โ‹ฏโŠ—(1v1)โŸmonomial base๐ฆ(๐ฏ)=(1โˆ’vnvn)โŠ—โ‹ฏโŠ—(1โˆ’v1v1)โŸliteral base \underbrace{\mathbf{m}(\mathbf{v}) = \begin{pmatrix}1\\ v_{n}\end{pmatrix}\otimes\cdots\otimes \begin{pmatrix}1\\ v_{1}\end{pmatrix}}_{\text{monomial base}} \qquad \underbrace{\mathbf{m}(\mathbf{v}) = \begin{pmatrix}1-v_{n}\\ v_{n}\end{pmatrix}\otimes\cdots\otimes \begin{pmatrix}1-v_{1}\\ v_{1}\end{pmatrix}}_{\text{literal base}}

where โŠ—\otimes denotes the Kronecker product. The monomial base lists the monomials 1,v1,v2,v1v2,โ€ฆ1, v_1, v_2, v_1v_2, \dots; the literal base lists the products in which each variable occurs either negated (1โˆ’vi1-v_i) or non-negated (viv_i). In the literal base, the terminology is related to that of mathematical logic, where a literal is an occurrence of a variable in negated or non-negated form. It is therefore the natural one for the representation of functions that originate from Boolean logic.
Both bases span the same function space, so every multilinear function can be written in either one; only the coefficients differ.

Canonical polyadic normalized representation

The parameter tensor ๐™ตโˆˆโ„ร—(nv)2ร—N{\mathtt{F}}\in\mathbb{R}^{\times^{(n_v)}2\times N} of a multilinear vector function ๐Ÿ:โ„nvโ†’โ„N\mathbf{f}:\mathbb{R}^{n_v}\rightarrow\mathbb{R}^{N}
has a CP-decomposition

๐™ต=[๐…1,โ€ฆ,๐…nv,๐…ฮฆ], \mathtt{F}= {\left[{\mathbf{F}_{1},\dots,\mathbf{F}_{n_v}, \mathbf{F}_{\Phi}}\right]},

where ๐…iโˆˆโ„2ร—R\mathbf{F}_i\in\mathbb{R}^{2\times R} for i=1,โ€ฆ,nvi=1,\dots,n_v and a parameter matrix ๐…ฮฆโˆˆโ„Nร—R\mathbf{F}_{\Phi}\in\mathbb{R}^{N\times R}.

Normalizing every factor-matrix column with the 1-norm ||๐…i(:,r)||1=1\lvert\lvert\mathbf{F}_i(:,r)\rvert\rvert_{1}=1 gives the CPN1 (canonical polyadic norm-1) representation [2] used throughout this toolbox. After the normalization the rr-th column of the ii-th factor matrix is (1โˆ’|si,r|,si,r)โŠค\left(1-\lvert s_{i,r}\rvert,\; s_{i,r}\right)^{\top} and |si,r|โ‰ค1\lvert s_{i,r}\rvert \le 1, so each column carries a single degree of freedom. Because of this, the second rows of all factor matrices can be stacked into one structure matrix ๐’โˆˆโ„nvร—R\mathbf{S}\in\mathbb{R}^{n_v\times R}, and the column scalings are absorbed into the parameter matrix ๐šฝโˆˆโ„Nร—R\mathbf{\Phi}\in\mathbb{R}^{N\times R}:

si,r=sign(fi1,r)fi2,r|fi1,r|+|fi2,r|, s_{i,r} = \operatorname{sign}\!\left(f_{i_{1,r}}\right) \frac{f_{i_{2,r}}}{\lvert f_{i_{1,r}}\rvert + \lvert f_{i_{2,r}}\rvert},

๐šฝ=๐›ŒโŠก๐…ฮฆ,ฮปr=โˆi=1nvsign(fi1,r)(|fi1,r|+|fi2,r|), \mathbf{\Phi} = \boldsymbol{\lambda} \boxdot \mathbf{F}_{\Phi}, \quad \lambda_{r} = \prod_{i=1}^{n_v}\operatorname{sign}\!\left(f_{i_{1,r}}\right) \left(\lvert f_{i_{1,r}}\rvert + \lvert f_{i_{2,r}}\rvert\right),

with โŠก\boxdot the broadcast (element-wise Hadamard) product.

The model base

Contracting the normalized factor column (1โˆ’|s|,s)โŠค\left(1-\lvert s\rvert,\;s\right)^{\top} with the two-element basis vector of a variable vv gives the scalar factor function pbp_{b}, and the model base bb decides which basis vector is used:

pb(s,v)=(1โˆ’|s|)m1(v)+sm2(v),(m1,m2)={(1,v)b=0(monomial base)(1โˆ’v,v)b=1(literal base) p_{b}(s,v) = \left(1-\lvert s\rvert\right) m_{1}(v) + s\, m_{2}(v), \qquad \left(m_{1},m_{2}\right) = \begin{cases} \left(1,\; v\right) & b = 0 \quad\text{(monomial base)}\\[2pt] \left(1-v,\; v\right) & b = 1 \quad\text{(literal base)} \end{cases}

which written out is

p0(s,v)=1โˆ’|s|+sv, p_{0}(s,v) = 1-\lvert s\rvert + s\,v ,

p1(s,v)=(1โˆ’|s|)(1โˆ’v)+sv=1โˆ’|s|+(s+|s|โˆ’1)v. p_{1}(s,v) = \left(1-\lvert s\rvert\right)\left(1-v\right) + s\,v = 1-\lvert s\rvert + \left(s + \lvert s\rvert - 1\right) v .

References

[1] Lichtenberg, Gerwald; Pangalos, Georg; Cateriano Yรกรฑez, Carlos; Luxa, Aline; Jรถres, Niklas; Schnelle, Leona; Kaufmann, Christoph (2022): Implicit multilinear modeling. In at - Automatisierungstechnik 70 (1), pp.ย 13โ€“30. DOI: 10.1515/auto-2021-0133.

[2] N. Jรถres, C. Kaufmann, L. Schnelle, C. Yรกรฑez, G. Pangalos, and G. Lichtenberg, Reduced CP representation of multilinear models. In Proceedings of the 12th International Conference on Simulation and Modeling Methodologies, Technologies and Applications, Lisbon, Portugal, Jul.ย 2022, pp.ย 252โ€“259, DOI: 10.5220/0011273100003274.

[3] J.Cherian, E.UhIenberg, H.G.S.Maregowda, L.S.VaIIejos, T.Warnecke, and G. Lichtenberg (2026). Tensor train based explicit multilinear modeling and control of heating systems. 12th12^{th} CoDIT Conference. DOI: 10.1109/CoDIT70676.2026.11631280.

See also

mdss ยท msim ยท ss2mss ยท mlgreyest ยท mlinearize ยท CPNTensor ยท TTTensor ยท mss2mdss


MyToolbox Documentation | Generated automatically by CI/CD pipeline