preprocessor: change prior_posterior_function into two arguments. closes #1076
parent
3907462ae9
commit
d587a5133f
|
@ -138,7 +138,9 @@ PerfectForesightSolverStatement::writeOutput(ostream &output, const string &base
|
|||
output << "perfect_foresight_solver;" << endl;
|
||||
}
|
||||
|
||||
PriorPosteriorFunctionStatement::PriorPosteriorFunctionStatement(const OptionsList &options_list_arg) :
|
||||
PriorPosteriorFunctionStatement::PriorPosteriorFunctionStatement(const bool prior_func_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
prior_func(prior_func_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
@ -146,20 +148,11 @@ PriorPosteriorFunctionStatement::PriorPosteriorFunctionStatement(const OptionsLi
|
|||
void
|
||||
PriorPosteriorFunctionStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
// Fill in option_occbin of mod_file_struct
|
||||
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("prior");
|
||||
OptionsList::num_options_t::const_iterator it1 = options_list.num_options.find("posterior");
|
||||
if ((it == options_list.num_options.end() && it1 == options_list.num_options.end())
|
||||
|| (it != options_list.num_options.end() && it1 != options_list.num_options.end()))
|
||||
{
|
||||
cerr << "ERROR: prior_posterior_function requires one of 'prior' or 'posterior'" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
OptionsList::string_options_t::const_iterator it2 = options_list.string_options.find("function");
|
||||
if (it2 == options_list.string_options.end() || it2->second.empty())
|
||||
{
|
||||
cerr << "ERROR: prior_posterior_function requires the 'function' argument" << endl;
|
||||
cerr << "ERROR: both the prior_function and posterior_function commands require the 'function' argument"
|
||||
<< endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +162,7 @@ PriorPosteriorFunctionStatement::writeOutput(ostream &output, const string &base
|
|||
{
|
||||
options_list.writeOutput(output);
|
||||
string type = "posterior";
|
||||
if (options_list.num_options.find("prior") != options_list.num_options.end())
|
||||
if (prior_func)
|
||||
type = "prior";
|
||||
|
||||
output << "oo_ = execute_prior_posterior_function("
|
||||
|
|
|
@ -80,9 +80,10 @@ public:
|
|||
class PriorPosteriorFunctionStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const bool prior_func;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
PriorPosteriorFunctionStatement(const OptionsList &options_list_arg);
|
||||
PriorPosteriorFunctionStatement(const bool prior_func_arg, const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
};
|
||||
|
|
|
@ -147,7 +147,7 @@ class ParsingDriver;
|
|||
%token VLISTLOG VLISTPER SPECTRAL_DENSITY
|
||||
%token RESTRICTION RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
|
||||
%token DUMMY_OBS NSTATES INDXSCALESSTATES NO_BAYESIAN_PRIOR SPECIFICATION SIMS_ZHA
|
||||
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR POSTERIOR PRIOR_VARIANCE HESSIAN IDENTITY_MATRIX DIRICHLET
|
||||
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM GAMMA INV_GAMMA INV_GAMMA1 INV_GAMMA2 NORMAL UNIFORM EPS PDF FIG DR NONE PRIOR PRIOR_VARIANCE HESSIAN IDENTITY_MATRIX DIRICHLET
|
||||
%token GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD WEIBULL WEIBULL_PDF
|
||||
%token INDXPARR INDXOVR INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
|
||||
%token INDXESTIMA INDXGDLS EQ_MS FILTER_COVARIANCE FILTER_DECOMPOSITION
|
||||
|
@ -162,7 +162,7 @@ class ParsingDriver;
|
|||
%token SELECTED_VARIABLES_ONLY COVA_COMPUTE SIMULATION_FILE_TAG FILE_TAG
|
||||
%token NO_ERROR_BANDS ERROR_BAND_PERCENTILES SHOCKS_PER_PARAMETER NO_CREATE_INIT
|
||||
%token SHOCK_DRAWS FREE_PARAMETERS MEDIAN DATA_OBS_NBR NEIGHBORHOOD_WIDTH PVALUE_KS PVALUE_CORR
|
||||
%token FILTERED_PROBABILITIES REAL_TIME_SMOOTHED PRIOR_POSTERIOR_FUNCTION SAMPLING_DRAWS
|
||||
%token FILTERED_PROBABILITIES REAL_TIME_SMOOTHED PRIOR_FUNCTION POSTERIOR_FUNCTION SAMPLING_DRAWS
|
||||
%token PROPOSAL_TYPE PROPOSAL_UPPER_BOUND PROPOSAL_LOWER_BOUND PROPOSAL_DRAWS USE_MEAN_CENTER
|
||||
%token ADAPTIVE_MH_DRAWS THINNING_FACTOR COEFFICIENTS_PRIOR_HYPERPARAMETERS
|
||||
%token CONVERGENCE_STARTING_VALUE CONVERGENCE_ENDING_VALUE CONVERGENCE_INCREMENT_VALUE
|
||||
|
@ -281,7 +281,8 @@ statement : parameters
|
|||
| histval_file
|
||||
| perfect_foresight_setup
|
||||
| perfect_foresight_solver
|
||||
| prior_posterior_function
|
||||
| prior_function
|
||||
| posterior_function
|
||||
;
|
||||
|
||||
dsample : DSAMPLE INT_NUMBER ';'
|
||||
|
@ -1023,17 +1024,19 @@ perfect_foresight_solver_options : o_stack_solve_algo
|
|||
| o_occbin
|
||||
;
|
||||
|
||||
prior_posterior_function : PRIOR_POSTERIOR_FUNCTION '(' prior_posterior_function_options_list ')' ';'
|
||||
{ driver.prior_posterior_function(); }
|
||||
;
|
||||
prior_function : PRIOR_FUNCTION '(' prior_posterior_function_options_list ')' ';'
|
||||
{ driver.prior_posterior_function(true); }
|
||||
;
|
||||
|
||||
posterior_function : POSTERIOR_FUNCTION '(' prior_posterior_function_options_list ')' ';'
|
||||
{ driver.prior_posterior_function(false); }
|
||||
;
|
||||
|
||||
prior_posterior_function_options_list : prior_posterior_function_options_list COMMA prior_posterior_function_options
|
||||
| prior_posterior_function_options
|
||||
;
|
||||
|
||||
prior_posterior_function_options : o_function
|
||||
| o_prior
|
||||
| o_posterior
|
||||
| o_sampling_draws
|
||||
;
|
||||
|
||||
|
@ -3083,7 +3086,6 @@ o_lmmcp : LMMCP {driver.option_num("lmmcp", "1"); };
|
|||
o_occbin : OCCBIN {driver.option_num("occbin", "1"); };
|
||||
o_function : FUNCTION EQUAL filename { driver.option_str("function", $3); };
|
||||
o_prior : PRIOR { driver.option_num("prior", "1"); };
|
||||
o_posterior : POSTERIOR { driver.option_num("posterior", "1"); };
|
||||
o_sampling_draws : SAMPLING_DRAWS EQUAL INT_NUMBER { driver.option_num("sampling_draws",$3); };
|
||||
|
||||
range : symbol ':' symbol
|
||||
|
@ -3229,7 +3231,6 @@ symbol : NAME
|
|||
| NONE
|
||||
| DR
|
||||
| PRIOR
|
||||
| POSTERIOR
|
||||
;
|
||||
%%
|
||||
|
||||
|
|
|
@ -214,15 +214,12 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
|||
yylval->string_val = new string(yytext);
|
||||
return token::PRIOR;
|
||||
}
|
||||
<DYNARE_STATEMENT>posterior {
|
||||
yylval->string_val = new string(yytext);
|
||||
return token::POSTERIOR;
|
||||
}
|
||||
<INITIAL>std {BEGIN DYNARE_STATEMENT; return token::STD;}
|
||||
<INITIAL>corr {BEGIN DYNARE_STATEMENT; return token::CORR;}
|
||||
<DYNARE_STATEMENT>function {return token::FUNCTION;}
|
||||
<DYNARE_STATEMENT>sampling_draws {return token::SAMPLING_DRAWS;}
|
||||
<INITIAL>prior_posterior_function {BEGIN DYNARE_STATEMENT; return token::PRIOR_POSTERIOR_FUNCTION;}
|
||||
<INITIAL>prior_function {BEGIN DYNARE_STATEMENT; return token::PRIOR_FUNCTION;}
|
||||
<INITIAL>posterior_function {BEGIN DYNARE_STATEMENT; return token::POSTERIOR_FUNCTION;}
|
||||
|
||||
/* Inside of a Dynare statement */
|
||||
<DYNARE_STATEMENT>{DATE} {
|
||||
|
|
|
@ -2798,9 +2798,9 @@ ParsingDriver::perfect_foresight_solver()
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::prior_posterior_function()
|
||||
ParsingDriver::prior_posterior_function(bool prior_func)
|
||||
{
|
||||
mod_file->addStatement(new PriorPosteriorFunctionStatement(options_list));
|
||||
mod_file->addStatement(new PriorPosteriorFunctionStatement((bool)prior_func, options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -703,7 +703,7 @@ public:
|
|||
void histval_file(string *filename);
|
||||
void perfect_foresight_setup();
|
||||
void perfect_foresight_solver();
|
||||
void prior_posterior_function();
|
||||
void prior_posterior_function(bool prior_func);
|
||||
};
|
||||
|
||||
#endif // ! PARSING_DRIVER_HH
|
||||
|
|
Loading…
Reference in New Issue