UDFlt.hpp

Go to the documentation of this file.
00001 #ifndef _BAYES_FILTER_UD
00002 #define _BAYES_FILTER_UD
00003 /*
00004  * Bayes++ the Bayesian Filtering Library
00005  * Copyright (c) 2002 Michael Stevens
00006  * See accompanying Bayes++.htm for terms and conditions of use.
00007  *
00008  * $Id: UDFlt.hpp 562 2006-04-05 20:46:23 +0200 (Wed, 05 Apr 2006) mistevens $
00009  */
00010 
00011 /*
00012  * UdU' Factorisation of covariance Filter Scheme.
00013  *  Implementation of a 'Square-root' linearised kalman filter
00014  * 
00015  * Bierman's UD factorisatised update algorithm using Agee-Turner UdU' factorisation rank 1 update
00016  * Thornton's MWG-S factorisation predict algorithm
00017  * References
00018  * [1] "Factorisation Methods for Discrete Sequential Estimation" Gerald J. Bierman ISBN 0-12-097350-2
00019  * [2] "Kalman Filtering, Theory and Practice", Mohinder S. Grewal, Angus P. Andrews ISBN 0-13-211335-X
00020  *
00021  * A initial observation size may also be specified for efficiency.
00022  * 
00023  * The filter is operated by performing a
00024  *  predict, observe
00025  * cycle defined by the base class
00026  */
00027 #include "bayesFlt.hpp"
00028 
00029 /* Filter namespace */
00030 namespace Bayesian_filter
00031 {
00032 
00033 class UD_sequential_observe_model : public Linrz_uncorrelated_observe_model
00034 {
00035 public:
00036     UD_sequential_observe_model (std::size_t x_size, std::size_t z_size) :
00037         Linrz_uncorrelated_observe_model(x_size, z_size), Hx_o(x_size)
00038     {}
00039     virtual const FM::Vec& ho (const FM::Vec& x, const std::size_t o) = 0;
00040     /* Supplied model (h) for observation using state x, z allows normalisation and model variation
00041        Fast model of a single element (o) in observation model
00042        Precondition: Hx_o is conformantly dimensioned
00043        Postcondition:
00044         z(k|k-1) = h(x(k|k-1)
00045         Hx_o(x(k-1|k-1) = Jacobian of h with respect to state x (row o)
00046     */
00047     FM::Vec Hx_o;
00048 };
00049 
00050 
00051 class UD_scheme : public Linrz_kalman_filter
00052 {
00053 private:
00054     std::size_t q_max;  // Maxiumum size allocated for noise model, constructed before UD
00055 public:
00056     FM::Matrix UD;  // UDU factorisation of X with D on diagonal
00057                         // Lower triangle used as workspace
00058     FM::Vec s;      // Innovation
00059     FM::Vec Sd;     // Innovation Covariance 
00060 
00061     UD_scheme (std::size_t x_size, std::size_t q_maxsize, std::size_t z_initialsize = 0);
00062     UD_scheme& operator= (const UD_scheme&);
00063     // Optimise copy assignment to only copy filter state
00064 
00065     void init ();
00066     void update ();
00067     Float predict (Linrz_predict_model& f);
00068 
00069     Float observe (Linrz_correlated_observe_model& h, const FM::Vec& z);
00070     /* No solution for Correlated noise and Linrz model */
00071     Float observe (Linrz_uncorrelated_observe_model& h, const FM::Vec& z);
00072     /* General observe */
00073 
00074     Float observe (Linear_correlated_observe_model& h, const FM::Vec& z);
00075     /* Special Linear observe for correlated Z, fast Z decorrelation */
00076     Float observe (UD_sequential_observe_model& h, const FM::Vec& z);
00077     /* Special Linrz observe using fast sequential model */
00078 
00079 protected:
00080     Float predictGq (const FM::Matrix& Fx, const FM::Matrix& G, const FM::Vec& q);
00081     FM::Vec d, dv, v;   // predictGQ temporaries
00082     Float observeUD (FM::Vec& gain, Float& alpha, const FM::Vec& h, const Float r);
00083     FM::Vec a, b;       // observeUD temporaries
00084                         // Observation temporaies
00085     void observe_size (std::size_t z_size);
00086     std::size_t last_z_size;
00087     FM::Vec h1;             // Single Observation model
00088     FM::Vec w;              // Single Gain
00089     FM::Vec znorm;          // Normalised innovation
00090     FM::Vec zpdecol;        // Decorrelated zp
00091     FM::Matrix Gz;          // Z coupling
00092     FM::Matrix GIHx;        // Modified Model for linear decorrelation
00093 };
00094 
00095 
00096 }//namespace
00097 #endif

Generated on Wed Oct 4 22:57:23 2006 for Bayes++ Bayesian Filtering Classes by  doxygen 1.4.6