Source code for stonesoup.models.transition.nonlinear

import copy

import numpy as np

from ...types.state import StateVector
from .base import _CombinedGaussianTransitionModel
from ..base import NonLinearModel

[docs]class CombinedNonlinearGaussianTransitionModel(_CombinedGaussianTransitionModel, NonLinearModel): r"""Combine multiple models into a single model by stacking them. The assumption is that all models are Gaussian. Time Variant, and Time Invariant models can be combined together. If any of the models are time variant the keyword argument "time_interval" must be supplied to all methods """
[docs] def function(self, state, **kwargs) -> StateVector: """Applies each transition model in :py:attr:`~model_list` in turn to the state's corresponding state vector components. For example, in a 3D state space, with :py:attr:`~model_list` = [modelA(ndim_state=2), modelB(ndim_state=1)], this would apply modelA to the state vector's 1st and 2nd elements, then modelB to the remaining 3rd element. Parameters ---------- state : :class:`stonesoup.state.State` The state to be transitioned according to the models in :py:attr:`~model_list`. Returns ------- state_vector: :class:`stonesoup.types.array.StateVector` of shape (:py:attr:`~ndim_state, 1`). The resultant state vector of the transition. """ temp_state = copy.copy(state) ndim_count = 0 state_vector = np.zeros((self.ndim_state, 1)).view(StateVector) for model in self.model_list: temp_state.state_vector =\ state.state_vector[ndim_count:model.ndim_state + ndim_count, :] state_vector[ndim_count:model.ndim_state + ndim_count, :] += model.function(temp_state, **kwargs) ndim_count += model.ndim_state return state_vector