45 | | <a name="l00054"></a><a class="code" href="classbdm_1_1ArxDS.html">00054</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1ArxDS.html" title="Generator of ARX data.">ArxDS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
46 | | <a name="l00055"></a>00055 <span class="keyword">protected</span>: |
47 | | <a name="l00057"></a><a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb">00057</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a>; |
48 | | <a name="l00059"></a><a class="code" href="classbdm_1_1ArxDS.html#d910dcb5d0c1132f1cffad2c91348b3f">00059</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1ArxDS.html#d910dcb5d0c1132f1cffad2c91348b3f" title="Rv of the history (full regressor).">Hrv</a>; |
49 | | <a name="l00061"></a><a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597">00061</a> vec <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
50 | | <a name="l00063"></a><a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5">00063</a> vec <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>; |
51 | | <a name="l00065"></a><a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe">00065</a> vec <a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe" title="temporary variable for regressor">rgr</a>; |
52 | | <a name="l00067"></a><a class="code" href="classbdm_1_1ArxDS.html#2d30d78ba1f16d66267ab8fc2c9cfb5d">00067</a> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> *<a class="code" href="classbdm_1_1ArxDS.html#2d30d78ba1f16d66267ab8fc2c9cfb5d" title="data link: H -&gt; rgr">rgrlnk</a>; |
53 | | <a name="l00069"></a><a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb">00069</a> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<chmat></a> <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>; |
54 | | <a name="l00071"></a><a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1">00071</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>; |
55 | | <a name="l00073"></a><a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85">00073</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>; |
56 | | <a name="l00074"></a>00074 <span class="keywordtype">int</span> L_R; |
57 | | <a name="l00075"></a>00075 <span class="keyword">public</span>: |
58 | | <a name="l00076"></a><a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595">00076</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) { |
59 | | <a name="l00077"></a>00077 it_assert_debug ( dt.length() ==<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.count(),<span class="stringliteral">"ArxDS"</span> ); |
60 | | <a name="l00078"></a>00078 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.left ( <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() +<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() ); |
61 | | <a name="l00079"></a>00079 }; |
62 | | <a name="l00080"></a><a class="code" href="classbdm_1_1ArxDS.html#fd61140869637b91bc23215ab7f45d3b">00080</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt, <span class="keyword">const</span> ivec &indexes ) { |
63 | | <a name="l00081"></a>00081 it_assert_debug ( dt.length() ==indeces.length(),<span class="stringliteral">"ArxDS"</span> ); |
64 | | <a name="l00082"></a>00082 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a> ( indexes ); |
65 | | <a name="l00083"></a>00083 }; |
66 | | <a name="l00084"></a><a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940">00084</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ) { |
67 | | <a name="l00085"></a>00085 it_assert_debug ( ut.length() ==<a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.count(),<span class="stringliteral">"ArxDS"</span> ); |
68 | | <a name="l00086"></a>00086 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>=ut; |
69 | | <a name="l00087"></a>00087 }; |
70 | | <a name="l00088"></a><a class="code" href="classbdm_1_1ArxDS.html#7240ea989a6453e58468feea319dcf0b">00088</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut, <span class="keyword">const</span> ivec &indexes ) { |
71 | | <a name="l00089"></a>00089 it_assert_debug ( ut.length() ==indeces.length(),<span class="stringliteral">"ArxDS"</span> ); |
72 | | <a name="l00090"></a>00090 set_subvector ( <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>, indexes,ut ); |
73 | | <a name="l00091"></a>00091 }; |
74 | | <a name="l00092"></a>00092 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#57dfa26b23cc03d53b123fa7e0474b19" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>(); |
75 | | <a name="l00094"></a><a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849">00094</a> <a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849" title="Default constructor.">ArxDS</a> ( ){}; |
76 | | <a name="l00096"></a><a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a">00096</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a" title="Set parameters of the internal model.">set_parameters</a> ( <span class="keyword">const</span> mat &Th0, <span class="keyword">const</span> vec mu0, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &sqR0 ) |
77 | | <a name="l00097"></a>00097 { <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#5d18dec3167584338a4775c1d165d96f" title="Set A and R.">set_parameters</a> ( Th0, mu0, sqR0 ); }; |
78 | | <a name="l00099"></a><a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436">00099</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436" title="set options from a string">set_options</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &s ) { |
79 | | <a name="l00100"></a>00100 <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>= ( s.find ( <span class="stringliteral">"L_theta"</span> ) !=string::npos ); |
80 | | <a name="l00101"></a>00101 }; |
81 | | <a name="l00102"></a><a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52">00102</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52" title="Register DS for logging into logger L.">log_add</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
82 | | <a name="l00103"></a>00103 <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">DS::log_add</a> ( L ); |
83 | | <a name="l00104"></a>00104 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
84 | | <a name="l00105"></a>00105 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
85 | | <a name="l00106"></a>00106 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {<a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1" title="returns an identifier which will be later needed for calling the log() function">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{theta }"</span>, vec_1 ( A.rows() *A.cols() ) ),<span class="stringliteral">"t"</span> );} |
86 | | <a name="l00107"></a>00107 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L_R=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1" title="returns an identifier which will be later needed for calling the log() function">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{R }"</span>, vec_1 ( R.rows() *R.cols() ) ),<span class="stringliteral">"r"</span> );} |
87 | | <a name="l00108"></a>00108 } |
88 | | <a name="l00109"></a><a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90">00109</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90" title="Register DS for logging into logger L.">logit</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
89 | | <a name="l00110"></a>00110 <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">DS::logit</a> ( L ); |
90 | | <a name="l00111"></a>00111 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
91 | | <a name="l00112"></a>00112 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
92 | | <a name="l00113"></a>00113 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>,vec ( A._data(), A.rows() *A.cols() ) );}; |
93 | | <a name="l00114"></a>00114 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_R, vec ( R._data(), R.rows() *R.rows() ) );}; |
94 | | <a name="l00115"></a>00115 } |
95 | | <a name="l00116"></a>00116 |
96 | | <a name="l00117"></a>00117 }; |
97 | | <a name="l00118"></a>00118 |
98 | | <a name="l00119"></a>00119 <span class="keyword">class </span>ARXDS : <span class="keyword">public</span> ArxDS { |
99 | | <a name="l00120"></a>00120 <span class="keyword">public</span>: |
100 | | <a name="l00121"></a>00121 ARXDS ( ) : ArxDS ( ) {} |
101 | | <a name="l00122"></a>00122 |
102 | | <a name="l00123"></a>00123 <span class="keywordtype">void</span> getdata ( vec &dt ) {dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>;} |
103 | | <a name="l00124"></a>00124 <span class="keywordtype">void</span> getdata ( vec &dt, <span class="keyword">const</span> ivec &indeces ) {dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a> ( indeces );} |
104 | | <a name="l00125"></a>00125 <span class="keyword">virtual</span> RV _drv()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1ArxDS.html#d910dcb5d0c1132f1cffad2c91348b3f" title="Rv of the history (full regressor).">Hrv</a>;} |
105 | | <a name="l00126"></a>00126 |
106 | | <a name="l00127"></a>00127 }; |
107 | | <a name="l00128"></a>00128 |
108 | | <a name="l00129"></a>00129 <span class="keyword">class </span>stateDS : <span class="keyword">public</span> DS { |
109 | | <a name="l00130"></a>00130 <span class="keyword">protected</span>: |
110 | | <a name="l00132"></a>00132 mpdf* IM; |
111 | | <a name="l00134"></a>00134 mpdf* OM; |
112 | | <a name="l00136"></a>00136 vec dt; |
113 | | <a name="l00138"></a>00138 vec xt; |
114 | | <a name="l00140"></a>00140 vec ut; |
115 | | <a name="l00142"></a>00142 <span class="keywordtype">int</span> L_xt; |
116 | | <a name="l00143"></a>00143 <span class="keyword">public</span>: |
117 | | <a name="l00144"></a>00144 <span class="keywordtype">void</span> getdata ( vec &dt0 ) {dt0=dt;} |
118 | | <a name="l00145"></a>00145 <span class="keywordtype">void</span> getdata ( vec &dt0, <span class="keyword">const</span> ivec &indeces ) {dt0=dt ( indeces );} |
119 | | <a name="l00146"></a>00146 |
120 | | <a name="l00147"></a>00147 stateDS ( mpdf* IM0, mpdf* OM0, <span class="keywordtype">int</span> usize ) :<a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a" title="default constructors">DS</a> ( ),IM ( IM0 ),OM ( OM0 ), |
121 | | <a name="l00148"></a>00148 dt ( OM0->dimension() ), xt ( IM0->dimension() ), ut ( usize) {} |
122 | | <a name="l00149"></a>00149 ~stateDS() {<span class="keyword">delete</span> IM; <span class="keyword">delete</span> OM;} |
123 | | <a name="l00150"></a>00150 <span class="keyword">virtual</span> <span class="keywordtype">void</span> step() { |
124 | | <a name="l00151"></a>00151 xt=IM->samplecond(<a class="code" href="namespacebdm.html#b9016687c0e874ca5cdcf75ae28811aa" title="Concat two random variables.">concat</a> ( xt,ut )); |
125 | | <a name="l00152"></a>00152 dt=OM->samplecond(<a class="code" href="namespacebdm.html#b9016687c0e874ca5cdcf75ae28811aa" title="Concat two random variables.">concat</a> ( xt,ut )); |
126 | | <a name="l00153"></a>00153 }; |
127 | | <a name="l00154"></a>00154 |
128 | | <a name="l00155"></a>00155 <span class="keyword">virtual</span> <span class="keywordtype">void</span> log_add ( logger &L ) { |
129 | | <a name="l00156"></a>00156 <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">DS::log_add</a> ( L ); |
130 | | <a name="l00157"></a>00157 L_xt=L.add(IM->_rv(),<span class="stringliteral">"true"</span>); |
131 | | <a name="l00158"></a>00158 } |
132 | | <a name="l00159"></a>00159 <span class="keyword">virtual</span> <span class="keywordtype">void</span> logit ( logger &L ) { |
133 | | <a name="l00160"></a>00160 <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">DS::logit</a> ( L ); |
134 | | <a name="l00161"></a>00161 L.logit ( L_xt,xt); |
135 | | <a name="l00162"></a>00162 } |
136 | | <a name="l00163"></a>00163 |
137 | | <a name="l00164"></a>00164 }; |
138 | | <a name="l00165"></a>00165 |
139 | | <a name="l00166"></a>00166 }; <span class="comment">//namespace</span> |
140 | | <a name="l00167"></a>00167 |
141 | | <a name="l00168"></a>00168 <span class="preprocessor">#endif // DS_H</span> |
| 85 | <a name="l00054"></a><a class="code" href="classbdm_1_1ArxDS.html">00054</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1ArxDS.html" title="Generator of ARX data.">ArxDS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
| 86 | <a name="l00055"></a>00055 <span class="keyword">protected</span>: |
| 87 | <a name="l00057"></a><a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb">00057</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a>; |
| 88 | <a name="l00059"></a><a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597">00059</a> vec <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
| 89 | <a name="l00061"></a><a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5">00061</a> vec <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>; |
| 90 | <a name="l00063"></a><a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe">00063</a> vec <a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe" title="temporary variable for regressor">rgr</a>; |
| 91 | <a name="l00065"></a><a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898">00065</a> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> <a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898" title="data link: H -&gt; rgr">rgrlnk</a>; |
| 92 | <a name="l00067"></a><a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb">00067</a> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<chmat></a> <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>; |
| 93 | <a name="l00069"></a><a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1">00069</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>; |
| 94 | <a name="l00071"></a><a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85">00071</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>; |
| 95 | <a name="l00072"></a>00072 <span class="keywordtype">int</span> L_R; |
| 96 | <a name="l00073"></a>00073 <span class="keywordtype">int</span> dt_size; |
| 97 | <a name="l00074"></a>00074 <span class="keyword">public</span>: |
| 98 | <a name="l00075"></a><a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595">00075</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) { |
| 99 | <a name="l00076"></a>00076 <span class="comment">//it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" );</span> |
| 100 | <a name="l00077"></a>00077 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
| 101 | <a name="l00078"></a>00078 }; |
| 102 | <a name="l00079"></a><a class="code" href="classbdm_1_1ArxDS.html#701151418bc5fc3861acef8359fb0d80">00079</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt, <span class="keyword">const</span> ivec &indices ) { |
| 103 | <a name="l00080"></a>00080 it_assert_debug ( dt.length() ==indices.length(),<span class="stringliteral">"ArxDS"</span> ); |
| 104 | <a name="l00081"></a>00081 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a> ( indices ); |
| 105 | <a name="l00082"></a>00082 }; |
| 106 | <a name="l00083"></a><a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940">00083</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ) { |
| 107 | <a name="l00084"></a>00084 <span class="comment">//it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" );</span> |
| 108 | <a name="l00085"></a>00085 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>=ut; |
| 109 | <a name="l00086"></a>00086 }; |
| 110 | <a name="l00087"></a><a class="code" href="classbdm_1_1ArxDS.html#477fd706639535f520e9dbbd19f73318">00087</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut, <span class="keyword">const</span> ivec &indices ) { |
| 111 | <a name="l00088"></a>00088 it_assert_debug ( ut.length() ==indices.length(),<span class="stringliteral">"ArxDS"</span> ); |
| 112 | <a name="l00089"></a>00089 set_subvector ( <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>, indices,ut ); |
| 113 | <a name="l00090"></a>00090 }; |
| 114 | <a name="l00091"></a>00091 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#57dfa26b23cc03d53b123fa7e0474b19" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>(); |
| 115 | <a name="l00093"></a><a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849">00093</a> <a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849" title="Default constructor.">ArxDS</a> ( ) {}; |
| 116 | <a name="l00095"></a><a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a">00095</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a" title="Set parameters of the internal model, H is maximum time delay.">set_parameters</a> ( <span class="keyword">const</span> mat &Th0, <span class="keyword">const</span> vec mu0, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &sqR0 ) |
| 117 | <a name="l00096"></a>00096 { <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#5d18dec3167584338a4775c1d165d96f" title="Set A and R.">set_parameters</a> ( Th0, mu0, sqR0 );}; |
| 118 | <a name="l00098"></a><a class="code" href="classbdm_1_1ArxDS.html#bf9cd9d4043d7e0dc61de56db37ec703">00098</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#bf9cd9d4043d7e0dc61de56db37ec703" title="Set.">set_drv</a>(<a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &yrv, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &urv, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rrv){ |
| 119 | <a name="l00099"></a>00099 <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a> = rrv; |
| 120 | <a name="l00100"></a>00100 <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a> = urv; |
| 121 | <a name="l00101"></a>00101 dt_size = yrv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()+urv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 122 | <a name="l00102"></a>00102 |
| 123 | <a name="l00103"></a>00103 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> drv = concat(yrv,urv); |
| 124 | <a name="l00104"></a>00104 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> = drv; |
| 125 | <a name="l00105"></a>00105 <span class="keywordtype">int</span> td = rrv.<a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>(); |
| 126 | <a name="l00106"></a>00106 <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.set_size(drv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()*(-td+1)); |
| 127 | <a name="l00107"></a>00107 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>.set_size(<a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()); |
| 128 | <a name="l00108"></a>00108 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=-1;i>=td;i--){ |
| 129 | <a name="l00109"></a>00109 drv.<a class="code" href="classbdm_1_1RV.html#bd77cb0899f7fba1d0e34396137b7f1f" title="Shift time shifted by delta.">t</a>(-1); |
| 130 | <a name="l00110"></a>00110 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a>(drv); <span class="comment">//shift u1</span> |
| 131 | <a name="l00111"></a>00111 } |
| 132 | <a name="l00112"></a>00112 <a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898" title="data link: H -&gt; rgr">rgrlnk</a>.<a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a>(rrv,<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>); |
| 133 | <a name="l00113"></a>00113 |
| 134 | <a name="l00114"></a>00114 dtsize = <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 135 | <a name="l00115"></a>00115 utsize = <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 136 | <a name="l00116"></a>00116 } |
| 137 | <a name="l00118"></a><a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436">00118</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436" title="set options from a string">set_options</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &s ) { |
| 138 | <a name="l00119"></a>00119 <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>= ( s.find ( <span class="stringliteral">"L_theta"</span> ) !=string::npos ); |
| 139 | <a name="l00120"></a>00120 }; |
| 140 | <a name="l00121"></a><a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52">00121</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52" title="Register DS for logging into logger L.">log_add</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
| 141 | <a name="l00122"></a>00122 <span class="comment">//DS::log_add ( L ); too long!!</span> |
| 142 | <a name="l00123"></a>00123 <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>(0,dt_size),<span class="stringliteral">""</span> ); |
| 143 | <a name="l00124"></a>00124 L_ut=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>,<span class="stringliteral">""</span> ); |
| 144 | <a name="l00125"></a>00125 |
| 145 | <a name="l00126"></a>00126 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
| 146 | <a name="l00127"></a>00127 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
| 147 | <a name="l00128"></a>00128 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {<a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{th }"</span>, vec_1 ( A.rows() *A.cols() ) ),<span class="stringliteral">"t"</span> );} |
| 148 | <a name="l00129"></a>00129 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L_R=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{R }"</span>, vec_1 ( R.rows() *R.cols() ) ),<span class="stringliteral">"r"</span> );} |
| 149 | <a name="l00130"></a>00130 } |
| 150 | <a name="l00131"></a><a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90">00131</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90" title="Register DS for logging into logger L.">logit</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
| 151 | <a name="l00132"></a>00132 <span class="comment">//DS::logit ( L );</span> |
| 152 | <a name="l00133"></a>00133 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>( <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.left(dt_size)); |
| 153 | <a name="l00134"></a>00134 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(L_ut, <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>); |
| 154 | <a name="l00135"></a>00135 |
| 155 | <a name="l00136"></a>00136 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
| 156 | <a name="l00137"></a>00137 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
| 157 | <a name="l00138"></a>00138 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>,vec ( A._data(), A.rows() *A.cols() ) );}; |
| 158 | <a name="l00139"></a>00139 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_R, vec ( R._data(), R.rows() *R.rows() ) );}; |
| 159 | <a name="l00140"></a>00140 } |
| 160 | <a name="l00141"></a>00141 |
| 161 | <a name="l00142"></a>00142 }; |
| 162 | <a name="l00143"></a>00143 |
| 163 | <a name="l00144"></a>00144 <span class="keyword">class </span>stateDS : <span class="keyword">public</span> DS { |
| 164 | <a name="l00145"></a>00145 <span class="keyword">protected</span>: |
| 165 | <a name="l00147"></a>00147 mpdf* IM; |
| 166 | <a name="l00149"></a>00149 mpdf* OM; |
| 167 | <a name="l00151"></a>00151 vec dt; |
| 168 | <a name="l00153"></a>00153 vec xt; |
| 169 | <a name="l00155"></a>00155 vec ut; |
| 170 | <a name="l00157"></a>00157 <span class="keywordtype">int</span> L_xt; |
| 171 | <a name="l00158"></a>00158 <span class="keyword">public</span>: |
| 172 | <a name="l00159"></a>00159 <span class="keywordtype">void</span> getdata ( vec &dt0 ) {dt0=dt;} |
| 173 | <a name="l00160"></a>00160 <span class="keywordtype">void</span> getdata ( vec &dt0, <span class="keyword">const</span> ivec &indeces ) {dt0=dt ( indeces );} |
| 174 | <a name="l00161"></a>00161 |
| 175 | <a name="l00162"></a>00162 stateDS ( mpdf* IM0, mpdf* OM0, <span class="keywordtype">int</span> usize ) :<a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a" title="default constructors">DS</a> ( ),IM ( IM0 ),OM ( OM0 ), |
| 176 | <a name="l00163"></a>00163 dt ( OM0->dimension() ), xt ( IM0->dimension() ), ut ( usize ) {} |
| 177 | <a name="l00164"></a>00164 ~stateDS() {<span class="keyword">delete</span> IM; <span class="keyword">delete</span> OM;} |
| 178 | <a name="l00165"></a>00165 <span class="keyword">virtual</span> <span class="keywordtype">void</span> step() { |
| 179 | <a name="l00166"></a>00166 xt=IM->samplecond ( concat ( xt,ut ) ); |
| 180 | <a name="l00167"></a>00167 dt=OM->samplecond ( concat ( xt,ut ) ); |
| 181 | <a name="l00168"></a>00168 }; |
| 182 | <a name="l00169"></a>00169 |
| 183 | <a name="l00170"></a>00170 <span class="keyword">virtual</span> <span class="keywordtype">void</span> log_add ( logger &L ) { |
| 184 | <a name="l00171"></a>00171 <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">DS::log_add</a> ( L ); |
| 185 | <a name="l00172"></a>00172 L_xt=L.add ( IM->_rv(),<span class="stringliteral">"true"</span> ); |
| 186 | <a name="l00173"></a>00173 } |
| 187 | <a name="l00174"></a>00174 <span class="keyword">virtual</span> <span class="keywordtype">void</span> logit ( logger &L ) { |
| 188 | <a name="l00175"></a>00175 <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">DS::logit</a> ( L ); |
| 189 | <a name="l00176"></a>00176 L.logit ( L_xt,xt ); |
| 190 | <a name="l00177"></a>00177 } |
| 191 | <a name="l00178"></a>00178 |
| 192 | <a name="l00179"></a>00179 }; |
| 193 | <a name="l00180"></a>00180 |
| 194 | <a name="l00181"></a>00181 }; <span class="comment">//namespace</span> |
| 195 | <a name="l00182"></a>00182 |
| 196 | <a name="l00183"></a>00183 <span class="preprocessor">#endif // DS_H</span> |