kkf.koopman#

Koopman operator approximation module.

Implements kernel-based Extended Dynamic Mode Decomposition (kEDMD) for computing Koopman operator approximations.

Classes

KoopmanOperator(kernel_function, ...)

Implementation of Koopman operator approximation using kernel-based Extended Dynamic Mode Decomposition (kEDMD).

class kkf.koopman.KoopmanOperator(kernel_function, dynamical_system)[source]#

Bases: object

Implementation of Koopman operator approximation using kernel-based Extended Dynamic Mode Decomposition (kEDMD).

This class provides methods to compute finite-dimensional approximations of the Koopman operator for nonlinear dynamical systems.

Parameters:
kernel_function#

Kernel function for computing feature space mappings.

Type:

Callable

dynamical_system#

The underlying dynamical system.

Type:

DynamicalSystem

X#

Dictionary of states used for kernel computations.

Type:

Optional[np.ndarray]

phi#

Feature map function.

Type:

Optional[Callable]

U#

Koopman operator matrix.

Type:

Optional[np.ndarray]

G#

Gram matrix.

Type:

Optional[np.ndarray]

C#

Output matrix.

Type:

Optional[np.ndarray]

B#

State-to-feature space transformation matrix.

Type:

Optional[np.ndarray]

Notes

The Koopman operator framework lifts nonlinear dynamics to a linear setting in a higher-dimensional feature space. This implementation uses kernel methods to compute the necessary feature spaces and operators.

compute_edmd(n_features, optimize=False, n_restarts_optimizer=10, reg=1e-10)[source]#

Compute the kernel-based Extended Dynamic Mode Decomposition (kEDMD).

This method constructs finite-dimensional approximations of the Koopman operator and associated matrices using kernel methods.

Parameters:
  • n_features (int) – Number of features to use in the approximation.

  • optimize (bool) – Whether to optimize the kernel function. If True, the method will optimize the kernel function using Gaussian Process Regression. If False, the provided kernel function will be used without optimization. Default is False (fast; enable it explicitly to fit kernel hyperparameters).

  • n_restarts_optimizer (int) – Number of restarts for the optimizer. If optimize is False, will be ignored. Default is 10.

  • reg (float) – Tikhonov (jitter) regularization added to the diagonal of the Gram matrix before inversion, scaled by its mean diagonal. Kernel Gram matrices are often ill-conditioned; a small positive value keeps the inversion numerically stable. Increase it if you see unstable estimates. Default is 1e-10.

Return type:

None

Notes

The method performs the following steps: 1. Generates dictionary points using the state distribution 2. Constructs the feature map using the kernel function 3. Computes the Gram matrix and its inverse 4. Constructs the Koopman operator approximation 5. Computes output and state transformation matrices

property dictionary: ndarray[tuple[Any, ...], dtype[float64]] | None#

Dictionary of sampled states (alias of X).

property feature_map: Callable | None#

Feature map function (alias of phi).

get_feature_dimension()[source]#

Get the dimension of the feature space.

Returns:

Dimension of the feature space, or None if EDMD hasn’t been computed.

Return type:

Optional[int]

property gram_matrix: ndarray[tuple[Any, ...], dtype[float64]] | None#

Kernel Gram matrix (alias of G).

property koopman_matrix: ndarray[tuple[Any, ...], dtype[float64]] | None#

Koopman operator approximation (alias of U).

opt_kernel(X, n_restarts_optimizer=10)[source]#

Deprecated alias for optimize_kernel().

Deprecated since version Use: optimize_kernel() instead. This alias will be removed in a future major release.

Parameters:
Return type:

None

optimize_kernel(X, n_restarts_optimizer=10)[source]#

Optimize the kernel function for the Koopman operator.

Parameters:
  • X (np.ndarray) – Set of points.

  • n_restarts_optimizer (int) – Number of restarts for the optimizer. Default is 10.

Return type:

None

Notes

This method uses Gaussian Process Regression to optimize the kernel function.

property output_matrix: ndarray[tuple[Any, ...], dtype[float64]] | None#

Feature-to-output matrix (alias of C).

property state_matrix: ndarray[tuple[Any, ...], dtype[float64]] | None#

Feature-to-state matrix (alias of B).