Changeset 948 for library/doc/tutorial/01userguide_sim.dox
- Timestamp:
- 05/18/10 16:54:25 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/tutorial/01userguide_sim.dox
r947 r948 2 2 \page userguide_sim BDM Use - System, Data, Simulation 3 3 4 This section serves as introduction to the scenario of data simulation. Since it is the simpliest of all scenarios defined in \ref userguide0 it also serves as introduction to configuration of an experiment (see \ref ui) and basic decision making objects (bdm::RV and bdm::DS). 5 6 All experiments are demonstarted on mex file \c simulator, which is also available as a standalone application. 4 This section serves as introduction to the scenario of data simulation. Since it is the simplest of all scenarios defined in \ref userguide0 it also serves as introduction to configuration of an experiment (see \ref ui) and basic decision making objects (bdm::RV and bdm::DS). 5 6 All experiments are demonstrated on mex file \c simulator, which is also available as a standalone application. 7 8 Table of contents: 9 \section ug_sim_config 10 \section ug_sim 11 \section ug_memds 12 \section ug_rvs 13 \subsection ug_rv_connect 14 \section ug_pdfds 15 \section ug_arx_sim 16 \subsection ug_ini 17 \section ug_store 7 18 8 19 … … 13 24 Specific treatment was developed for objects. Since BDM is designed as object oriented library, the configuration was designed to honor the rule of inheritance. That is, offspring of a class can be used in place of its predecessor. Hence, objects (instances of classes) are configured by a structure with compulsory field \c class. This is a string variable corresponding to the name of the class to be used. This information is stored in Matlab structures (or objects, see section on Matlab extensions). 14 25 15 Adva cnded users can find more information in (\ref ui).26 Advanced users can find more information in (\ref ui). 16 27 17 28 \subsection ug_first First experiment … … 24 35 which can be found in file bdmtoolbox/tutorials/userguide/memds_example.m. 25 36 26 The code above is the minimum necessary information to run scenario \c simulator in matlab.27 To actually do so, make sure that matlab paths are correctly set, as described in \ref install.37 The code above is the minimum necessary information to run scenario \c simulator in Matlab. 38 To actually do so, make sure that Matlab paths are correctly set, as described in \ref install. 28 39 29 40 The expected result for Matlab is: … … 62 73 -# store log of its activity into dedicated logger. 63 74 64 No f ruther specification, e.g. if the data are pre-recorded or computed on-the-fly, are given.75 No further specification, e.g. if the data are pre-recorded or computed on-the-fly, are given. 65 76 For a list of available DataSources, see ... 66 77 … … 71 82 72 83 Operation of such object is trivial, the data are stored as a matrix and the general operations defined above are specialized as follows: 73 -# data observed at time \f$ t \f$ are columns of the matrix, getdata() r uturns current column,84 -# data observed at time \f$ t \f$ are columns of the matrix, getdata() returns current column, 74 85 -# time step itself is performed by increasing the column index, 75 86 -# each row is named as "ch0","ch1",... 76 87 77 This is the default b ahavior. It can be customized using the UI mechanism. Full list of options is:88 This is the default behavior. It can be customized using the UI mechanism. Full list of options is: 78 89 \code 79 90 DS.class = 'MemDS'; … … 99 110 100 111 It is used for: 101 - des ription of RV in pdfs, ways how to define marginalization and conditioning,112 - description of RV in pdfs, ways how to define marginalization and conditioning, 102 113 - connection between source of data and computational objects that use them, 103 114 - connection <b>time</b>, more exactly time shift from \f$ t \f$, defaults to 0. 104 115 105 For example, the estimators will request the data from the above mentioned data source by asking for rv 'ch0'. If a more meanin ful names are available, the fields drv can be added to read:116 For example, the estimators will request the data from the above mentioned data source by asking for rv 'ch0'. If a more meaningful names are available, the fields drv can be added to read: 106 117 \code 107 118 DS.class='MemDS'; … … 109 120 DS.drv = RV('y'); 110 121 \endcode 111 Data from th sidata source will be available when estimators ask for rv 'y'.122 Data from this data source will be available when estimators ask for rv 'y'. 112 123 113 124 \subsection ug_rv_connect Storing results 114 125 115 results of an experiment can be stored in many ways. This functionality was abstracted into a class called logger. Exact form of the stored resul s is chosen by choosing appropriate class.116 For example, \c stdlog writes all output in the console, \c dirfilelog writes all data in the dirfilelog format for high-speed data processing, \c mexlog writes data into matlab structure.126 results of an experiment can be stored in many ways. This functionality was abstracted into a class called logger. Exact form of the stored results is chosen by choosing appropriate class. 127 For example, \c stdlog writes all output in the console, \c dirfilelog writes all data in the dirfilelog format for high-speed data processing, \c mexlog writes data into Matlab structure. 117 128 The \c mexlog is the default option in bdmtoolbox. 118 129 119 Connection between computational blocks and loggers is controlled by structure called \c log_level which govern es the level of details to be logged.130 Connection between computational blocks and loggers is controlled by structure called \c log_level which governs the level of details to be logged. 120 131 A standard Data source has two levels, \c logdt and \c logut which means "log all outputs, dt" and "log all inputs, ut". 121 132 Readers familiar with Simulink environment may look at the RV as being unique identifiers of inputs and outputs of simulation blocks. The inputs are connected automatically with the outputs with matching RV. This view is however, very incomplete, RV have more roles than this. … … 134 145 \f] 135 146 136 The datasource itself, i.e. the instanc of \c EpdfDS can be then configured via:147 The datasource itself, i.e. the instance of \c EpdfDS can be then configured via: 137 148 \code 138 149 DS.class = 'pdfDS'; … … 150 161 151 162 If the task was only to generate random realizations, this would indeed be a very clumsy way of doing it. 152 However, the power of the proposed approach will be reve lead in more demanding examples, one of which follows next.163 However, the power of the proposed approach will be revealed in more demanding examples, one of which follows next. 153 164 154 165 By default, data from this datasouce will be named after the rvs in given by the pdfs. When pdf with no rv is used, drv of the data source is set again to 'ch0'. … … 164 175 We need to handle two issues: 165 176 -# extra unsimulated variable \f$ u \f$, 166 -# time delay es of the values.177 -# time delays of the values. 167 178 168 179 The first issue can be handled in two ways. First, \f$ u \f$ can be considered as input and as such it could be externally given to the datasource. This solution is used in scenario \c closedloop. … … 202 213 Explanation of this example will require few remarks: 203 214 - class of the \c fy object is 'mlnorm\<ldmat\>' which is Normal pdf with mean value given by linear function, and covariance matrix stored in LD decomposition, see bdm::mlnorm for details. 204 - naming convention 'mlnorm\<ldmat\>' relates to the concept of templates in C++. For those unfamiliar with this concept, it is basical y a way how to share code for different flavours of the same object. Note that mlnorm exist in three versions: mlnorm\<ldmat\>, mlnorm<chmat>, mlnorm<fsqmat>. Those classes act identically the only difference is that the internal data are stored either in LD decomposition, choleski decomposition or full matrices, respectively.215 - naming convention 'mlnorm\<ldmat\>' relates to the concept of templates in C++. For those unfamiliar with this concept, it is basically a way how to share code for different flavors of the same object. Note that mlnorm exist in three versions: mlnorm\<ldmat\>, mlnorm<chmat>, mlnorm<fsqmat>. Those classes act identically the only difference is that the internal data are stored either in LD decomposition, choleski decomposition or full matrices, respectively. 205 216 - the same concept is used for enorm, where enorm<chmat> and enorm<fsqmat> are also possible. In this particular use, these objects are equivalent. In specific situation, e.g. Kalman filter implemented on Choleski decomposition (bdm::KalmanCh), only enorm<chmat> is approprate. 206 217 - class 'mprod' represents the chain rule of probability, see \ref ug_pdf_cond. 207 218 208 The code above can be immediatel ly run, usinthe same execution sequence of \c estimator as above.219 The code above can be immediately run, using the same execution sequence of \c estimator as above. 209 220 210 221 \subsection ug_ini Initializing simulation … … 217 228 218 229 The values of \c init_values will be copied to places in history identified by corresponding values of \c init_rv. 219 Initial data is not checked for completeness, i.e. values of random variables missing from \c init_rv (in this case all occur ences of \f$ u \f$) are still initialized to 0.230 Initial data is not checked for completeness, i.e. values of random variables missing from \c init_rv (in this case all occurrences of \f$ u \f$) are still initialized to 0. 220 231 221 232 \section ug_store Storing results of simulation … … 226 237 For example, the output of \c MemDS can be stored as an .it file (filename is specified in configuration structure) which can be later read by bdm::ITppFileDS. 227 238 228 In matlab, the output of mexlog is a structure of vectors or matrices. The results can be saved in a matlab file using:239 In Matlab, the output of mexlog is a structure of vectors or matrices. The results can be saved in a Matlab file using: 229 240 \code 230 241 Data=[M.y; M.u];