Bayes++ Bayesian Filtering Classes  Release 2014.5 - Copyright (c) 2003,2004,2005,2006,2011,2012,2014 Michael Stevens
itrFlt.hpp
Go to the documentation of this file.
1 #ifndef _BAYES_FILTER_ITERATED_COVARIANCE
2 #define _BAYES_FILTER_ITERATED_COVARIANCE
3 
4 /*
5  * Bayes++ the Bayesian Filtering Library
6  * Copyright (c) 2002 Michael Stevens
7  * See accompanying Bayes++.htm for terms and conditions of use.
8  *
9  * $Id$
10  */
11 
12 /*
13  * Iterated Covariance Filter Scheme.
14  * A non-linear Covariance (Kalman) filter with relinearisation and iteration
15  *
16  * The observe algorithm uses the iterated non-linear formulation
17  * from Bar-Shalom and Fortmann p.119 (full scheme)
18  * Discontinuous observe models require that state is normalised with
19  * respect to the observation.
20  *
21  * The filter is operated by performing a
22  * predict, observe
23  * cycle defined by the base class
24  */
25 #include "bayesFlt.hpp"
26 
27 /* Filter namespace */
28 namespace Bayesian_filter
29 {
30 
31 class Iterated_covariance_scheme;
32 
34 /* Linrz observation model which can be iterated
35  Hx can be relinearised
36  */
37 {
38 protected: // model is not sufficient, it is used to build observe model's
40  {}
41 public:
42  virtual void relinearise (const FM::Vec& x) = 0;
43  // Relinearised about state x
44 };
45 
46 
48 /*
49  * Termination condition for filter Iteration
50  * Used by iterated observe to parameterise termination condition
51  * If iteration continues, the terminator must also relinearise the model about the filters new state
52  *
53  * Defaults to immediately terminating the iteration
54  *
55  * A more useful terminator can built by derivation.
56  * For example terminator constructed with a reference to the filter and model can
57  * detect convergence of x and/or X
58  */
59 {
60 public:
62  {
63  return true;
64  }
65 };
66 
68 /* Termination condition with a simple fixed number of iterations
69  */
70 {
71 public:
72  Counted_iterated_terminator (Iterated_observe_model& model, unsigned iterations) :
73  m(model), i(iterations)
74  {}
75  bool term_or_relinearize (const Iterated_covariance_scheme& f);
77  unsigned i;
78 };
79 
80 
81 
83 {
84 public:
85  Iterated_covariance_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
86  /* Initialised filter requires an addition iteration limit for the
87  observe algorithm */
89  // Optimise copy assignment to only copy filter state
90 
91  void init ();
92  void update ();
93  Float predict (Linrz_predict_model& f);
94 
97  // Observe with iteration
99  { // Observe with default termination
100  Iterated_terminator term;
101  return observe (h, term, z);
102  }
104  { // Observe with default termination
105  Iterated_terminator term;
106  return observe (h, term, z);
107  }
108 
109 public: // Exposed Numerical Results
110  FM::SymMatrix S, SI; // Innovation Covariance and Inverse
111 
112 protected: // Permanently allocated temps
114 
115 protected: // allow fast operation if z_size remains constant
116  std::size_t last_z_size;
117  void observe_size (std::size_t z_size);
118  // Permanently allocated temps
121 };
122 
123 
124 }//namespace
125 #endif
Iterated_observe_model()
Definition: itrFlt.hpp:39
FM::RowMatrix tempX
Definition: itrFlt.hpp:113
FM::SymMatrix SI
Definition: itrFlt.hpp:110
Counted_iterated_terminator(Iterated_observe_model &model, unsigned iterations)
Definition: itrFlt.hpp:72
Definition: itrFlt.hpp:47
Definition: bayesFlt.hpp:588
Definition: bayesFlt.hpp:226
Float observe(Linrz_correlated_observe_model &h, const FM::Vec &z)
Definition: itrFlt.hpp:103
Definition: bayesException.hpp:20
FM::Vec s
Definition: itrFlt.hpp:119
FM::Matrix HxT
Definition: itrFlt.hpp:120
Iterated_observe_model & m
Definition: itrFlt.hpp:76
FMVec< detail::BaseVector > Vec
Definition: uBLASmatrix.hpp:323
Definition: bayesFlt.hpp:33
RowMatrix Matrix
Definition: uBLASmatrix.hpp:325
std::size_t last_z_size
Definition: itrFlt.hpp:116
Float observe(Linrz_uncorrelated_observe_model &h, const FM::Vec &z)
Definition: itrFlt.hpp:98
Bayesian_filter_matrix::Float Float
Definition: bayesFlt.hpp:39
FMMatrix< detail::SymMatrixWrapper< detail::BaseRowMatrix > > SymMatrix
Definition: uBLASmatrix.hpp:327
virtual void relinearise(const FM::Vec &x)=0
unsigned i
Definition: itrFlt.hpp:77
Definition: bayesFlt.hpp:177
FMMatrix< detail::BaseRowMatrix > RowMatrix
Definition: uBLASmatrix.hpp:324
virtual bool term_or_relinearize(const Iterated_covariance_scheme &f)
Definition: itrFlt.hpp:61