preprocessor: add use_calibration option for estimated_params_init block. closes #447, closes #512

issue#70
Houtan Bastani 2013-11-06 10:36:58 +01:00
parent 6d6701aa50
commit 8513c59c9e
6 changed files with 19 additions and 9 deletions

View File

@ -581,15 +581,20 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) c
}
EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
const SymbolTable &symbol_table_arg) :
const SymbolTable &symbol_table_arg,
const bool use_calibration_arg) :
estim_params_list(estim_params_list_arg),
symbol_table(symbol_table_arg)
symbol_table(symbol_table_arg),
use_calibration(use_calibration_arg)
{
}
void
EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const
{
if (use_calibration)
output << "options_.use_calibration_initialization = 1;" << endl;
vector<EstimationParams>::const_iterator it;
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)

View File

@ -290,9 +290,11 @@ class EstimatedParamsInitStatement : public Statement
private:
const vector<EstimationParams> estim_params_list;
const SymbolTable &symbol_table;
const bool use_calibration;
public:
EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
const SymbolTable &symbol_table_arg);
const SymbolTable &symbol_table_arg,
const bool use_calibration_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};

View File

@ -90,7 +90,7 @@ class ParsingDriver;
%}
%token AIM_SOLVER ANALYTIC_DERIVATION AR AUTOCORR
%token BAYESIAN_IRF BETA_PDF BLOCK
%token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION
%token BVAR_DENSITY BVAR_FORECAST
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
@ -1141,7 +1141,10 @@ estimated_elem3 : expression_or_empty COMMA expression_or_empty
;
estimated_params_init : ESTIMATED_PARAMS_INIT ';' estimated_init_list END ';'
{ driver.estimated_params_init(); };
{ driver.estimated_params_init(); }
| ESTIMATED_PARAMS_INIT '(' USE_CALIBRATION ')' ';' estimated_init_list END ';'
{ driver.estimated_params_init(true); }
;
estimated_init_list : estimated_init_list estimated_init_elem
{ driver.add_estimated_params_element(); }

View File

@ -395,7 +395,7 @@ string eofbuff;
return token::CNUM;
}
<DYNARE_STATEMENT>banact {return token::BANACT;}
<DYNARE_BLOCK>use_calibration {return token::USE_CALIBRATION;}
<DYNARE_STATEMENT>output_file_tag {return token::OUTPUT_FILE_TAG;}
<DYNARE_STATEMENT>file_tag {return token::FILE_TAG;};
<DYNARE_STATEMENT>no_create_init {return token::NO_CREATE_INIT;};

View File

@ -1209,9 +1209,9 @@ ParsingDriver::estimated_params()
}
void
ParsingDriver::estimated_params_init()
ParsingDriver::estimated_params_init(bool use_calibration)
{
mod_file->addStatement(new EstimatedParamsInitStatement(estim_params_list, mod_file->symbol_table));
mod_file->addStatement(new EstimatedParamsInitStatement(estim_params_list, mod_file->symbol_table, use_calibration));
estim_params_list.clear();
}

View File

@ -391,7 +391,7 @@ public:
//! Writes estimated params command
void estimated_params();
//! Writes estimated params init command
void estimated_params_init();
void estimated_params_init(bool use_calibration = false);
//! Writes estimated params bound command
void estimated_params_bounds();
//! Adds a declaration for a user-defined external function