preprocessor: histval lag check must be made after transformation to the dynamic model due to ramsey_policy. closes #1193

issue#70
Houtan Bastani 2017-09-13 11:36:14 +02:00
parent 113b8799f3
commit 620f04a422
4 changed files with 18 additions and 31 deletions

View File

@ -547,11 +547,6 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
mod_file_struct.order_option = max(mod_file_struct.order_option, order + 1);
}
OptionsList::symbol_list_options_t::const_iterator itsl =
options_list.symbol_list_options.find("instruments");
if (itsl != options_list.symbol_list_options.end())
mod_file_struct.ramsey_state_variables = itsl->second.get_symbols();
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")

View File

@ -149,29 +149,6 @@ ModFile::checkPass(bool nostrict, bool stochastic)
exit(EXIT_FAILURE);
}
// Workaround for #1193
if (!mod_file_struct.hist_vals_wrong_lag.empty())
{
for (vector<string>::const_iterator it = mod_file_struct.ramsey_state_variables.begin();
it != mod_file_struct.ramsey_state_variables.end(); it++)
{
int symb_id = symbol_table.getID(*it);
map<int,int>::const_iterator it1 = mod_file_struct.hist_vals_wrong_lag.find(symb_id);
if (it1 != mod_file_struct.hist_vals_wrong_lag.end() && it1->second < 0)
mod_file_struct.hist_vals_wrong_lag.erase(symb_id);
}
if (!mod_file_struct.hist_vals_wrong_lag.empty())
{
for (map<int, int>::const_iterator it = mod_file_struct.hist_vals_wrong_lag.begin();
it != mod_file_struct.hist_vals_wrong_lag.end(); it++)
cerr << "ERROR: histval: variable " << symbol_table.getName(it->first)
<< " does not appear in the model with the lag " << it->second
<< " (see the reference manual for the timing convention in 'histval')" << endl;
exit(EXIT_FAILURE);
}
}
if ((mod_file_struct.ramsey_model_present || mod_file_struct.ramsey_policy_present)
&& mod_file_struct.discretionary_policy_present)
{
@ -417,6 +394,23 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs)
mod_file_struct.ramsey_eq_nbr = dynamic_model.equation_number() - mod_file_struct.orig_eq_nbr;
}
// Workaround for #1193
if (!mod_file_struct.hist_vals_wrong_lag.empty())
{
bool err = false;
for (map<int, int>::const_iterator it = mod_file_struct.hist_vals_wrong_lag.begin();
it != mod_file_struct.hist_vals_wrong_lag.end(); it++)
if (dynamic_model.minLagForSymbol(it->first) > it->second - 1)
{
cerr << "ERROR: histval: variable " << symbol_table.getName(it->first)
<< " does not appear in the model with the lag " << it->second - 1
<< " (see the reference manual for the timing convention in 'histval')" << endl;
err = true;
}
if (err)
exit(EXIT_FAILURE);
}
if (mod_file_struct.stoch_simul_present
|| mod_file_struct.estimation_present
|| mod_file_struct.osr_present

View File

@ -552,7 +552,7 @@ ParsingDriver::hist_val(string *name, string *lag, expr_t rhs)
pair<int, int> key(symb_id, ilag);
if (mod_file->dynamic_model.minLagForSymbol(symb_id) > ilag - 1)
hist_vals_wrong_lag[symb_id] = ilag-1;
hist_vals_wrong_lag[symb_id] = ilag;
if (hist_values.find(key) != hist_values.end())
error("hist_val: (" + *name + ", " + *lag + ") declared twice");

View File

@ -123,8 +123,6 @@ public:
bool steady_state_model_present;
//! Whether there is a write_latex_steady_state_model statement present
bool write_latex_steady_state_model_present;
//! Set list of variables that become state variables when ramsey_policy is used
vector<string> ramsey_state_variables;
//! Histval values that do not have the appropriate lag
map<int, int> hist_vals_wrong_lag;
};