00001 #ifndef _BAYES_FILTER__MODELS
00002 #define _BAYES_FILTER__MODELS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <boost/function.hpp>
00020
00021
00022 namespace Bayesian_filter
00023 {
00024
00025 typedef boost::function1<const FM::Vec&, const FM::Vec&> State_function;
00026
00027
00028
00029 class Simple_addative_predict_model : public Addative_predict_model
00030
00031 {
00032 State_function ff;
00033 public:
00034 Simple_addative_predict_model (State_function f_init, const FM::Matrix& G_init, const FM::Vec& q_init);
00035
00036
00037
00038
00039 virtual const FM::Vec& f(const FM::Vec& x) const
00040 { return ff(x);
00041 }
00042 };
00043
00044 class Simple_linrz_predict_model : public Linrz_predict_model
00045
00046 {
00047 State_function ff;
00048 public:
00049 Simple_linrz_predict_model (State_function f_init, const FM::Matrix& Fx_init, const FM::Matrix& G_init, const FM::Vec& q_init);
00050
00051
00052
00053
00054 virtual const FM::Vec& f(const FM::Vec& x) const
00055 { return ff(x);
00056 }
00057 };
00058
00059 class Simple_linear_predict_model : public Linear_predict_model
00060
00061 {
00062 public:
00063 Simple_linear_predict_model (const FM::Matrix& Fx_init, const FM::Matrix& G_init, const FM::Vec& q_init);
00064
00065 };
00066
00067
00068 class Simple_linrz_correlated_observe_model : public Linrz_correlated_observe_model
00069
00070 {
00071 State_function ff;
00072 public:
00073 Simple_linrz_correlated_observe_model (State_function f_init, const FM::Matrix& Hx_init, const FM::SymMatrix& Z_init);
00074
00075
00076
00077 virtual const FM::Vec& h(const FM::Vec& x) const
00078 { return ff(x);
00079 }
00080 };
00081
00082 class Simple_linrz_uncorrelated_observe_model : public Linrz_uncorrelated_observe_model
00083
00084 {
00085 State_function ff;
00086 public:
00087 Simple_linrz_uncorrelated_observe_model (State_function f_init, const FM::Matrix& Hx_init, const FM::Vec& Zv_init);
00088
00089
00090
00091 virtual const FM::Vec& h(const FM::Vec& x) const
00092 { return ff(x);
00093 }
00094 };
00095
00096 class Simple_linear_correlated_observe_model : public Linear_correlated_observe_model
00097
00098 {
00099 public:
00100 Simple_linear_correlated_observe_model (const FM::Matrix& Hx_init, const FM::SymMatrix& Z_init);
00101
00102 };
00103
00104 class Simple_linear_uncorrelated_observe_model : public Linear_uncorrelated_observe_model
00105
00106 {
00107 public:
00108 Simple_linear_uncorrelated_observe_model (const FM::Matrix& Hx_init, const FM::Vec& Zv_init);
00109
00110 };
00111
00112
00113
00114
00115
00116
00117
00118
00119 class Adapted_Correlated_addative_observe_model : public Correlated_addative_observe_model
00120
00121
00122
00123
00124 {
00125 public:
00126 Adapted_Correlated_addative_observe_model (Uncorrelated_addative_observe_model& adapt);
00127 const FM::Vec& h(const FM::Vec& x) const
00128 {
00129 return unc.h(x);
00130 }
00131 inline void normalise (FM::Vec& z_denorm, const FM::Vec& z_from) const
00132 {
00133 unc.normalise (z_denorm, z_from);
00134 };
00135 private:
00136 Uncorrelated_addative_observe_model& unc;
00137 };
00138
00139 class Adapted_Linrz_correlated_observe_model : public Linrz_correlated_observe_model
00140
00141
00142
00143
00144 {
00145 public:
00146 Adapted_Linrz_correlated_observe_model (Linrz_uncorrelated_observe_model& adapt);
00147 const FM::Vec& h(const FM::Vec& x) const
00148 {
00149 return unc.h(x);
00150 }
00151 inline void normalise (FM::Vec& z_denorm, const FM::Vec& z_from) const
00152 {
00153 unc.normalise (z_denorm, z_from);
00154 };
00155 protected:
00156 Linrz_uncorrelated_observe_model& unc;
00157 };
00158
00159
00160
00161
00162
00163
00164
00165 class General_LzUnAd_observe_model : public Linrz_uncorrelated_observe_model, public Likelihood_observe_model
00166 {
00167 public:
00168 General_LzUnAd_observe_model (std::size_t x_size, std::size_t z_size) :
00169 Linrz_uncorrelated_observe_model(x_size, z_size),
00170 Likelihood_observe_model(z_size),
00171 li(z_size)
00172 {}
00173 virtual Float L(const FM::Vec& x) const
00174
00175 { return li.L(*this, z, h(x));
00176 }
00177 virtual void Lz (const FM::Vec& zz)
00178
00179
00180 { Likelihood_observe_model::z = zz;
00181 li.Lz(*this);
00182 }
00183 private:
00184 friend class General_LiUnAd_observe_model;
00185 struct Likelihood_uncorrelated
00186 {
00187 Likelihood_uncorrelated(std::size_t z_size) :
00188 zInnov(z_size), Zv_inv(z_size)
00189 { zset = false;
00190 }
00191 mutable FM::Vec zInnov;
00192 FM::Vec Zv_inv;
00193 Float logdetZ;
00194 bool zset;
00195 Float L(const Uncorrelated_addative_observe_model& model, const FM::Vec& z, const FM::Vec& zp) const;
00196
00197 void Lz(const Uncorrelated_addative_observe_model& model);
00198 };
00199 Likelihood_uncorrelated li;
00200 };
00201
00202
00203 class General_LiUnAd_observe_model : public Linear_uncorrelated_observe_model, public Likelihood_observe_model
00204 {
00205 public:
00206 General_LiUnAd_observe_model (std::size_t x_size, std::size_t z_size) :
00207 Linear_uncorrelated_observe_model(x_size, z_size),
00208 Likelihood_observe_model(z_size),
00209 li(z_size)
00210 {}
00211 virtual Float L(const FM::Vec& x) const
00212
00213 { return li.L(*this, z, h(x));
00214 }
00215 virtual void Lz (const FM::Vec& zz)
00216
00217
00218 { Likelihood_observe_model::z = zz;
00219 li.Lz(*this);
00220 }
00221
00222 private:
00223 General_LzUnAd_observe_model::Likelihood_uncorrelated li;
00224 };
00225
00226
00227 class General_LzCoAd_observe_model : public Linrz_correlated_observe_model, public Likelihood_observe_model
00228 {
00229 public:
00230 General_LzCoAd_observe_model (std::size_t x_size, std::size_t z_size) :
00231 Linrz_correlated_observe_model(x_size, z_size),
00232 Likelihood_observe_model(z_size),
00233 li(z_size)
00234 {}
00235 virtual Float L(const FM::Vec& x) const
00236
00237 { return li.L(*this, z, h(x));
00238 }
00239 virtual void Lz (const FM::Vec& zz)
00240
00241
00242 { Likelihood_observe_model::z = zz;
00243 li.Lz(*this);
00244 }
00245
00246 private:
00247 friend class General_LiCoAd_observe_model;
00248 struct Likelihood_correlated
00249 {
00250 Likelihood_correlated(std::size_t z_size) :
00251 zInnov(z_size), Z_inv(z_size,z_size)
00252 { zset = false;
00253 }
00254 mutable FM::Vec zInnov;
00255 FM::SymMatrix Z_inv;
00256 Float logdetZ;
00257 bool zset;
00258 static Float scaled_vector_square(const FM::Vec& v, const FM::SymMatrix& V);
00259 Float L(const Correlated_addative_observe_model& model, const FM::Vec& z, const FM::Vec& zp) const;
00260
00261 void Lz(const Correlated_addative_observe_model& model);
00262 };
00263 Likelihood_correlated li;
00264 };
00265
00266
00267 class General_LiCoAd_observe_model : public Linear_correlated_observe_model, public Likelihood_observe_model
00268 {
00269 public:
00270 General_LiCoAd_observe_model (std::size_t x_size, std::size_t z_size) :
00271 Linear_correlated_observe_model(x_size, z_size),
00272 Likelihood_observe_model(z_size),
00273 li(z_size)
00274 {}
00275 virtual Float L(const FM::Vec& x) const
00276
00277 { return li.L(*this, z, h(x));
00278 }
00279 virtual void Lz (const FM::Vec& zz)
00280
00281
00282 { Likelihood_observe_model::z = zz;
00283 li.Lz(*this);
00284 }
00285
00286 private:
00287 General_LzCoAd_observe_model::Likelihood_correlated li;
00288 };
00289
00290
00291 }
00292
00293 #endif