Show
Ignore:
Timestamp:
02/09/09 23:14:58 (15 years ago)
Author:
smidl
Message:

UI in matlab

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • tests/UI/UIArxDS_test.cpp

    r263 r265  
    11/*! 
    2 \file  
     2\file 
    33\brief Test of UI builders for ARX 
    44 
     
    99 
    1010#include <stat/libDS_ui.h> 
     11#include <estim/arx_ui.h> 
    1112 
    1213using namespace bdm; 
    1314int main() { 
    14         UIFile F("UIArxDS_test.cfg"); 
     15        UIFile F ( "UIArxDS_test.cfg" ); 
    1516 
    16         logger* L;  
    17         UIbuild(F.lookup("logger"),L); 
     17        logger* L; 
     18        UIbuild ( F.lookup ( "logger" ),L ); 
    1819        ArxDS * DS; 
    19         UIbuild(F.lookup("system"),DS); 
     20        UIbuild ( F.lookup ( "system" ),DS ); 
    2021        int Ndat; 
    21         F.lookupValue("experiment.ndat",Ndat); 
     22        F.lookupValue ( "experiment.ndat",Ndat ); 
    2223        // SET SIMULATOR 
     24        BM* E; 
     25        UIbuild ( F.lookup ( "estimator" ),E ); 
    2326 
    24         DS->log_add(*L); 
     27        DS->log_add ( *L ); 
     28        int L_est= L->add ( E->_epdf()._rv(), "est" ); // estimate 
     29        int L_lb = L->add ( E->_epdf()._rv(), "lb" ); // lower bound 
     30        int L_ub = L->add ( E->_epdf()._rv(), "ub" ); // upper bound 
    2531        L->init(); 
    26          
     32 
     33        vec dt=zeros ( DS->_drv().count() );   //data variable 
     34        datalink_e2e dl ( E->_drv(),DS->_drv() ); //datalink between a datasource and estimator 
     35 
    2736        for ( int tK=1;tK<Ndat;tK++ ) { 
    28                 DS->step(); 
    29                 DS->logit(*L); 
     37                DS->step();                                                     // simulator step 
     38                DS->getdata ( dt );                                     // read data 
     39                E->bayes ( dl.get_val ( dt ) );         // update estimates 
     40 
     41                DS->logit ( *L ); 
     42                L->logit ( L_est, E->_epdf().mean() ); 
     43                L->logit ( L_lb,  E->_epdf().mean()-2*sqrt ( E->_epdf().variance() ) ); 
     44                L->logit ( L_ub,  E->_epdf().mean() +2*sqrt ( E->_epdf().variance() ) ); 
     45 
    3046                L->step(); 
    3147        } 
    32          
    33         L->finalize();  
    34          
     48 
     49        L->finalize(); 
     50 
    3551        delete L; 
    3652        delete DS; 
     53        delete E; 
    3754        return 0; 
    3855}