Changeset 321 for applications/mpdm

Show
Ignore:
Timestamp:
04/23/09 20:44:18 (15 years ago)
Author:
smidl
Message:

cleanup after cleanup ;-)

Location:
applications/mpdm
Files:
7 added
1 modified

Legend:

Unmodified
Added
Removed
  • applications/mpdm/SYSID09/merg_2a.cpp

    r297 r321  
    4747        RV r ("{r }"); 
    4848         
    49         double at = 1.5; 
    50         double bt = 0.5; 
     49        double at = 0.9; 
     50        double bt = 5; 
    5151        double ct = -0.5; 
    52         double rt = 0.30; 
     52        double rt = 0.50; 
    5353        // Full system 
    5454        vec thy =vec_2 ( at,bt ); //Simulated system - zero for constant term 
     
    5858 
    5959        //ARX constructor 
    60         mat V0 = 0.001*eye ( 3 ); V0 ( 0,0 ) = 1; // 
     60        mat V0 = 0.01*eye ( 3 ); V0 ( 0,0 ) = 1; // 
    6161 
    6262        ARX P1; P1.set_rv(concat(ab,r)); 
    6363        P1.set_statistics(1, V0, -1 ); 
     64        P1.set_parameters(0.9); 
    6465        ARX P2; P2.set_rv(concat(ac,r)); 
    65          P2.set_statistics(1, V0, -1 ); 
     66        P2.set_statistics(1, V0, -1 ); 
     67        P2.set_parameters(0.9); 
    6668 
    6769        //Test estimation 
     
    7072 
    7173        // Logging 
    72         dirfilelog L ( "exp/merg_2a",3 ); 
     74        dirfilelog L ( "exp/merg_2a",100 ); 
    7375        int Li_Data = L.add ( RV ( "{U Y Z }" ), "" ); 
    7476//      int Li_LL   = L.add ( RV ( "{P1 P2 M1 M2 }" ), "LL" ); 
     
    9092        g1.set_parameters ( "2  ", "2" ); 
    9193        enorm<ldmat> g2; g2.set_rv(c);  
    92         g2.set_parameters ( "1 ",mat ( "1" ) ); 
     94        g2.set_parameters ( "-1 ",mat ( "1" ) ); 
    9395 
    9496        Array<const epdf*> A ( 3 ); A ( 0 ) = &g0; A ( 1 ) =&g1; A(2) = &g2;  
    9597        eprod G0; G0.set_parameters ( A ); 
    9698 
    97         vec rgru(2); 
     99        epdf* proposal=&G0; 
     100         
    98101        vec rgry(2); 
     102        vec rgrz(2); 
    99103        Yt(0) = 0.1; 
    100104        Ut(0) = 0.0; 
    101105        for ( t=1; t<ndat; t++ ) { 
    102106                // True system 
    103                 Ut ( t ) = pow ( sin ( ( t/40.0 ) *pi ),3 ); 
    104                 rgru(0) = Ut(t); rgru(1) = Ut(t-1); 
    105                 Yt ( t ) = thy*rgru + rt * NorRNG(); 
    106                 rgry(0) = Yt(t); rgry(1) = Yt(t-1); 
    107                 Zt ( t ) = thz*rgry + rt * NorRNG(); 
     107                Ut ( t ) = 0.1*pow ( sin ( ( t/40.0 ) *pi ),3 ); 
     108                 
     109                rgry(0) = Ut(t); rgry(1) = Ut(t-1); 
     110                Yt ( t ) = thy*rgry + rt * NorRNG(); 
     111                 
     112                rgrz(0) = Yt(t); rgrz(1) = Yt(t-1); 
     113                Zt ( t ) = thz*rgrz + rt * NorRNG(); 
    108114 
    109115                // Bayes for all 
    110                 P1.bayes ( concat ( Yt ( t ),rgru ) ); 
    111                 P2.bayes ( concat ( Zt ( t ),rgry ) ); 
     116                P1.bayes ( concat ( Yt ( t ),rgry ) ); 
     117                P2.bayes ( concat ( Zt ( t ),rgrz ) ); 
    112118 
     119                if (t>50) {bt+=0.1; 
     120                        thy(1)=bt;} 
     121                if (t>50) {ct-=0.01; 
     122                        thz(1)=ct;} 
     123                 
    113124                // Merge estimates 
    114125                mepdf eG1 ( P1._e() ); 
     
    116127                Array<mpdf*> A ( 2 ); A ( 0 ) =&eG1;A ( 1 ) =&eG2; 
    117128                merger M ( A ); 
    118                 M.set_parameters ( 10, 100,3 ); //M._Mix().set_method(QB); 
     129                M.set_parameters ( 2, 100,20 ,0.99); M._Mix().set_method(QB); 
    119130                //M2.set_parameters ( 100.0, 1000,3 ); //M2._Mix().set_method(QB); 
    120                 M.merge ( &G0 ); 
     131/*              char fnm[100]; 
     132                sprintf(fnm,"m2a_dbg%d.it",t); 
     133                M.debug_file(fnm);*/ 
     134                M.merge ( proposal ); 
    121135 
     136                //proposal = M.proposal(); 
    122137                //Likelihood 
    123138                yt ( 0 ) = Yt ( t ); 
     
    131146                L.step ( ); 
    132147 
     148                cout << t << "," << endl; 
    133149        } 
    134150        L.finalize( );