From 24d4b2dc77a461047ee24f2c73388d5a09edf053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 5 Jul 2019 17:44:10 +0200 Subject: [PATCH] identification command now accepts the order option Note that this option does not modify the global options_.order, for consistency with the semantics of the identification command. The preprocessor will compute dynamic derivatives up to at least order+1. Closes #10 --- src/ComputingTasks.cc | 16 ++++++++++++++++ src/DynareBison.yy | 1 + src/ModFile.cc | 5 +++-- src/Statement.hh | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 400eda98..d6efce8d 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -2635,6 +2635,22 @@ void IdentificationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) { mod_file_struct.identification_present = true; + auto it = options_list.num_options.find("order"); + if (it != options_list.num_options.end()) + { + int order = stoi(it->second); + if (order < 1 || order > 2) + { + cerr << "ERROR: the order option of identification command must be either 1 or 2" << endl; + + exit(EXIT_FAILURE); + } + mod_file_struct.identification_order = max(mod_file_struct.identification_order, order); + + } + else + // The default value for order is 1 (which triggers 2nd order dynamic derivatives) + mod_file_struct.identification_order = max(mod_file_struct.identification_order, 1); } void diff --git a/src/DynareBison.yy b/src/DynareBison.yy index b1a2cf90..1a668e36 100644 --- a/src/DynareBison.yy +++ b/src/DynareBison.yy @@ -2247,6 +2247,7 @@ identification_option : o_ar | o_tol_sv | o_checks_via_subsets | o_max_dim_subsets_groups + | o_order ; model_comparison : MODEL_COMPARISON mc_filename_list ';' diff --git a/src/ModFile.cc b/src/ModFile.cc index d395a38b..13445056 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -758,8 +758,9 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri cerr << "ERROR: Incorrect order option..." << endl; exit(EXIT_FAILURE); } - int derivsOrder = mod_file_struct.order_option; - if (mod_file_struct.identification_present || linear || output == FileOutputType::second) + int derivsOrder = max(mod_file_struct.order_option, + mod_file_struct.identification_order + 1); + if (mod_file_struct.sensitivity_present || linear || output == FileOutputType::second) derivsOrder = max(derivsOrder, 2); if (mod_file_struct.estimation_analytic_derivation || output == FileOutputType::third) derivsOrder = max(derivsOrder, 3); diff --git a/src/Statement.hh b/src/Statement.hh index 9c7df3e5..137a2dca 100644 --- a/src/Statement.hh +++ b/src/Statement.hh @@ -68,6 +68,8 @@ public: bool svar_identification_present{false}; //! Whether an identification statement is present or the identification option of dynare_sensitivity statement is equal to one bool identification_present{false}; + //! The maximum of the “order” option in identification statements + int identification_order{0}; //! Whether a sensitivity statement is present bool sensitivity_present{false}; //! Whether the option analytic_derivation is given to estimation -- GitLab