Commit 81f22582 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

var_model: store max lag info

parent a69c53b0
......@@ -294,7 +294,9 @@ void
VarModelStatement::fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vector<int> &lhs_arg,
vector<set<pair<int, int> > > &rhs_arg,
vector<bool> &nonstationary_arg,
vector<bool> &diff_arg, vector<int> &orig_diff_var_arg)
vector<bool> &diff_arg,
vector<int> &orig_diff_var_arg,
int max_lag_arg)
{
eqnumber = eqnumber_arg;
lhs = lhs_arg;
......@@ -302,6 +304,7 @@ VarModelStatement::fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vect
nonstationary = nonstationary_arg;
diff = diff_arg;
orig_diff_var = orig_diff_var_arg;
max_lag = max_lag_arg;
// Order RHS vars by time (already ordered by equation tag)
for (vector<set<pair<int, int> > >::const_iterator it = rhs_by_eq.begin();
......@@ -363,15 +366,7 @@ VarModelStatement::writeOutput(ostream &output, const string &basename, bool min
output << symbol_table.getTypeSpecificID(*it) + 1;
}
output << "];" << endl
<< "options_.var.rhs.lag = [";
for (map<int, set<int> >::const_iterator it = rhs.begin();
it != rhs.end(); it++)
{
if (it != rhs.begin())
output << " ";
output << it->first;
}
output << "];" << endl
<< "options_.var.max_lag = " << max_lag << ";" << endl
<< "options_.var.nonstationary = [";
for (vector<bool>::const_iterator it = nonstationary.begin();
it != nonstationary.end(); it++)
......
......@@ -130,6 +130,7 @@ private:
map<int, set<int > > rhs; // lag -> set< symb_id > (all vars that appear at a given lag)
vector<set<pair<int, int> > > rhs_by_eq; // rhs by equation
vector<bool> nonstationary, diff;
int max_lag;
public:
VarModelStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
......@@ -140,7 +141,8 @@ public:
void fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vector<int> &lhs_arg,
vector<set<pair<int, int> > > &rhs_arg,
vector<bool> &nonstationary_arg,
vector<bool> &diff_arg, vector<int> &orig_diff_var_arg);
vector<bool> &diff_arg, vector<int> &orig_diff_var_arg,
int max_lag_arg);
void getVarModelName(string &var_model_name) const;
void getVarModelRHS(map<int, set<int > > &rhs_arg) const;
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
......
......@@ -3310,8 +3310,10 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
}
void
DynamicModel::getVarLhsDiffInfo(vector<int> &eqnumber, vector<bool> &diff, vector<int> &orig_diff_var) const
DynamicModel::getVarMaxLagAndLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
vector<int> &orig_diff_var, int &max_lag) const
{
max_lag = 0;
for (vector<int>::const_iterator it = eqnumber.begin();
it != eqnumber.end(); it++)
{
......@@ -3320,6 +3322,7 @@ DynamicModel::getVarLhsDiffInfo(vector<int> &eqnumber, vector<bool> &diff, vecto
{
set<pair<int, int> > diff_set;
equations[*it]->get_arg1()->collectDynamicVariables(eEndogenous, diff_set);
if (diff_set.size() != 1)
{
cerr << "ERROR: problem getting variable for LHS diff operator in equation " << *it << endl;
......@@ -3329,6 +3332,10 @@ DynamicModel::getVarLhsDiffInfo(vector<int> &eqnumber, vector<bool> &diff, vecto
}
else
orig_diff_var.push_back(-1);
int lag = equations[*it]->get_arg2()->maxEndoLag();
if (max_lag < lag)
max_lag = lag;
}
}
......
......@@ -293,8 +293,9 @@ public:
vector<set<pair<int, int> > > &rhs,
vector<bool> &nonstationary) const;
// Get equtaino information on diff operator
void getVarLhsDiffInfo(vector<int> &eqnumber, vector<bool> &diff, vector<int> &orig_diff_var) const;
// Get equtaino information on diff operator and max lag info
void getVarMaxLagAndLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
vector<int> &orig_diff_var, int &max_lag) const;
//! Set indices for var expectation in dynamic model file
void setVarExpectationIndices(map<string, pair<SymbolList, int> > &var_model_info);
......
......@@ -379,14 +379,15 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
vms->getVarModelEqTags(var_model_eqtags);
if (!var_model_eqtags.empty())
{
int max_lag = 0;
vector<int> eqnumber, lhs, orig_diff_var;
vector<set<pair<int, int> > > rhs;
vector<bool> nonstationary, diff;
dynamic_model.getVarModelVariablesFromEqTags(var_model_eqtags,
eqnumber, lhs, rhs, nonstationary);
original_model.getVarLhsDiffInfo(eqnumber, diff, orig_diff_var);
original_model.getVarMaxLagAndLhsDiffAndInfo(eqnumber, diff, orig_diff_var, max_lag);
vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary,
diff, orig_diff_var);
diff, orig_diff_var, max_lag);
string var_model_name;
map<int, set<int > > rhs_pac;
vms->getVarModelName(var_model_name);
......
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