indii/ml/filter/Filter.hpp

00001 #ifndef INDII_ML_FILTER_FILTER_HPP
00002 #define INDII_ML_FILTER_FILTER_HPP
00003 
00004 #include "../aux/vector.hpp"
00005 #include "../aux/GaussianPdf.hpp"
00006 
00007 namespace indii {
00008   namespace ml {
00009     namespace filter {
00010 /**
00011  * Abstract %filter.
00012  *
00013  * @author Lawrence Murray <lawrence@indii.org>
00014  * @version $Rev: 544 $
00015  * @date $Date: 2008-09-01 15:04:39 +0100 (Mon, 01 Sep 2008) $
00016  *
00017  * @param T The type of time.
00018  * @param P The type of probability distribution used to represent the
00019  * system state. 
00020  * 
00021  * @see indii::ml::filter for general usage guidelines.
00022  */
00023 template <class T = unsigned int, class P = indii::ml::aux::GaussianPdf>
00024 class Filter {
00025 public:
00026   /**
00027    * Constructor.
00028    *
00029    * @param p_x0 \f$p(\mathbf{x}_0)\f$; prior over the initial state
00030    * \f$\mathbf{x}_0\f$.
00031    */
00032   Filter(const P& p_x0);
00033 
00034   /**
00035    * Destructor.
00036    */
00037   virtual ~Filter();
00038 
00039   /**
00040    * Get the current time.
00041    *
00042    * @return \f$t_n\f$; the current time.
00043    */
00044   T getTime() const;
00045 
00046   /**
00047    * Set the current time.
00048    *
00049    * @param tn \f$t_n\f$; the current time.
00050    */
00051   void setTime(const T tn);
00052 
00053   /**
00054    * Get filter density.
00055    *
00056    * @return \f$p(\mathbf{x}(t_n)\,|\,\mathbf{y}_{1:n}\f$; the filter
00057    * density at the current time.
00058    */
00059   P& getFilteredState();
00060 
00061   /**
00062    * Set the filter density.
00063    *
00064    * @return \f$p(\mathbf{x}(t_n)\,|\,\mathbf{y}_{1:n}\f$; the filter
00065    * density at the current time.
00066    */
00067   void setFilteredState(const P& p_xtn_ytn);
00068 
00069   /**
00070    * Advance system to time of next measurement.
00071    *
00072    * @param tnp1 \f$t_{n+1}\f$; the time to which to advance the
00073    * system. This must be greater than the current time \f$t_n\f$.
00074    * @param ytnp1 \f$\mathbf{y}_{n+1}\f$; measurement at time
00075    * \f$t_{n+1}\f$.
00076    */
00077   virtual void filter(const T tnp1, const indii::ml::aux::vector& ytnp1)
00078       = 0;
00079 
00080   /**
00081    * Apply the measurement function to the current filtered state to
00082    * obtain an estimated measurement.
00083    *
00084    * @return The estimated measurement.
00085    */
00086   virtual P measure() = 0;
00087 
00088 protected:
00089   /**
00090    * \f$t_n\f$; the current time. For internal use only.
00091    */
00092   T tn;
00093 
00094   /**
00095    * \f$p(\mathbf{x}(t_n)\,|\,\mathbf{y}_{1:n}\f$; the filter
00096    * density at the current time.
00097    */
00098   P p_xtn_ytn;
00099 
00100 };
00101 
00102     }
00103   }
00104 }
00105 
00106 template <class T, class P>
00107 indii::ml::filter::Filter<T,P>::Filter(const P& p_x0) : p_xtn_ytn(p_x0) {
00108   this->tn = 0;
00109 }
00110 
00111 template <class T, class P>
00112 indii::ml::filter::Filter<T,P>::~Filter() {
00113   //
00114 }
00115 
00116 template <class T, class P>
00117 inline T indii::ml::filter::Filter<T,P>::getTime() const {
00118   return this->tn;
00119 }
00120 
00121 template <class T, class P>
00122 void indii::ml::filter::Filter<T,P>::setTime(const T tn) {
00123   this->tn = tn;
00124 }
00125 
00126 template <class T, class P>
00127 inline P& indii::ml::filter::Filter<T,P>::getFilteredState() {
00128   return this->p_xtn_ytn;
00129 }
00130 
00131 template <class T, class P>
00132 void indii::ml::filter::Filter<T,P>::setFilteredState(const P& p_xtn_ytn) {
00133   this->p_xtn_ytn = p_xtn_ytn;
00134 }
00135 
00136 #endif
00137 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3