Ramsey: do not warn if instruments are not defined in steady_state_model block

Closes: dynare#1677
issue#70
Sébastien Villemot 2019-12-12 16:03:59 +01:00
parent 047b397899
commit b58bbb8e84
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
3 changed files with 27 additions and 4 deletions

View File

@ -786,6 +786,11 @@ RamseyModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsol
(it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
// Fill list of instruments
if (auto it = options_list.symbol_list_options.find("instruments");
it != options_list.symbol_list_options.end())
mod_file_struct.instruments = it->second;
}
void
@ -944,6 +949,11 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
(it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
// Fill list of instruments
if (auto it = options_list.symbol_list_options.find("instruments");
it != options_list.symbol_list_options.end())
mod_file_struct.instruments = it->second;
}
void
@ -1067,6 +1077,11 @@ DiscretionaryPolicyStatement::checkPass(ModFileStructure &mod_file_struct, Warni
(it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
// Fill list of instruments
if (auto it = options_list.symbol_list_options.find("instruments");
it != options_list.symbol_list_options.end())
mod_file_struct.instruments = it->second;
}
void

View File

@ -120,12 +120,18 @@ SteadyStateModel::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
copy(symb_ids.begin(), symb_ids.end(), back_inserter(so_far_defined));
}
set<int> orig_endogs = symbol_table.getOrigEndogenous();
for (int orig_endog : orig_endogs)
/* Check that all original endogous are defined (except the instruments of a
Ramsey model, since the steady_state_block should give the steady state
*conditional* to those instruments) */
set<int> should_be_defined = symbol_table.getOrigEndogenous();
if (mod_file_struct.ramsey_policy_present || mod_file_struct.ramsey_model_present)
for (const auto &s : mod_file_struct.instruments.getSymbols())
should_be_defined.erase(symbol_table.getID(s));
for (int v : should_be_defined)
{
if (find(so_far_defined.begin(), so_far_defined.end(), orig_endog)
if (find(so_far_defined.begin(), so_far_defined.end(), v)
== so_far_defined.end())
warnings << "WARNING: in the 'steady_state_model' block, variable '" << symbol_table.getName(orig_endog) << "' is not assigned a value" << endl;
warnings << "WARNING: in the 'steady_state_model' block, variable '" << symbol_table.getName(v) << "' is not assigned a value" << endl;
}
}

View File

@ -129,6 +129,8 @@ public:
bool write_latex_steady_state_model_present{false};
//! Pac growth and discount
set<int> pac_params;
//! Instruments if ramsey_model, ramsey_policy or discretionary_policy is present
SymbolList instruments;
};
class Statement