simulate

Method of discreteTimeMss.

Do a discrete-time mss model forward sample by sample.

Source: src/simulator/@discreteTimeMss/simulate.m

What is solved

An mss state equation is explicit, so a sample is a single evaluation:

xk+1=ΦFm(xk,uk),k=1,,N1,x1=x0, x_{k+1} = \Phi_F\, m(x_k, u_k), \qquad k = 1,\dots,N-1, \qquad x_1 = x_0,

with Φ=Φc+Φ+1Φ1\Phi=\Phi_c+\Phi_{+1}-\Phi_{-1} and mm the norm-1 monomial vector over v=[xk;uk]v=[x_k;\,u_k]. The horizon is N=N= numel(inputTime); input row kk drives the step to sample k+1k{+}1, so the last input row is never used. On return sim.time is inputTime unchanged and sim.variableTrajectory is the nState×N state trajectory (states in rows).

CPN evaluation path

For a CPNTensor model the state-equation block is compiled once with CPNTensor.prepareForMTISIM and the entire horizon runs inside one MTISIM call in its multi-step mode, which feeds xkx_k back as the state block of vv without returning to MATLAB between samples.

That kernel mode requires the positional [states; inputs] variable layout — states first, inputs after — so the structure matrices are indexed with

𝚛𝚘𝚠𝙾𝚛𝚍𝚎𝚛=[𝚜𝚝𝚊𝚝𝚎𝙸𝚗𝚍𝚎𝚡;𝚒𝚗𝚙𝚞𝚝𝙸𝚗𝚍𝚎𝚡], \texttt{rowOrder} = [\,\texttt{stateIndex};\ \texttt{inputIndex}\,],

and this method is where that reorder belongs. For a model already in [x; u] layout rowOrder is the identity, but indexing a sparse matrix with it would still rebuild all three structure matrices nonzero by nonzero: MATLAB’s compressed-sparse-column storage keeps each column’s row indices ascending, so rows cannot be permuted in place, whereas a plain column slice is a contiguous copy. A triviality check (strictly ascending, first == 1, last == numel) proves the permutation is the identity, so the row indexing is skipped and the plain column slice is taken instead.

Generic tensor path

Any other mtiTensor is marched in a MATLAB loop, one call to computeFunctionValueMss per sample, using the same forward convention.

See also

discreteTimeMss · functionValue · msim · discreteSimulation


MyToolbox Documentation | Generated automatically by CI/CD pipeline