fit()

fit()#

ContinuousModel.fit(states, ddts, inputs=None)[source]#

Learn the model operators from data.

The operators are inferred by solving the regression problem

\[\min_{\Ohat}\sum_{j=0}^{k-1}\left\| \fhat(\qhat_j, \u_j) - \dot{\qhat}_j \right\|_2^2 = \min_{\Ohat}\left\| \D\Ohat\trp - [~\dot{\qhat}_0~~\cdots~~\dot{\qhat}_{k-1}~]\trp \right\|_F^2\]

where \(\ddt\qhat(t) = \fhat(\qhat(t), \u(t))\) is the model and

  • \(\qhat_j\in\RR^r\) is the state at some time \(t_j\),

  • \(\u_j\in\RR^m\) is the input at time \(t_j\),

  • \(\dot{\qhat}_j\in\RR^r\) is the time derivative of the state at time \(t_j\), i.e., \(\dot{\qhat}_j = \ddt\qhat(t)\big|_{t=t_j}\),

  • \(\Ohat\in\RR^{r\times d(r,m)}\) is the operator matrix such that \(\fhat(\q,\u) = \Ohat\d(\qhat,\u)\) for some data vector \(\d(\qhat,\u)\in\RR^{d(r,m)}\), and

  • \(\D\in\RR^{k\times d(r,m)}\) is the data matrix given by \([~\d(\qhat_0,\u_0)~~\cdots~~\d(\qhat_{k-1},\u_{k-1})~]\trp\).

See the opinf.operators module for further explanation.

The strategy for solving the regression, as well as any additional regularization or constraints, are specified by the solver.

Parameters:
states(r, k) ndarray

Snapshot training data. Each column is a single snapshot.

ddts(r, k) ndarray

Snapshot time derivative data. Each column ddts[:, j] corresponds to the snapshot states[:, j].

inputs(m, k) or (k,) ndarray or None

Input training data. Each column inputs[:, j] corresponds to the snapshot states[:, j]. May be a one-dimensional array if m=1 (scalar input).

Returns:
self