Control Models

class stonesoup.models.control.base.ControlModel[source]

Bases: Model

Control Model base class

property ndim: int

Number of dimensions of model

abstract property ndim_ctrl: int

Number of control input dimensions

abstractmethod function(control_input, prior=None, noise=False, **kwargs)[source]

Control Model function \(b_k(u(k),x(k),w(k))\)

Parameters:
  • control_input (State, optional) – \(\mathbf{u}_k\)

  • prior (State) – The prior state, \(\mathbf{x}_{k-1}\)

  • noise (numpy.ndarray or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output of rvs() is used)

Returns:

The StateVector(s) with the model function evaluated.

Return type:

StateVector or StateVectors

class stonesoup.models.control.linear.BaseLinearControlModel(seed: int | None = None, control_noise: ndarray = None)[source]

Bases: ControlModel, LinearModel, GaussianModel, ABC

Parameters:
  • seed (Optional[int], optional) – Seed for random number generation

  • control_noise (numpy.ndarray, optional) – Control input noise covariance at time \(k\)

control_noise: ndarray

Control input noise covariance at time \(k\)

abstractmethod matrix(**kwargs)[source]

Model matrix

function(control_input, prior=None, noise=False, **kwargs) StateVector[source]

Control Model function \(b_k(u(k),x(k),w(k))\)

Parameters:
  • control_input (State, optional) – \(\mathbf{u}_k\)

  • prior (State) – The prior state, \(\mathbf{x}_{k-1}\)

  • noise (numpy.ndarray or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output of rvs() is used)

Returns:

The StateVector(s) with the model function evaluated.

Return type:

StateVector or StateVectors

covar(**kwargs)[source]

Model covariance

class stonesoup.models.control.linear.LinearControlModel(control_matrix: ndarray, seed: int | None = None, control_noise: ndarray = None)[source]

Bases: BaseLinearControlModel

Implements a linear effect to the state vector via,

\[\hat{x}_k = B_k (\mathbf{u}_k + \gamma_k)\]

where \(B_k\) is the control-input model matrix (i.e. control matrix), \(\mathbf{u}_k\) is the control vector and \(\gamma_k\) is sampled from zero-mean white noise distribution \(\mathcal{N}(0,\Gamma_k)\)

Parameters:
  • control_matrix (numpy.ndarray) – Control input model matrix at time \(k\), \(B_k\)

  • seed (Optional[int], optional) – Seed for random number generation

  • control_noise (numpy.ndarray, optional) – Control input noise covariance at time \(k\)

control_matrix: ndarray

Control input model matrix at time \(k\), \(B_k\)

property ndim_ctrl

Number of control input dimensions

matrix(**kwargs) ndarray[source]
Returns:

the control-input model matrix, \(B_k\)

Return type:

numpy.ndarray

class stonesoup.models.control.linear.TransitionBasedLinearControlModel(transition_model: TransitionModel, mapping: Sequence[int], seed: int | None = None, control_noise: ndarray = None, output_in_state_vector: bool = False)[source]

Bases: BaseLinearControlModel

A model that applies an Nth Derivative Transition Model over a specified time period. This is just a LinearControlModel which accepts a time_interval input to compute the control matrix.

A derivative ordered state vector is assumed (e.g., \([x, \dot{x}, \ldots, y, \dot{y}, \dots]^T\)).:

Parameters:
  • transition_model (TransitionModel) – Transition model to apply

  • mapping (collections.abc.Sequence) – Mapping to Nth Derivatives of transition model

  • seed (Optional[int], optional) – Seed for random number generation

  • control_noise (numpy.ndarray, optional) – Control input noise covariance at time \(k\)

  • output_in_state_vector (bool, optional) – This flag determines whether the control input is dimensions are already in the statevector (True) or not (False).

transition_model: TransitionModel

Transition model to apply

mapping: Sequence[int]

Mapping to Nth Derivatives of transition model

output_in_state_vector: bool

This flag determines whether the control input is dimensions are already in the statevector (True) or not (False).

property ndim_ctrl

Number of control input dimensions

matrix(time_interval, **kwargs) ndarray[source]
Parameters:

time_interval (datetime.timedelta) – A time interval. Note the units used are \(s\) so accelerations are implicitly per second squared.

Returns:

the control-input model matrix, \(B_k\)

Return type:

numpy.ndarray