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
issue#70
Sébastien Villemot 2019-07-05 17:44:10 +02:00
parent 3fda763521
commit 24d4b2dc77
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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 ';'

View File

@ -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);

View File

@ -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