root/bdm/stat/libDS.h @ 263

Revision 263, 2.4 kB (checked in by smidl, 15 years ago)

UIArxDS test

  • Property svn:eol-style set to native
Line 
1/*!
2  \file
3  \brief Common DataSources.
4  \author Vaclav Smidl.
5
6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
13#ifndef DS_H
14#define DS_H
15
16
17#include "libBM.h"
18#include "libEF.h"
19
20
21namespace bdm {
22        /*!
23        * \brief Memory storage of off-line data column-wise
24
25        The data are stored in an internal matrix \c Data . Each column of Data corresponds to one discrete time observation \f$t\f$. Access to this matrix is via indexes \c rowid and \c delays.
26
27        The data can be loaded from a file.
28        */
29        class MemDS : public DS {
30                //! internal matrix of data
31                mat Data;
32                //! active column in the Data matrix
33                int time;
34                //!  vector of rows that are presented in Dt
35                ivec rowid;
36                //! vector of delays that are presented in Dt
37                ivec delays;
38
39        public:
40                void getdata ( vec &dt );
41                void getdata ( vec &dt, const ivec &indeces );
42                void linkrvs ( RV &drv, RV &urv );
43                void write ( vec &ut ) {it_error ( "MemDS::write is not supported" );}
44                void write ( vec &ut,ivec &indexes ) {it_error ( "MemDS::write is not supported" );}
45                void step();
46                //!Default constructor
47                MemDS ( mat &Dat, ivec &rowid, ivec &delays );
48        };
49
50        /*!
51        \brief Generator of ARX data
52
53        */
54        class ArxDS : public DS {
55                //! Rv of the regressor
56                RV Rrv;
57                //! Rv of the history (full regressor)
58                RV Hrv;
59                //! Internal storage of results
60                vec Y;
61                //! History, ordered as \f$[u_t, y_{t-1 }, u_{t-1}, \ldots]\f$
62                vec H;
63                //! temporary variable for regressor
64                vec rgr;
65                //! data link: val = y, cond = u; local = rgr;
66                datalink_e2e rgrlnk;
67                //! model of Y - linear Gaussian
68                mlnorm<chmat> model;
69                public:
70                void getdata ( vec &dt ){it_assert_debug(dt.length()==Y.length(),"ArxDS"); 
71                        dt=concat(Y,H.left(Urv.count()));};
72                void getdata ( vec &dt, const ivec &indexes ){it_assert_debug(dt.length()==Y.length(),"ArxDS"); dt=Y(indexes);};
73                void write ( vec &ut ){it_assert_debug(ut.length()==Urv.count(),"ArxDS"); H.set_subvector(0,ut);};
74                void write ( vec &ut, const ivec &indexes ){it_assert_debug(ut.length()==Urv.count(),"ArxDS"); set_subvector(H,indexes,ut);};
75                void step();
76                //!Default constructor
77                ArxDS ( RV &drv, RV &urv, RV &rrv);
78                //! Set parameters of the internal model
79                void set_parameters(const mat &Th0, const vec mu0, const chmat &sqR0)
80                {model.set_parameters(Th0, mu0, sqR0); };
81        };
82
83}; //namespace
84
85#endif // DS_H
Note: See TracBrowser for help on using the browser.