306 | | //! State-space data source simulating two densities |
307 | | class StateDS : public DS { |
308 | | protected: |
309 | | //!conditional pdf of the state evolution \f$ f(x_t|x_{t-1}) \f$ |
310 | | shared_ptr<pdf> IM; |
311 | | |
312 | | //!conditional pdf of the observations \f$ f(d_t|x_t) \f$ |
313 | | shared_ptr<pdf> OM; |
314 | | |
315 | | //! result storage |
316 | | vec dt; |
317 | | //! state storage |
318 | | vec xt; |
319 | | //! input storage |
320 | | vec ut; |
321 | | |
322 | | //! datalink from ut to IM.rvc |
323 | | datalink_part u2imc; |
324 | | //! datalink from ut to OM.rvc |
325 | | datalink_part u2omc; |
326 | | public: |
327 | | void getdata ( vec &dt0 ) const { |
328 | | dt0 = dt; |
329 | | } |
330 | | void write ( const vec &ut0 ) { |
331 | | ut = ut0; |
332 | | } |
333 | | |
334 | | void getdata ( vec &dt0, const ivec &indices ) { |
335 | | dt0 = dt ( indices ); |
336 | | } |
337 | | |
338 | | virtual void step(); |
339 | | |
340 | | //! set parameters |
341 | | void set_parameters ( shared_ptr<pdf> IM0, shared_ptr<pdf> OM0 ) { |
342 | | IM = IM0; |
343 | | OM = OM0; |
344 | | } |
345 | | void set_initx ( const vec &x0 ) { |
346 | | xt = x0; |
347 | | } |
348 | | |
349 | | virtual void write ( const vec &ut, const ivec &indices ) NOT_IMPLEMENTED_VOID; |
350 | | |
351 | | /*! UI for stateDS |
352 | | |
353 | | The DS is constructed from a structure with fields: |
354 | | \code |
355 | | class = "stateDS"; |
356 | | //Internal model |
357 | | IM = { type = "pdf-offspring"; }; |
358 | | //Observation model |
359 | | OM = { type = "pdf-offspring"; } |
360 | | //initial state |
361 | | x0 = [...]; //vector of data |
362 | | \endcode |
363 | | Both models must have defined \c rv. and \c rvc |
364 | | Random variables not found in any rv are considered to be inputs. |
365 | | */ |
366 | | void from_setting ( const Setting &set ); |
367 | | |
368 | | // TODO dodelat void to_setting( Setting &set ) const; |
369 | | |
370 | | void validate(); |
371 | | }; |
372 | | |
373 | | UIREGISTER ( StateDS ); |
374 | | SHAREDPTR ( StateDS ); |
375 | | |