Introduce two new command: perfect_foresight_{setup,solver}.
simul is now simply an alias for perfect_foresight_setup+perfect_foresight_solver.issue#70
parent
ff17a871dd
commit
d44cb3af93
|
@ -94,14 +94,45 @@ SimulStatement::SimulStatement(const OptionsList &options_list_arg) :
|
|||
void
|
||||
SimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
mod_file_struct.simul_present = true;
|
||||
mod_file_struct.perfect_foresight_solver_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
SimulStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
output << "simul();\n";
|
||||
output << "perfect_foresight_setup;" << endl
|
||||
<< "perfect_foresight_solver;" << endl;
|
||||
}
|
||||
|
||||
PerfectForesightSetupStatement::PerfectForesightSetupStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PerfectForesightSetupStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
output << "perfect_foresight_setup;" << endl;
|
||||
}
|
||||
|
||||
PerfectForesightSolverStatement::PerfectForesightSolverStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PerfectForesightSolverStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
mod_file_struct.perfect_foresight_solver_present = true;
|
||||
}
|
||||
|
||||
void
|
||||
PerfectForesightSolverStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
output << "perfect_foresight_solver;" << endl;
|
||||
}
|
||||
|
||||
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
||||
|
|
|
@ -58,6 +58,25 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class PerfectForesightSetupStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
PerfectForesightSetupStatement(const OptionsList &options_list_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class PerfectForesightSolverStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
PerfectForesightSolverStatement(const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class ModelInfoStatement : public Statement
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -112,6 +112,7 @@ class ParsingDriver;
|
|||
%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS
|
||||
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS
|
||||
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
|
||||
%token PERFECT_FORESIGHT_SETUP PERFECT_FORESIGHT_SOLVER
|
||||
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING
|
||||
%token <string_val> QUOTED_STRING
|
||||
%token QZ_CRITERIUM QZ_ZERO_THRESHOLD FULL DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT TRUNCATE
|
||||
|
@ -272,6 +273,8 @@ statement : parameters
|
|||
| irf_calibration
|
||||
| smoother2histval
|
||||
| histval_file
|
||||
| perfect_foresight_setup
|
||||
| perfect_foresight_solver
|
||||
;
|
||||
|
||||
dsample : DSAMPLE INT_NUMBER ';'
|
||||
|
@ -970,6 +973,37 @@ model_info_options_list : model_info_options_list COMMA model_info_options
|
|||
;
|
||||
model_info_options :
|
||||
|
||||
perfect_foresight_setup : PERFECT_FORESIGHT_SETUP ';'
|
||||
{ driver.perfect_foresight_setup(); }
|
||||
| PERFECT_FORESIGHT_SETUP '(' perfect_foresight_setup_options_list ')' ';'
|
||||
{ driver.perfect_foresight_setup(); }
|
||||
;
|
||||
|
||||
perfect_foresight_setup_options_list : perfect_foresight_setup_options_list COMMA perfect_foresight_setup_options
|
||||
| perfect_foresight_setup_options
|
||||
;
|
||||
|
||||
perfect_foresight_setup_options : o_periods
|
||||
| o_datafile
|
||||
;
|
||||
|
||||
perfect_foresight_solver : PERFECT_FORESIGHT_SOLVER ';'
|
||||
{ driver.perfect_foresight_solver(); }
|
||||
| PERFECT_FORESIGHT_SOLVER '(' perfect_foresight_solver_options_list ')' ';'
|
||||
{ driver.perfect_foresight_solver(); }
|
||||
;
|
||||
|
||||
perfect_foresight_solver_options_list : perfect_foresight_solver_options_list COMMA perfect_foresight_solver_options
|
||||
| perfect_foresight_solver_options
|
||||
;
|
||||
|
||||
perfect_foresight_solver_options : o_stack_solve_algo
|
||||
| o_markowitz
|
||||
| o_minimal_solving_periods
|
||||
| o_simul_maxit
|
||||
| o_endogenous_terminal_period
|
||||
;
|
||||
|
||||
simul : SIMUL ';'
|
||||
{ driver.simul(); }
|
||||
| SIMUL '(' simul_options_list ')' ';'
|
||||
|
@ -980,13 +1014,8 @@ simul_options_list : simul_options_list COMMA simul_options
|
|||
| simul_options
|
||||
;
|
||||
|
||||
simul_options : o_periods
|
||||
| o_datafile
|
||||
| o_stack_solve_algo
|
||||
| o_markowitz
|
||||
| o_minimal_solving_periods
|
||||
| o_simul_maxit
|
||||
| o_endogenous_terminal_period
|
||||
simul_options : perfect_foresight_setup_options
|
||||
| perfect_foresight_solver_options
|
||||
;
|
||||
|
||||
external_function : EXTERNAL_FUNCTION '(' external_function_options_list ')' ';'
|
||||
|
|
|
@ -168,6 +168,8 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
|||
<INITIAL>model_diagnostics {BEGIN DYNARE_STATEMENT; return token::MODEL_DIAGNOSTICS;}
|
||||
<INITIAL>extended_path {BEGIN DYNARE_STATEMENT; return token::EXTENDED_PATH;}
|
||||
<INITIAL>smoother2histval {BEGIN DYNARE_STATEMENT; return token::SMOOTHER2HISTVAL;}
|
||||
<INITIAL>perfect_foresight_setup {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_SETUP;}
|
||||
<INITIAL>perfect_foresight_solver {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_SOLVER;}
|
||||
|
||||
<DYNARE_STATEMENT>; {
|
||||
if (!sigma_e)
|
||||
|
|
14
ModFile.cc
14
ModFile.cc
|
@ -129,7 +129,7 @@ ModFile::checkPass()
|
|||
// Allow empty model only when doing a standalone BVAR estimation
|
||||
if (dynamic_model.equation_number() == 0
|
||||
&& (mod_file_struct.check_present
|
||||
|| mod_file_struct.simul_present
|
||||
|| mod_file_struct.perfect_foresight_solver_present
|
||||
|| stochastic_statement_present))
|
||||
{
|
||||
cerr << "ERROR: At least one model equation must be declared!" << endl;
|
||||
|
@ -153,9 +153,9 @@ ModFile::checkPass()
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (mod_file_struct.simul_present && stochastic_statement_present)
|
||||
if (mod_file_struct.perfect_foresight_solver_present && stochastic_statement_present)
|
||||
{
|
||||
cerr << "ERROR: A .mod file cannot contain both a simul command and one of {stoch_simul, estimation, osr, ramsey_policy, discretionary_policy}" << endl;
|
||||
cerr << "ERROR: A .mod file cannot contain both one of {perfect_foresight_solver,simul} and one of {stoch_simul, estimation, osr, ramsey_policy, discretionary_policy}. This is not possible: one cannot mix perfect foresight context with stochastic context in the same file." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -407,9 +407,9 @@ ModFile::transformPass(bool nostrict)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (symbol_table.exo_det_nbr() > 0 && mod_file_struct.simul_present)
|
||||
if (symbol_table.exo_det_nbr() > 0 && mod_file_struct.perfect_foresight_solver_present)
|
||||
{
|
||||
cerr << "ERROR: A .mod file cannot contain both a simul command and varexo_det declaration (all exogenous variables are deterministic in this case)" << endl;
|
||||
cerr << "ERROR: A .mod file cannot contain both one of {perfect_foresight_solver,simul} and varexo_det declaration (all exogenous variables are deterministic in this case)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -473,13 +473,13 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output)
|
|||
false, paramsDerivatives, block, byte_code);
|
||||
}
|
||||
// Set things to compute for dynamic model
|
||||
if (mod_file_struct.simul_present || mod_file_struct.check_present
|
||||
if (mod_file_struct.perfect_foresight_solver_present || mod_file_struct.check_present
|
||||
|| mod_file_struct.stoch_simul_present
|
||||
|| mod_file_struct.estimation_present || mod_file_struct.osr_present
|
||||
|| mod_file_struct.ramsey_model_present || mod_file_struct.identification_present
|
||||
|| mod_file_struct.calib_smoother_present)
|
||||
{
|
||||
if (mod_file_struct.simul_present)
|
||||
if (mod_file_struct.perfect_foresight_solver_present)
|
||||
dynamic_model.computingPass(true, false, false, false, global_eval_context, no_tmp_terms, block, use_dll, byte_code);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2692,3 +2692,18 @@ ParsingDriver::histval_file(string *filename)
|
|||
mod_file->addStatement(new HistvalFileStatement(*filename));
|
||||
delete filename;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ParsingDriver::perfect_foresight_setup()
|
||||
{
|
||||
mod_file->addStatement(new PerfectForesightSetupStatement(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::perfect_foresight_solver()
|
||||
{
|
||||
mod_file->addStatement(new PerfectForesightSolverStatement(options_list));
|
||||
options_list.clear();
|
||||
}
|
||||
|
|
|
@ -668,6 +668,8 @@ public:
|
|||
|
||||
void smoother2histval();
|
||||
void histval_file(string *filename);
|
||||
void perfect_foresight_setup();
|
||||
void perfect_foresight_solver();
|
||||
};
|
||||
|
||||
#endif // ! PARSING_DRIVER_HH
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
ModFileStructure::ModFileStructure() :
|
||||
check_present(false),
|
||||
steady_present(false),
|
||||
simul_present(false),
|
||||
perfect_foresight_solver_present(false),
|
||||
stoch_simul_present(false),
|
||||
estimation_present(false),
|
||||
osr_present(false),
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
bool check_present;
|
||||
//! Whether steady is present
|
||||
bool steady_present;
|
||||
//! Whether a simul statement is present
|
||||
bool simul_present;
|
||||
//! Whether a perfect_foresight_solver/simul statement is present
|
||||
bool perfect_foresight_solver_present;
|
||||
//! Whether a stoch_simul statement is present
|
||||
bool stoch_simul_present;
|
||||
//! Whether an estimation statement is present
|
||||
|
|
Loading…
Reference in New Issue