From badeec612f6e413dca007c1e72c24fe548d4442b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 16 Nov 2012 12:34:49 +0100 Subject: [PATCH] Add interface and documentation to model_diagnostics Closes: #205 --- doc/dynare.texi | 10 ++++++++++ preprocessor/ComputingTasks.cc | 10 ++++++++++ preprocessor/ComputingTasks.hh | 7 +++++++ preprocessor/DynareBison.yy | 7 ++++++- preprocessor/DynareFlex.ll | 1 + preprocessor/ParsingDriver.cc | 5 +++++ preprocessor/ParsingDriver.hh | 2 ++ 7 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index f108c7457b..40f2687dcd 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -2689,6 +2689,16 @@ Contains the eigenvalues of the model, as computed by the @code{check} command. @end defvr + +@deffn Command model_diagnostics ; + +This command performs various sanity checks on the model, and prints a +message if a problem is detected (missing variables at current period, +invalid steady state, singular Jacobian of static model). + +@end deffn + + @deffn Command model_info ; @deffnx Command model_info (@var{OPTIONS}@dots{}); diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 4fe107823a..f01bec395a 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -2410,3 +2410,13 @@ ExtendedPathStatement::writeOutput(ostream &output, const string &basename) cons << ") ];" << endl << "oo_.exo_simul = oo_.ep.shocks;" << endl; } + +ModelDiagnosticsStatement::ModelDiagnosticsStatement() +{ +} + +void +ModelDiagnosticsStatement::writeOutput(ostream &output, const string &basename) const +{ + output << "model_diagnostics(M_,options_,oo_);" << endl; +} diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index 5a75ea55bc..926e082d21 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -805,4 +805,11 @@ public: virtual void writeOutput(ostream &output, const string &basename) const; }; +class ModelDiagnosticsStatement : public Statement +{ +public: + ModelDiagnosticsStatement(); + virtual void writeOutput(ostream &output, const string &basename) const; +}; + #endif diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 7437560ded..b0937c20e5 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -113,7 +113,7 @@ class ParsingDriver; %token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL MARKOWITZ MARGINAL_DENSITY MAX MAXIT %token MFS MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER MIN MINIMAL_SOLVING_PERIODS SOLVE_MAXIT %token MODE_CHECK MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN -%token MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS +%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS %token <string_val> NAME %token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS %token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF @@ -270,6 +270,7 @@ statement : parameters | ms_variance_decomposition | calib_smoother | extended_path + | model_diagnostics ; dsample : DSAMPLE INT_NUMBER ';' @@ -2177,6 +2178,10 @@ extended_path_option : o_periods | o_solver_periods ; +model_diagnostics : MODEL_DIAGNOSTICS ';' + { driver.model_diagnostics(); } + ; + o_dr_algo : DR_ALGO EQUAL INT_NUMBER { if (*$3 == string("0")) driver.warning("dr_algo option is now deprecated, and may be removed in a future version of Dynare"); diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index eba4ff972f..3c8b40a9bc 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -157,6 +157,7 @@ string eofbuff; <INITIAL>external_function {BEGIN DYNARE_STATEMENT; return token::EXTERNAL_FUNCTION;} /* End of a Dynare statement */ <INITIAL>calib_smoother { BEGIN DYNARE_STATEMENT; return token::CALIB_SMOOTHER; } +<INITIAL>model_diagnostics {BEGIN DYNARE_STATEMENT; return token::MODEL_DIAGNOSTICS;} <DYNARE_STATEMENT>; { if (!sigma_e) diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index ee72245f6f..e4e36f909c 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -2493,3 +2493,8 @@ ParsingDriver::process_graph_format_option() graph_formats.clear(); } +void +ParsingDriver::model_diagnostics() +{ + mod_file->addStatement(new ModelDiagnosticsStatement()); +} diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh index 203ab6c8b2..30ae85a408 100644 --- a/preprocessor/ParsingDriver.hh +++ b/preprocessor/ParsingDriver.hh @@ -634,6 +634,8 @@ public: void add_graph_format(const string &name); //! Add the graph_format option to the OptionsList structure void process_graph_format_option(); + //! Model diagnostics + void model_diagnostics(); }; #endif // ! PARSING_DRIVER_HH -- GitLab