Changeset 787
- Timestamp:
- 01/14/10 21:37:57 (15 years ago)
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/tutorial/mpdm/dist_ctrl_acc.m
r786 r787 50 50 %P1.merger.dbg_file = 'mp.it'; 51 51 P1.merger.ncoms = 20; 52 P1.merger.stop_niter= 5; 52 53 P1.neighbours = {};%{'P2'}; 53 54 … … 88 89 Y = [M.DS_y1 M.DS_y2 M.DS_y3]; 89 90 Yreq = ones(size(M.DS_y1))*[0 1 0]; 90 loss_ non_coop(i) = trace((Y-Yreq)'*0.01*(Y-Yreq)) + M.DS_u1'*C1.Qu*M.DS_u1 + M.DS_u2'*C1.Qu*M.DS_u2;91 loss_coop(i) = trace((Y-Yreq)'*0.01*(Y-Yreq)) + M.DS_u1'*C1.Qu*M.DS_u1 + M.DS_u2'*C1.Qu*M.DS_u2; 91 92 if loss_coop(i)>100 92 93 %keyboard -
applications/bdmtoolbox/tutorial/mpdm/dist_ctrl_example.m
r781 r787 31 31 C1.Qy = 1*eye(1); 32 32 C1.yreq = 1; 33 C1.horizon = 5;33 C1.horizon = 1; 34 34 35 35 C2=C1; … … 44 44 %P1.merger.dbg_file = 'mp.it'; 45 45 P1.merger.ncoms = 20; 46 P1.merger.stop_niter= 5; 46 47 P1.neighbours = {};%{'P2'}; 47 48 … … 60 61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MONTE CARLO %%%%%%%%%%%%%%%%%%% 61 62 62 Ntrials = 100;63 Ntrials = 3; 63 64 loss_non_coop = zeros(1,Ntrials); 64 65 for i=1:Ntrials 65 66 M= arena(DS,{P1,P2},exper); 66 67 67 loss_non_coop(i) = M.DS_y'*C1.Qy*M.DS_y+ M.DS_u1'*C1.Qu*M.DS_u1 + M.DS_u2'*C1.Qu*M.DS_u2;68 loss_non_coop(i) = (M.DS_y-C1.yreq)'*C1.Qy*(M.DS_y-C1.yreq) + M.DS_u1'*C1.Qu*M.DS_u1 + M.DS_u2'*C1.Qu*M.DS_u2; 68 69 if loss_non_coop(i)>100 69 70 %keyboard … … 78 79 M= arena(DS,{P1,P2},exper); 79 80 80 loss_coop(i) = M.DS_y'*C1.Qy*M.DS_y+ M.DS_u1'*C1.Qu*M.DS_u1 + M.DS_u2'*C1.Qu*M.DS_u2;81 loss_coop(i) = (M.DS_y-C1.yreq)'*C1.Qy*(M.DS_y-C1.yreq) + M.DS_u1'*C1.Qu*M.DS_u1 + M.DS_u2'*C1.Qu*M.DS_u2; 81 82 if loss_coop(i)>100 82 83 %keyboard -
library/bdm/itpp_ext.cpp
r766 r787 390 390 void triu ( mat &A ) { 391 391 for ( int i = 1; i < A.rows(); i++ ) { // row cycle 392 for ( int j = 0; j < i; j++ ) {392 for ( int j = 0; (j < i) && (j<A.cols()); j++ ) { 393 393 A ( i, j ) = 0; 394 394 } -
library/bdm/mpdm/arx_agent.h
r776 r787 65 65 } 66 66 void adapt(const vec &glob_dt){ 67 dlDt.filldown(glob_dt, dt); 67 dlDt.filldown(glob_dt, dt); 68 dlDt.store_data(glob_dt); // do not ever use dlDt again! 69 68 70 lqg_arx->adapt(dt); 69 71 // remove old predictors … … 80 82 merger->merge(); 81 83 enorm<chmat> joint_pred; 82 joint_pred.set_parameters(merger->mean(), merger->covariance()); 84 mat Cov=merger->covariance(); 85 if (sumsum(Cov)==0.0){ 86 bdm_error("merging failed"); 87 } 88 joint_pred.set_parameters(merger->mean(), Cov); 83 89 joint_pred.set_rv(merger->_rv()); 84 90 … … 96 102 ut=lqg_arx->ctrlaction(dt); 97 103 dlU.filldown(ut,glob_ut); 98 // save dat for next time99 dlDt.store_data(dt);100 104 } 101 105 virtual void ds_register(const DS &ds){ -
library/bdm/stat/merger.cpp
r773 r787 163 163 mat Tmp = zeros ( dim, dim ); 164 164 for ( int i = 0; i < Npoints; i++ ) { 165 Tmp += w ( i ) * outer_product ( S ( i ), S ( i ) ); 166 } 167 return Tmp - outer_product ( mea, mea ); 165 vec tmp=S ( i )-mea; //inefficient but numerically stable 166 Tmp += w ( i ) * outer_product (tmp , tmp ); 167 } 168 return Tmp; 168 169 } 169 170 … … 174 175 void merger_mix::merge ( ) { 175 176 if(Npoints<1){ 176 set_support(enorm<fsqmat>(zeros(dim), eye(dim)), 100 );177 set_support(enorm<fsqmat>(zeros(dim), eye(dim)), 1000); 177 178 } 178 179