Changeset 764

Show
Ignore:
Timestamp:
01/11/10 14:39:47 (14 years ago)
Author:
smidl
Message:

burnin in controlloop is configurable

Location:
applications/bdmtoolbox
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/controlloop.cpp

    r744 r764  
    7070        // Check the number of inputs and output arguments 
    7171        if ( n_input<2 ) mexErrMsgTxt ( "Usage:\n" 
    72                                                 "result=estimator(system, estimators, experiment, logger)\n" 
     72                                                "result=controlloop(system, controllers, experiment, logger)\n" 
    7373                                                "  system     = struct('class','datasource',...);  % Estimated system\n" 
    74                                                 "  estimators = {struct('class','estimator',...),  % Estimators\n" 
    75                                                 "                struct('class','estimator',...),...} \n" 
     74                                                "  controllers= {struct('class','controller',...),  % Controllers\n" 
     75                                                "                struct('class','controller',...),...} \n" 
    7676                                                "  === optional ===" 
    77                                                 "  experiment = struct('ndat',10);                 % number of data in experiment, full length of finite datasources, 10 otherwise \n" 
     77                                                "  experiment = struct('ndat',100,...               % number of data in experiment, full length of finite datasources, 100 otherwise \n" 
     78                                                "               'burnin',10,...                    % initial time with different control\n" 
     79                                                "               'burn_pdf', struct('class','epdf_offspring') );\n" 
     80                                                "                                                  % sampler of the initial control\n" 
    7881                                                "  logger     = struct('class','mexlogger');       % How to store results, default=mexlog, i.e. matlab structure\n\n" 
    7982                                                "see documentation of classes datasource, BM, and mexlogger and their offsprings in BDM." ); 
     
    115118        UI::get ( Cs,Cfg, "controllers" ); 
    116119        int Ndat=100; 
    117         int burnin=10; 
     120        int burnin=0; 
     121        shared_ptr<epdf> burn_pdf;  
     122         
    118123        if ( Cfg.exists ( "experiment" ) ) { 
    119                 if ( Cfg.getRoot().lookupValue ( "experiment.ndat",Ndat ) ) { 
     124                Setting &exper=Cfg.getRoot()["experiment"]; 
     125                if (UI::get(Ndat, exper, "Ndat", UI::optional ) ) { 
    120126                        bdm_assert ( Ndat<=Ds->max_length(), "Data source has less data then required" ); 
    121127                }; 
     128                if (UI::get(burnin, exper, "burnin",UI::optional )){ 
     129                        burn_pdf = UI::build<epdf>(exper,"burn_pdf", UI::compulsory); 
     130                        if (burn_pdf){ 
     131                                bdm_assert(burn_pdf->dimension()==Ds->_urv()._dsize(),"Given burn_pdf does not match the DataSource"); 
     132                        } else { 
     133                                bdm_error("burn_pdf not specified!"); 
     134                        } 
     135                         
     136                } 
    122137        } else { 
    123138                if ( Ds->max_length() < std::numeric_limits< int >::max() ) { 
     
    183198                                Cs(i) -> redesign(); 
    184199                                Cs(i) -> adapt( Dlsc(i) ->pushdown(dt)); 
     200                                if (tK >= burnin){ 
     201                                        vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) );                // update estimates 
     202                                        Dlsu(i)->filldown(uti, ut); 
     203                                } 
    185204                        } 
    186                         if (tK > burnin){ 
    187                                 vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) );                // update estimates 
    188                                 Dlsu(i)->filldown(uti, ut); 
    189                         } else { 
    190                                 ut = 0.1*randn(Ds->_urv()._dsize()); 
     205                        if(tK<burnin) { 
     206                                ut = burn_pdf->sample(); 
    191207                        } 
    192208                         
  • applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m

    r744 r764  
    3636C2.ARX = A2; 
    3737 
    38 M= controlloop(DS,{C1,C2}); 
     38exper.Ndat=100; 
     39exper.burnin=3; 
     40exper.burn_pdf.class='enorm<chmat>'; 
     41exper.burn_pdf.mu=[0,0]; 
     42exper.burn_pdf.R=0.1*eye(2); 
     43 
     44 
     45M= controlloop(DS,{C1,C2},exper); 
    3946 
    4047