jacobnzw / SSMToybox

Nonlinear Sigma-Point Kalman Filters based on Bayesian Quadrature
MIT License
12 stars 0 forks source link

Redesign StateSpaceModel and StateSpaceInference #5

Closed jacobnzw closed 5 years ago

jacobnzw commented 6 years ago

Problem with StateSpaceModel class

The class represents a too coarse a concept, which brings complications. Every time the process or measurement model changes, a new derived class of StateSpaceModel needs to be defined, which leads to combinatorial explosion of classes. For example, constant velocity model can be paired with any number of measurement models (range, bearing, range rate, any combination of these or any other).

TODO list

jacobnzw commented 5 years ago

Accommodating Different Distributions for Initial Conditions/Noises

Module: utils.py

Create a base class RandomVariable which will dictate common interface for all RVs. The distribution classes will have the following responsibilities:

Create subclass for each type of random variable. Instances will be fed to TransitionModel and MeasurementModel initializers. Local filters propagate mean and covariance only, regardless of the noise/init. distribution. Which means that the random variable should have a method for computing the mean and covariance from its distribution parameters (sufficient statistics). For example: Student's RV is parametrized by mean, scale matrix and dof. Covariance can be computed from scale matrix and dof.

Even though scipy.stats provide a bunch of random variables, the multivariate t and Gaussian mixtures are missing! Might use them though.

jacobnzw commented 5 years ago

Open Questions

Additional considerations

This issue started because of the following. Storage and passing of the SSM specifications. For example, currently CoordinatedTurnRadar class contains definitions of initial conditions and noise statistics in its __init__(), which I think is rather strange. The class should define both SSM functions and optionally also their Jacobians, and that's it. All the specs and statistics should be passed into the __init__() in the form of a dictionary (with predefined keys) on case by case basis depending on how each experiment is set up. This, of course, applies to all SSMs!

On the other hand, for ReentryVehicleRadarTracking it's very sensible to specify default values inside the initializer, because these values are highly specific and must make physical sense.

jacobnzw commented 5 years ago

Solution

Break down the SSM concept into process model and measurement model, which effectively amounts to splitting the StateSpaceModel class into base classes TransitionModel and MeasurementModel.

TransitionModel class responsibilities

  1. define continuous/discrete-time state transition function (system dynamics and noise coupling)
  2. define evaluation function, which takes care of the evaluation of the state transition under noise coupling (additive vs. non-additive)
  3. simulate the discrete-time state evolution for given time period (steps)
  4. simulate the continuous-time state evolution for given time [sec] and tau [sec]
  5. enable online setting of state transition function parameters (like discretization period etc.)

MeasurementModel class responsibilities:

  1. same as above
  2. simulate measurements given one state or sequence of states
  3. store input dimension of the measurement function (often lower than the state dimension)
  4. define evaluation function that additionally picks out the optionally specified indices of state

This division will have the following effects:

meas_eval() will have to pickout state dimensions using a optionally supplied list of indices where the relevant components of state vector are. For example: if state if x = [px, vx, py, vy, theta] and the measurement function is code with the assumption that x[0]=px and x[1]=py, then the supplied list should be [0, 2], because px is at x[0] and py is at x[2]. So the real input to MF is then [x[0], x[2]].