Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign StateSpaceModel and StateSpaceInference #5

Closed
8 tasks done
jacobnzw opened this issue Jun 18, 2018 · 3 comments
Closed
8 tasks done

Redesign StateSpaceModel and StateSpaceInference #5

jacobnzw opened this issue Jun 18, 2018 · 3 comments
Assignees

Comments

@jacobnzw
Copy link
Owner

jacobnzw commented Jun 18, 2018

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

  • Define TransitionModel
  • Define MeasurementModel
  • Define RandomVariable and related sub-classes.
  • Rewrite all current SSM classes using sub-classes of TransitionModel and MeasurementModel
  • Masking of meas_eval() input, dim_in independent of the transition model, change indexes of x in meas_fcn() implementations to reflect these changes.
  • Provide recommended initial/noise statistics in the docstrings of each transition/measurement model.
  • Write tests for TransitionModel and its sub-classes
  • Write tests for MeasurementModel and its sub-classes
This was referenced Jul 4, 2018
@jacobnzw jacobnzw self-assigned this Jul 12, 2018
@jacobnzw jacobnzw reopened this Jul 12, 2018
@jacobnzw jacobnzw changed the title Rethink Implementations Redesign StateSpaceModel class Oct 2, 2018
@jacobnzw jacobnzw changed the title Redesign StateSpaceModel class Redesign StateSpaceModel class Oct 2, 2018
@jacobnzw jacobnzw changed the title Redesign StateSpaceModel class Redesign StateSpaceModel and StateSpaceInference Oct 2, 2018
@jacobnzw
Copy link
Owner Author

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:

  • store distribution statistics
  • sample from the distribution
  • (PDF evaluation, ...)

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
Copy link
Owner Author

Open Questions

  • Measurement model (MM)
    • Should there be one general MM for radar? In reality, radar measures range, bearing and range rate computed from (x, y, z). What if my problem is in 2D? This will require separate classes, because of Jacobians. 3D radar model has different Jacobian than 2D.
  • par_fcn() has no use, probably. Dependence of transition model parameters on time can be coded into dyn_fcn() anyway.
  • SSM simulation should probably be defined in utils.py as a function.
    • Need to accommodate situations like: simulate a system trajectory where measurements are obtained with given frequency. This kinda situation probably requires coordination between state and measurement simulation, hence one function.

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
Copy link
Owner Author

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:

  • TransitionModel and MeasurementModel classes passed to the StateSpaceInference initializer (instead of the StateSpaceModel object)
  • StateSpaceInference will have to be reworked;
  • derived classes, like GaussianInference, will probably still be retained
  • less classes necessary for specifying the SSMs
  • dynsys.py module will probably not be necessary

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]].

@jacobnzw jacobnzw closed this as completed Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant