Changeset 321 for applications/mpdm
- Timestamp:
- 04/23/09 20:44:18 (16 years ago)
- Location:
- applications/mpdm
- Files:
-
- 7 added
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/mpdm/SYSID09/merg_2a.cpp
r297 r321 47 47 RV r ("{r }"); 48 48 49 double at = 1.5;50 double bt = 0.5;49 double at = 0.9; 50 double bt = 5; 51 51 double ct = -0.5; 52 double rt = 0. 30;52 double rt = 0.50; 53 53 // Full system 54 54 vec thy =vec_2 ( at,bt ); //Simulated system - zero for constant term … … 58 58 59 59 //ARX constructor 60 mat V0 = 0.0 01*eye ( 3 ); V0 ( 0,0 ) = 1; //60 mat V0 = 0.01*eye ( 3 ); V0 ( 0,0 ) = 1; // 61 61 62 62 ARX P1; P1.set_rv(concat(ab,r)); 63 63 P1.set_statistics(1, V0, -1 ); 64 P1.set_parameters(0.9); 64 65 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); 66 68 67 69 //Test estimation … … 70 72 71 73 // Logging 72 dirfilelog L ( "exp/merg_2a", 3);74 dirfilelog L ( "exp/merg_2a",100 ); 73 75 int Li_Data = L.add ( RV ( "{U Y Z }" ), "" ); 74 76 // int Li_LL = L.add ( RV ( "{P1 P2 M1 M2 }" ), "LL" ); … … 90 92 g1.set_parameters ( "2 ", "2" ); 91 93 enorm<ldmat> g2; g2.set_rv(c); 92 g2.set_parameters ( " 1 ",mat ( "1" ) );94 g2.set_parameters ( "-1 ",mat ( "1" ) ); 93 95 94 96 Array<const epdf*> A ( 3 ); A ( 0 ) = &g0; A ( 1 ) =&g1; A(2) = &g2; 95 97 eprod G0; G0.set_parameters ( A ); 96 98 97 vec rgru(2); 99 epdf* proposal=&G0; 100 98 101 vec rgry(2); 102 vec rgrz(2); 99 103 Yt(0) = 0.1; 100 104 Ut(0) = 0.0; 101 105 for ( t=1; t<ndat; t++ ) { 102 106 // 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(); 108 114 109 115 // Bayes for all 110 P1.bayes ( concat ( Yt ( t ),rgr u) );111 P2.bayes ( concat ( Zt ( t ),rgr y) );116 P1.bayes ( concat ( Yt ( t ),rgry ) ); 117 P2.bayes ( concat ( Zt ( t ),rgrz ) ); 112 118 119 if (t>50) {bt+=0.1; 120 thy(1)=bt;} 121 if (t>50) {ct-=0.01; 122 thz(1)=ct;} 123 113 124 // Merge estimates 114 125 mepdf eG1 ( P1._e() ); … … 116 127 Array<mpdf*> A ( 2 ); A ( 0 ) =&eG1;A ( 1 ) =&eG2; 117 128 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); 119 130 //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 ); 121 135 136 //proposal = M.proposal(); 122 137 //Likelihood 123 138 yt ( 0 ) = Yt ( t ); … … 131 146 L.step ( ); 132 147 148 cout << t << "," << endl; 133 149 } 134 150 L.finalize( );