state_space module
- class dynamapp.state_space.StateSpace(a: jax.numpy.ndarray, b: jax.numpy.ndarray, c: jax.numpy.ndarray, d: jax.numpy.ndarray, k: jax.numpy.ndarray = None, x_init: jax.numpy.ndarray = None, y_column_names: List[str] = None, u_column_names: List[str] = None)[source]
Bases:
object
A state-space model defined by the following equations:
\[\begin{split}\begin{cases} x_{k+1} &= A x_k + B u_k + K e_k \\ y_k &= C x_k + D u_k + e_k \end{cases}\end{split}\]The shapes of the matrices are checked for consistency and will raise if inconsistent. If a matrix does not exist in the model representation, the corresponding
jnp.ndarray
should have dimension zero along that axis. See the example below.Example
An autonomous state-space model has no matrices \(B\) and \(D\). An autonomous model with a one-dimensional internal state and output, can be represented as follows:
>>> model = StateSpace( >>> jnp.ones((1, 1)), >>> jnp.ones((1, 0)), >>> jnp.ones((1, 1)), >>> jnp.ones((1, 0)) >>> )
- param a:
matrix \(A\)
- param b:
matrix \(B\)
- param c:
matrix \(C\)
- param d:
matrix \(D\)
- param k:
matrix \(K\), optional
- param x_init:
initial state \(x_0\) of the model, optional
- param y_column_names:
list of output column names, optional
- param u_column_names:
list of input column names, optional
- set_matrices(a: jax.numpy.ndarray, b: jax.numpy.ndarray, c: jax.numpy.ndarray, d: jax.numpy.ndarray, k: jax.numpy.ndarray = None)[source]
Validate if the shapes make sense and set the system matrices.
- step(u: jax.numpy.ndarray = None, e: jax.numpy.ndarray = None) jax.numpy.ndarray [source]
Calculates the output of the state-space model and returns it. Updates the internal state of the model as well. The input
u
is optional, as is the noisee
.
- output(x: jax.numpy.ndarray, u: jax.numpy.ndarray = None, e: jax.numpy.ndarray = None)[source]
Calculate the output of the state-space model. This function calculates the updated \(y_k\) of the state-space model in the class description. The current state
x
is required. Providing an inputu
is optional. Providing a noise terme
to be added is optional as well.