Commit 627031d1 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: histval lag check must be made after transformation to the...

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

(cherry picked from commit 71ee63dc)
parent 7295737d
......@@ -432,11 +432,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")
......
......@@ -141,29 +141,6 @@ ModFile::checkPass(bool nostrict)
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)
{
......@@ -408,6 +385,23 @@ ModFile::transformPass(bool nostrict, 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
......
......@@ -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");
......
......@@ -117,8 +117,6 @@ public:
int orig_eq_nbr;
//! Stores the number of equations added to the Ramsey model
int ramsey_eq_nbr;
//! 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;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment