Merge branch 'master' into temporary_terms_array
commit
732a317030
|
@ -9,7 +9,7 @@ Upstream-Contact: Dynare Team, whose members in 2018 are:
|
||||||
Ferhat Mihoubi <fmihoubi@univ-evry.fr>
|
Ferhat Mihoubi <fmihoubi@univ-evry.fr>
|
||||||
Johannes Pfeifer <jpfeifer@gmx.de>
|
Johannes Pfeifer <jpfeifer@gmx.de>
|
||||||
Marco Ratto <marco.ratto@ec.europa.eu>
|
Marco Ratto <marco.ratto@ec.europa.eu>
|
||||||
Sébastien Villemot <sebastien.villemot@sciencespo.fr>
|
Sébastien Villemot <sebastien@dynare.org>
|
||||||
Source: http://www.dynare.org
|
Source: http://www.dynare.org
|
||||||
|
|
||||||
Files: *
|
Files: *
|
||||||
|
|
|
@ -258,6 +258,129 @@ PriorPosteriorFunctionStatement::writeJsonOutput(ostream &output) const
|
||||||
output << "}";
|
output << "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PacModelStatement::PacModelStatement(const string &name_arg,
|
||||||
|
const string &var_name_arg,
|
||||||
|
const string &discount_arg,
|
||||||
|
const string &growth_arg,
|
||||||
|
const map<string, int> &undiff_arg,
|
||||||
|
const SymbolTable &symbol_table_arg) :
|
||||||
|
name(name_arg),
|
||||||
|
var_name(var_name_arg),
|
||||||
|
discount(discount_arg),
|
||||||
|
growth(growth_arg),
|
||||||
|
undiff(undiff_arg),
|
||||||
|
symbol_table(symbol_table_arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PacModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||||
|
{
|
||||||
|
mod_file_struct.pac_params.insert(symbol_table.getID(discount));
|
||||||
|
if (!growth.empty())
|
||||||
|
mod_file_struct.pac_params.insert(symbol_table.getID(growth));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PacModelStatement::fillUndiffedLHS(vector<int> &lhs_arg)
|
||||||
|
{
|
||||||
|
lhs = lhs_arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PacModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||||
|
{
|
||||||
|
output << "M_.pac." << name << ".var_model_name = '" << var_name << "';" << endl
|
||||||
|
<< "M_.pac." << name << ".discount_index = " << symbol_table.getTypeSpecificID(discount) + 1 << ";" << endl;
|
||||||
|
|
||||||
|
if (!growth.empty())
|
||||||
|
{
|
||||||
|
output << "M_.pac." << name << ".growth_index = " << symbol_table.getTypeSpecificID(growth) + 1 << ";" << endl
|
||||||
|
<< "M_.pac." << name << ".growth_type = ";
|
||||||
|
switch(symbol_table.getType(growth))
|
||||||
|
{
|
||||||
|
case eEndogenous:
|
||||||
|
output << "'endogenous';" << endl;
|
||||||
|
break;
|
||||||
|
case eExogenous:
|
||||||
|
output << "'exogenous';" << endl;
|
||||||
|
break;
|
||||||
|
case eParameter:
|
||||||
|
output << "'parameter';" << endl;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cerr << "pac_model: error encountered in growth type" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output << "M_.pac." << name << ".lhs = [";
|
||||||
|
for (vector<int>::const_iterator it = lhs.begin(); it !=lhs.end(); it++)
|
||||||
|
{
|
||||||
|
if (it != lhs.begin())
|
||||||
|
output << " ";
|
||||||
|
output << *it + 1;
|
||||||
|
}
|
||||||
|
output << "];" << endl
|
||||||
|
<< "M_.pac." << name << ".undiff_eqtags = {";
|
||||||
|
for (map<string, int>::const_iterator it = undiff.begin(); it != undiff.end(); it++)
|
||||||
|
{
|
||||||
|
if (it != undiff.begin())
|
||||||
|
output << "; ";
|
||||||
|
output << "'" << it->first << "'";
|
||||||
|
}
|
||||||
|
output << "};" << endl
|
||||||
|
<< "M_.pac." << name << ".undiff_num = [";
|
||||||
|
for (map<string, int>::const_iterator it = undiff.begin(); it != undiff.end(); it++)
|
||||||
|
{
|
||||||
|
if (it != undiff.begin())
|
||||||
|
output << " ";
|
||||||
|
output << it->second;
|
||||||
|
}
|
||||||
|
output << "];" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PacModelStatement::writeJsonOutput(ostream &output) const
|
||||||
|
{
|
||||||
|
output << "{\"statementName\": \"pac_model\","
|
||||||
|
<< "\"model_name\": \"" << name << "\","
|
||||||
|
<< "\"var_model_name\": \"" << var_name << "\","
|
||||||
|
<< "\"discount_index\": " << symbol_table.getTypeSpecificID(discount) + 1;
|
||||||
|
|
||||||
|
if (!growth.empty())
|
||||||
|
{
|
||||||
|
output << ","
|
||||||
|
<< "\"growth_index\": " << symbol_table.getTypeSpecificID(growth) + 1 << ","
|
||||||
|
<< "\"growth_type\": ";
|
||||||
|
switch(symbol_table.getType(growth))
|
||||||
|
{
|
||||||
|
case eEndogenous:
|
||||||
|
output << "\"endogenous\"" << endl;
|
||||||
|
break;
|
||||||
|
case eExogenous:
|
||||||
|
output << "\"exogenous\"" << endl;
|
||||||
|
break;
|
||||||
|
case eParameter:
|
||||||
|
output << "\"parameter\"" << endl;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cerr << "pac_model: error encountered in growth type" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output << "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PacModelStatement::getPacModelInfoForPacExpectation(pair<string, pair<string, pair<string, pair<int, map<string, int> > > > > &pac_model_info) const
|
||||||
|
{
|
||||||
|
int growth_symb_id = -1;
|
||||||
|
if (!growth.empty())
|
||||||
|
growth_symb_id = symbol_table.getID(growth);
|
||||||
|
pac_model_info = make_pair(name, make_pair(var_name, make_pair(discount, make_pair(growth_symb_id, undiff))));
|
||||||
|
}
|
||||||
|
|
||||||
VarModelStatement::VarModelStatement(const SymbolList &symbol_list_arg,
|
VarModelStatement::VarModelStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const string &name_arg,
|
const string &name_arg,
|
||||||
|
@ -270,24 +393,21 @@ VarModelStatement::VarModelStatement(const SymbolList &symbol_list_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VarModelStatement::getVarModelInfoForVarExpectation(map<string, pair<SymbolList, int> > &var_model_info) const
|
VarModelStatement::getVarModelInfo(string &var_model_name,
|
||||||
|
map<string, pair<SymbolList, int> > &var_model_info,
|
||||||
|
map<string, vector<string> > &var_model_eqtags) const
|
||||||
{
|
{
|
||||||
|
var_model_name = name;
|
||||||
if (symbol_list.empty())
|
if (symbol_list.empty())
|
||||||
return;
|
{
|
||||||
|
OptionsList::vec_str_options_t::const_iterator it = options_list.vector_str_options.find("var.eqtags");
|
||||||
|
var_model_eqtags[name] = it->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("var.order");
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("var.order");
|
||||||
var_model_info[name] = make_pair(symbol_list, atoi(it->second.c_str()));
|
var_model_info[name] = make_pair(symbol_list, atoi(it->second.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
VarModelStatement::getVarModelEqTags(vector<string> &var_model_eqtags) const
|
|
||||||
{
|
|
||||||
if (!symbol_list.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
OptionsList::vec_str_options_t::const_iterator it1 =
|
|
||||||
options_list.vector_str_options.find("var.eqtags");
|
|
||||||
var_model_eqtags = it1->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -307,12 +427,6 @@ VarModelStatement::fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vect
|
||||||
max_lag = max_lag_arg;
|
max_lag = max_lag_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
VarModelStatement::getVarModelName(string &var_model_name) const
|
|
||||||
{
|
|
||||||
var_model_name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VarModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
VarModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,6 +119,30 @@ public:
|
||||||
virtual void writeJsonOutput(ostream &output) const;
|
virtual void writeJsonOutput(ostream &output) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PacModelStatement : public Statement
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const string &name;
|
||||||
|
const string &var_name;
|
||||||
|
const string &discount;
|
||||||
|
const string &growth;
|
||||||
|
const map<string, int> undiff;
|
||||||
|
const SymbolTable &symbol_table;
|
||||||
|
vector<int> lhs;
|
||||||
|
public:
|
||||||
|
PacModelStatement(const string &name_arg,
|
||||||
|
const string &var_name_arg,
|
||||||
|
const string &discount_arg,
|
||||||
|
const string &growth_arg,
|
||||||
|
const map<string, int> &undiff_arg,
|
||||||
|
const SymbolTable &symbol_table_arg);
|
||||||
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
|
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||||
|
virtual void writeJsonOutput(ostream &output) const;
|
||||||
|
void fillUndiffedLHS(vector<int> &lhs);
|
||||||
|
void getPacModelInfoForPacExpectation(pair<string, pair<string, pair<string, pair<int, map<string, int> > > > > &pac_model_info) const;
|
||||||
|
};
|
||||||
|
|
||||||
class VarModelStatement : public Statement
|
class VarModelStatement : public Statement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -135,14 +159,14 @@ public:
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const string &name_arg,
|
const string &name_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
void getVarModelInfoForVarExpectation(map<string, pair<SymbolList, int> > &var_model_info) const;
|
void getVarModelInfo(string &var_model_name,
|
||||||
void getVarModelEqTags(vector<string> &var_model_eqtags) const;
|
map<string, pair<SymbolList, int> > &var_model_info,
|
||||||
|
map<string, vector<string> > &var_model_eqtags) const;
|
||||||
void fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vector<int> &lhs_arg,
|
void fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vector<int> &lhs_arg,
|
||||||
vector<set<pair<int, int> > > &rhs_arg,
|
vector<set<pair<int, int> > > &rhs_arg,
|
||||||
vector<bool> &nonstationary_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);
|
int max_lag_arg);
|
||||||
void getVarModelName(string &var_model_name) const;
|
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||||
void createVarModelMFunction(ostream &output, const map<string, set<int> > &var_expectation_functions_to_write) const;
|
void createVarModelMFunction(ostream &output, const map<string, set<int> > &var_expectation_functions_to_write) const;
|
||||||
|
|
|
@ -515,14 +515,13 @@ DataTree::AddVarExpectation(const int symb_id, const int forecast_horizon, const
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddPacExpectation(const string &model_name, const string &var_model_name, const int discount_id, const int growth_id)
|
DataTree::AddPacExpectation(const string &model_name)
|
||||||
{
|
{
|
||||||
pac_expectation_node_map_t::iterator it =
|
pac_expectation_node_map_t::iterator it = pac_expectation_node_map.find(model_name);
|
||||||
pac_expectation_node_map.find(make_pair(model_name, make_pair(var_model_name, make_pair(discount_id, growth_id))));
|
|
||||||
if (it != pac_expectation_node_map.end())
|
if (it != pac_expectation_node_map.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
return new PacExpectationNode(*this, model_name, var_model_name, discount_id, growth_id);
|
return new PacExpectationNode(*this, model_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
|
|
|
@ -81,8 +81,8 @@ protected:
|
||||||
typedef map<pair<string, pair<int, int> >, VarExpectationNode *> var_expectation_node_map_t;
|
typedef map<pair<string, pair<int, int> >, VarExpectationNode *> var_expectation_node_map_t;
|
||||||
var_expectation_node_map_t var_expectation_node_map;
|
var_expectation_node_map_t var_expectation_node_map;
|
||||||
|
|
||||||
// (model_name, (discount, growth)) -> PacExpectationNode
|
// model_name -> PacExpectationNode
|
||||||
typedef map<pair<string, pair<string, pair<int, int> > >, PacExpectationNode *> pac_expectation_node_map_t;
|
typedef map<string, PacExpectationNode *> pac_expectation_node_map_t;
|
||||||
pac_expectation_node_map_t pac_expectation_node_map;
|
pac_expectation_node_map_t pac_expectation_node_map;
|
||||||
|
|
||||||
// ((arguments, deriv_idx), symb_id) -> FirstDerivExternalFunctionNode
|
// ((arguments, deriv_idx), symb_id) -> FirstDerivExternalFunctionNode
|
||||||
|
@ -231,7 +231,7 @@ public:
|
||||||
//! Adds "var_expectation(arg1, arg2, model_name=arg3)" to model tree
|
//! Adds "var_expectation(arg1, arg2, model_name=arg3)" to model tree
|
||||||
expr_t AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name);
|
expr_t AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name);
|
||||||
//! Adds pac_expectation command to model tree
|
//! Adds pac_expectation command to model tree
|
||||||
expr_t AddPacExpectation(const string &model_name, const string &var_model_name, const int discount_id, const int growth_id);
|
expr_t AddPacExpectation(const string &model_name);
|
||||||
//! Adds a model local variable with its value
|
//! Adds a model local variable with its value
|
||||||
void AddLocalVariable(int symb_id, expr_t value) throw (LocalVariableException);
|
void AddLocalVariable(int symb_id, expr_t value) throw (LocalVariableException);
|
||||||
//! Adds an external function node
|
//! Adds an external function node
|
||||||
|
|
|
@ -3486,6 +3486,7 @@ void
|
||||||
DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
|
DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
|
||||||
vector<int> &eqnumber,
|
vector<int> &eqnumber,
|
||||||
vector<int> &lhs,
|
vector<int> &lhs,
|
||||||
|
vector<expr_t> &lhs_expr_t,
|
||||||
vector<set<pair<int, int> > > &rhs,
|
vector<set<pair<int, int> > > &rhs,
|
||||||
vector<bool> &nonstationary) const
|
vector<bool> &nonstationary) const
|
||||||
{
|
{
|
||||||
|
@ -3544,6 +3545,10 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
|
||||||
|
|
||||||
eqnumber.push_back(eqn);
|
eqnumber.push_back(eqn);
|
||||||
lhs.push_back(it->first);
|
lhs.push_back(it->first);
|
||||||
|
lhs_set.clear();
|
||||||
|
set<expr_t> lhs_expr_t_set;
|
||||||
|
equations[eqn]->get_arg1()->collectVARLHSVariable(lhs_expr_t_set);
|
||||||
|
lhs_expr_t.push_back(*(lhs_expr_t_set.begin()));
|
||||||
|
|
||||||
equations[eqn]->get_arg2()->collectDynamicVariables(eEndogenous, rhs_set);
|
equations[eqn]->get_arg2()->collectDynamicVariables(eEndogenous, rhs_set);
|
||||||
for (it = rhs_set.begin(); it != rhs_set.end(); it++)
|
for (it = rhs_set.begin(); it != rhs_set.end(); it++)
|
||||||
|
@ -3558,10 +3563,58 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::getVarMaxLagAndLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
|
DynamicModel::checkVarMinLag(vector<int> &eqnumber) const
|
||||||
vector<int> &orig_diff_var, int &max_lag) const
|
{
|
||||||
|
int eqn = 1;
|
||||||
|
for (vector<int>::const_iterator it = eqnumber.begin();
|
||||||
|
it != eqnumber.end(); it++, eqn++)
|
||||||
|
{
|
||||||
|
int min_lag = -1;
|
||||||
|
min_lag = equations[*it]->get_arg2()->VarMinLag();
|
||||||
|
if (min_lag <= 0)
|
||||||
|
{
|
||||||
|
cerr << "ERROR in VAR Equation #" << eqn << ". "
|
||||||
|
<< "Leaded exogenous variables and leaded or contemporaneous endogenous variables not allowed in VAR";
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
DynamicModel::getVarMaxLag(StaticModel &static_model, vector<int> &eqnumber) const
|
||||||
|
{
|
||||||
|
vector<expr_t> lhs;
|
||||||
|
for (vector<int>::const_iterator it = eqnumber.begin();
|
||||||
|
it != eqnumber.end(); it++)
|
||||||
|
{
|
||||||
|
set<expr_t> lhs_set;
|
||||||
|
equations[*it]->get_arg1()->collectVARLHSVariable(lhs_set);
|
||||||
|
if (lhs_set.size() != 1)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: in Equation "
|
||||||
|
<< ". A VAR may only have one endogenous variable on the LHS. " << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
lhs.push_back(*(lhs_set.begin()));
|
||||||
|
}
|
||||||
|
|
||||||
|
set<expr_t> lhs_static;
|
||||||
|
for(vector<expr_t>::const_iterator it = lhs.begin();
|
||||||
|
it != lhs.end(); it++)
|
||||||
|
lhs_static.insert((*it)->toStatic(static_model));
|
||||||
|
|
||||||
|
int max_lag = 0;
|
||||||
|
for (vector<int>::const_iterator it = eqnumber.begin();
|
||||||
|
it != eqnumber.end(); it++)
|
||||||
|
equations[*it]->get_arg2()->VarMaxLag(static_model, lhs_static, max_lag);
|
||||||
|
|
||||||
|
return max_lag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicModel::getVarLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
|
||||||
|
vector<int> &orig_diff_var) const
|
||||||
{
|
{
|
||||||
max_lag = 0;
|
|
||||||
for (vector<int>::const_iterator it = eqnumber.begin();
|
for (vector<int>::const_iterator it = eqnumber.begin();
|
||||||
it != eqnumber.end(); it++)
|
it != eqnumber.end(); it++)
|
||||||
{
|
{
|
||||||
|
@ -3580,10 +3633,6 @@ DynamicModel::getVarMaxLagAndLhsDiffAndInfo(vector<int> &eqnumber, vector<bool>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
orig_diff_var.push_back(-1);
|
orig_diff_var.push_back(-1);
|
||||||
|
|
||||||
int lag = equations[*it]->get_arg2()->maxEndoLag();
|
|
||||||
if (max_lag < lag)
|
|
||||||
max_lag = lag;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3646,6 +3695,114 @@ DynamicModel::addEquationsForVar(map<string, pair<SymbolList, int> > &var_model_
|
||||||
cout << "Accounting for var_model lags not in model block: added " << count << " auxiliary variables and equations." << endl;
|
cout << "Accounting for var_model lags not in model block: added " << count << " auxiliary variables and equations." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicModel::getUndiffLHSForPac(vector<int> &lhs, vector<expr_t> &lhs_expr_t, vector<bool> &diff, vector<int> &orig_diff_var,
|
||||||
|
vector<int> &eqnumber, map<string, int> &undiff, ExprNode::subst_table_t &diff_subst_table)
|
||||||
|
{
|
||||||
|
if (undiff.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (map<string, int>::const_iterator it = undiff.begin();
|
||||||
|
it != undiff.end(); it++)
|
||||||
|
{
|
||||||
|
int eqn = -1;
|
||||||
|
string eqtag (it->first);
|
||||||
|
for (vector<pair<int, pair<string, string> > >::const_iterator iteqtag =
|
||||||
|
equation_tags.begin(); iteqtag != equation_tags.end(); iteqtag++)
|
||||||
|
if (iteqtag->second.first == "name"
|
||||||
|
&& iteqtag->second.second == eqtag)
|
||||||
|
{
|
||||||
|
eqn = iteqtag->first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eqn == -1)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: equation tag '" << eqtag << "' not found" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (vector<int>::const_iterator it1 = eqnumber.begin();
|
||||||
|
it1 != eqnumber.end(); it1++, i++)
|
||||||
|
if (*it1 == eqn)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (eqnumber[i] != eqn)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: equation not found in VAR";
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff.at(eqnumber[i]) != true)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: the variable on the LHS of equation #" << eqn << " (VAR equation #" << eqnumber[i]
|
||||||
|
<< " with equation tag '" << eqtag
|
||||||
|
<< "') does not have the diff operator applied to it yet you are trying to undiff it." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool printerr = false;
|
||||||
|
ExprNode::subst_table_t::const_iterator it1;
|
||||||
|
expr_t node = NULL;
|
||||||
|
expr_t aux_var = lhs_expr_t.at(i);
|
||||||
|
for (it1 = diff_subst_table.begin(); it1 != diff_subst_table.end(); it1++)
|
||||||
|
if (it1->second == aux_var)
|
||||||
|
{
|
||||||
|
node = const_cast<expr_t>(it1->first);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node == NULL)
|
||||||
|
{
|
||||||
|
cerr << "Unexpected error encountered." << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = it->second; j > 0; j--)
|
||||||
|
if (printerr)
|
||||||
|
{
|
||||||
|
cerr << "You are undiffing the LHS of equation #" << eqn << " "
|
||||||
|
<< it->second << " times but it has only been diffed " << j << " time(s)" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
node = node->undiff();
|
||||||
|
it1 = diff_subst_table.find(node);
|
||||||
|
if (it1 == diff_subst_table.end())
|
||||||
|
printerr = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printerr)
|
||||||
|
{ // we have undiffed something like diff(x), hence x is not in diff_subst_table
|
||||||
|
lhs_expr_t.at(i) = node;
|
||||||
|
lhs.at(i) = dynamic_cast<VariableNode *>(node)->get_symb_id();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lhs_expr_t.at(i) = const_cast<expr_t>(it1->first);
|
||||||
|
lhs.at(i) = const_cast<VariableNode *>(it1->second)->get_symb_id();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
DynamicModel::getUndiffMaxLag(StaticModel &static_model, vector<expr_t> &lhs, vector<int> &eqnumber) const
|
||||||
|
{
|
||||||
|
set<expr_t> lhs_static;
|
||||||
|
for(vector<expr_t>::const_iterator it = lhs.begin();
|
||||||
|
it != lhs.end(); it++)
|
||||||
|
lhs_static.insert((*it)->toStatic(static_model));
|
||||||
|
|
||||||
|
int max_lag = 0;
|
||||||
|
for (vector<int>::const_iterator it = eqnumber.begin();
|
||||||
|
it != eqnumber.end(); it++)
|
||||||
|
equations[*it]->get_arg2()->VarMaxLag(static_model, lhs_static, max_lag);
|
||||||
|
|
||||||
|
return max_lag;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::walkPacParameters()
|
DynamicModel::walkPacParameters()
|
||||||
{
|
{
|
||||||
|
@ -3653,10 +3810,11 @@ DynamicModel::walkPacParameters()
|
||||||
{
|
{
|
||||||
bool pac_encountered = false;
|
bool pac_encountered = false;
|
||||||
pair<int, int> lhs (-1, -1);
|
pair<int, int> lhs (-1, -1);
|
||||||
set<pair<int, pair<int, int> > > params_and_vals;
|
set<pair<int, pair<int, int> > > params_and_vars;
|
||||||
equations[i]->walkPacParameters(pac_encountered, lhs, params_and_vals);
|
set<pair<int, pair<int, int> > > ecm_params_and_vars;
|
||||||
|
equations[i]->walkPacParameters(pac_encountered, lhs, ecm_params_and_vars, params_and_vars);
|
||||||
if (pac_encountered)
|
if (pac_encountered)
|
||||||
equations[i]->addParamInfoToPac(lhs, params_and_vals);
|
equations[i]->addParamInfoToPac(lhs, ecm_params_and_vars, params_and_vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3664,10 +3822,11 @@ void
|
||||||
DynamicModel::fillPacExpectationVarInfo(string &var_model_name,
|
DynamicModel::fillPacExpectationVarInfo(string &var_model_name,
|
||||||
vector<int> &lhs,
|
vector<int> &lhs,
|
||||||
int max_lag,
|
int max_lag,
|
||||||
vector<bool> &nonstationary)
|
vector<bool> &nonstationary,
|
||||||
|
int growth_symb_id)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < equations.size(); i++)
|
for (size_t i = 0; i < equations.size(); i++)
|
||||||
equations[i]->fillPacExpectationVarInfo(var_model_name, lhs, max_lag, nonstationary, i);
|
equations[i]->fillPacExpectationVarInfo(var_model_name, lhs, max_lag, nonstationary, growth_symb_id, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -5261,7 +5420,7 @@ DynamicModel::substituteAdl()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::substituteDiff(StaticModel &static_model)
|
DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table)
|
||||||
{
|
{
|
||||||
// Find diff Nodes
|
// Find diff Nodes
|
||||||
diff_table_t diff_table;
|
diff_table_t diff_table;
|
||||||
|
@ -5274,7 +5433,6 @@ DynamicModel::substituteDiff(StaticModel &static_model)
|
||||||
|
|
||||||
// Substitute in model local variables
|
// Substitute in model local variables
|
||||||
vector<BinaryOpNode *> neweqs;
|
vector<BinaryOpNode *> neweqs;
|
||||||
ExprNode::subst_table_t diff_subst_table;
|
|
||||||
for (map<int, expr_t>::iterator it = local_variables_table.begin();
|
for (map<int, expr_t>::iterator it = local_variables_table.begin();
|
||||||
it != local_variables_table.end(); it++)
|
it != local_variables_table.end(); it++)
|
||||||
it->second = it->second->substituteDiff(static_model, diff_table, diff_subst_table, neweqs);
|
it->second = it->second->substituteDiff(static_model, diff_table, diff_subst_table, neweqs);
|
||||||
|
@ -5342,6 +5500,10 @@ DynamicModel::substituteExpectation(bool partial_information_model)
|
||||||
void
|
void
|
||||||
DynamicModel::transformPredeterminedVariables()
|
DynamicModel::transformPredeterminedVariables()
|
||||||
{
|
{
|
||||||
|
for (map<int, expr_t>::iterator it = local_variables_table.begin();
|
||||||
|
it != local_variables_table.end(); it++)
|
||||||
|
it->second = it->second->decreaseLeadsLagsPredeterminedVariables();
|
||||||
|
|
||||||
for (int i = 0; i < (int) equations.size(); i++)
|
for (int i = 0; i < (int) equations.size(); i++)
|
||||||
{
|
{
|
||||||
BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->decreaseLeadsLagsPredeterminedVariables());
|
BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->decreaseLeadsLagsPredeterminedVariables());
|
||||||
|
|
|
@ -300,12 +300,19 @@ public:
|
||||||
void getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
|
void getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
|
||||||
vector<int> &eqnumber,
|
vector<int> &eqnumber,
|
||||||
vector<int> &lhs,
|
vector<int> &lhs,
|
||||||
|
vector<expr_t> &lhs_expr_t,
|
||||||
vector<set<pair<int, int> > > &rhs,
|
vector<set<pair<int, int> > > &rhs,
|
||||||
vector<bool> &nonstationary) const;
|
vector<bool> &nonstationary) const;
|
||||||
|
|
||||||
|
//! Returns the max lag of the VAR
|
||||||
|
void checkVarMinLag(vector<int> &eqnumber) const;
|
||||||
|
|
||||||
|
//! Returns the max lag of the VAR
|
||||||
|
int getVarMaxLag(StaticModel &static_model, vector<int> &eqnumber) const;
|
||||||
|
|
||||||
// Get equtaino information on diff operator and max lag info
|
// Get equtaino information on diff operator and max lag info
|
||||||
void getVarMaxLagAndLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
|
void getVarLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
|
||||||
vector<int> &orig_diff_var, int &max_lag) const;
|
vector<int> &orig_diff_var) const;
|
||||||
|
|
||||||
//! Set indices for var expectation in dynamic model file
|
//! Set indices for var expectation in dynamic model file
|
||||||
void setVarExpectationIndices(map<string, pair<SymbolList, int> > &var_model_info);
|
void setVarExpectationIndices(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
|
@ -317,7 +324,11 @@ public:
|
||||||
void fillPacExpectationVarInfo(string &var_model_name,
|
void fillPacExpectationVarInfo(string &var_model_name,
|
||||||
vector<int> &lhs,
|
vector<int> &lhs,
|
||||||
int max_lag,
|
int max_lag,
|
||||||
vector<bool> &nonstationary);
|
vector<bool> &nonstationary,
|
||||||
|
int growth_symb_id);
|
||||||
|
//! Get the max lag for the PAC VAR
|
||||||
|
int getUndiffMaxLag(StaticModel &static_model, vector<expr_t> &lhs, vector<int> &eqnumber) const;
|
||||||
|
|
||||||
//! Substitutes pac_expectation operator
|
//! Substitutes pac_expectation operator
|
||||||
void substitutePacExpectation();
|
void substitutePacExpectation();
|
||||||
|
|
||||||
|
@ -409,7 +420,11 @@ public:
|
||||||
void substituteAdl();
|
void substituteAdl();
|
||||||
|
|
||||||
//! Substitutes diff operator
|
//! Substitutes diff operator
|
||||||
void substituteDiff(StaticModel &static_model);
|
void substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table);
|
||||||
|
|
||||||
|
//! Table to undiff LHS variables for pac vector z
|
||||||
|
void getUndiffLHSForPac(vector<int> &lhs, vector<expr_t> &lhs_expr_t, vector<bool> &diff, vector<int> &orig_diff_var,
|
||||||
|
vector<int> &eqnumber, map<string, int> &undiff, ExprNode::subst_table_t &diff_subst_table);
|
||||||
|
|
||||||
//! Adds contents of diff_aux_equations to the back of aux_equations
|
//! Adds contents of diff_aux_equations to the back of aux_equations
|
||||||
void combineDiffAuxEquations();
|
void combineDiffAuxEquations();
|
||||||
|
|
|
@ -107,7 +107,7 @@ class ParsingDriver;
|
||||||
%token FAST_KALMAN_FILTER KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF TOLX PLOT_INIT_DATE PLOT_END_DATE
|
%token FAST_KALMAN_FILTER KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF TOLX PLOT_INIT_DATE PLOT_END_DATE
|
||||||
%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_RESULTS_AFTER_LOAD_MH LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV LINEAR_APPROXIMATION
|
%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_RESULTS_AFTER_LOAD_MH LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV LINEAR_APPROXIMATION
|
||||||
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
|
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
|
||||||
%token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS
|
%token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_TUNE_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS
|
||||||
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
|
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
|
||||||
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
|
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
|
||||||
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
|
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
|
||||||
|
@ -132,7 +132,7 @@ class ParsingDriver;
|
||||||
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
|
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
|
||||||
%token VALUES VAR VAREXO VAREXO_DET VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
|
%token VALUES VAR VAREXO VAREXO_DET VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
|
||||||
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL CROSSEQUATIONS COVARIANCE WRITE_LATEX_STEADY_STATE_MODEL
|
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL CROSSEQUATIONS COVARIANCE WRITE_LATEX_STEADY_STATE_MODEL
|
||||||
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL QOQ YOY AOA PAC_EXPECTATION
|
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL PAC_MODEL QOQ YOY AOA UNDIFF PAC_EXPECTATION
|
||||||
%left COMMA
|
%left COMMA
|
||||||
%left EQUAL_EQUAL EXCLAMATION_EQUAL
|
%left EQUAL_EQUAL EXCLAMATION_EQUAL
|
||||||
%left LESS GREATER LESS_EQUAL GREATER_EQUAL
|
%left LESS GREATER LESS_EQUAL GREATER_EQUAL
|
||||||
|
@ -233,6 +233,7 @@ statement : parameters
|
||||||
| set_time
|
| set_time
|
||||||
| data
|
| data
|
||||||
| var_model
|
| var_model
|
||||||
|
| pac_model
|
||||||
| restrictions
|
| restrictions
|
||||||
| prior
|
| prior
|
||||||
| prior_eq
|
| prior_eq
|
||||||
|
@ -383,6 +384,20 @@ var_model_options : o_var_name
|
||||||
| o_var_eq_tags
|
| o_var_eq_tags
|
||||||
;
|
;
|
||||||
|
|
||||||
|
pac_model : PAC_MODEL '(' pac_model_options_list ')' ';' { driver.pac_model(); } ;
|
||||||
|
|
||||||
|
pac_model_options_list : pac_model_options_list COMMA pac_model_options
|
||||||
|
| pac_model_options
|
||||||
|
;
|
||||||
|
|
||||||
|
pac_model_options : o_pac_name
|
||||||
|
| o_pac_var_name
|
||||||
|
| o_pac_discount
|
||||||
|
| o_pac_growth
|
||||||
|
| UNDIFF '(' QUOTED_STRING COMMA INT_NUMBER ')'
|
||||||
|
{ driver.pac_model_undiff($3, $5); }
|
||||||
|
;
|
||||||
|
|
||||||
restrictions : RESTRICTIONS '(' symbol ')' ';' { driver.begin_VAR_restrictions(); }
|
restrictions : RESTRICTIONS '(' symbol ')' ';' { driver.begin_VAR_restrictions(); }
|
||||||
restrictions_list END ';' { driver.end_VAR_restrictions($3); }
|
restrictions_list END ';' { driver.end_VAR_restrictions($3); }
|
||||||
;
|
;
|
||||||
|
@ -914,8 +929,8 @@ hand_side : '(' hand_side ')'
|
||||||
{ $$ = driver.add_var_expectation($3, new string("1"), $7); }
|
{ $$ = driver.add_var_expectation($3, new string("1"), $7); }
|
||||||
| VAR_EXPECTATION '(' symbol COMMA INT_NUMBER COMMA MODEL_NAME EQUAL NAME ')'
|
| VAR_EXPECTATION '(' symbol COMMA INT_NUMBER COMMA MODEL_NAME EQUAL NAME ')'
|
||||||
{ $$ = driver.add_var_expectation($3, $5, $9); }
|
{ $$ = driver.add_var_expectation($3, $5, $9); }
|
||||||
| PAC_EXPECTATION '(' pac_expectation_options_list ')'
|
| PAC_EXPECTATION '(' symbol ')'
|
||||||
{ $$ = driver.add_pac_expectation(); }
|
{ $$ = driver.add_pac_expectation($3); }
|
||||||
| MINUS hand_side %prec UMINUS
|
| MINUS hand_side %prec UMINUS
|
||||||
{ $$ = driver.add_uminus($2); }
|
{ $$ = driver.add_uminus($2); }
|
||||||
| PLUS hand_side
|
| PLUS hand_side
|
||||||
|
@ -974,21 +989,6 @@ hand_side : '(' hand_side ')'
|
||||||
{ $$ = driver.add_steady_state($3); }
|
{ $$ = driver.add_steady_state($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
pac_expectation_options_list : pac_expectation_options_list COMMA pac_expectation_options
|
|
||||||
| pac_expectation_options
|
|
||||||
;
|
|
||||||
|
|
||||||
pac_expectation_options : VAR_MODEL_NAME EQUAL NAME
|
|
||||||
{ driver.add_pac_expectation_var_model_name($3); }
|
|
||||||
| MODEL_NAME EQUAL NAME
|
|
||||||
{ driver.add_pac_expectation_model_name($3); }
|
|
||||||
| DISCOUNT EQUAL symbol
|
|
||||||
{ driver.add_pac_expectation_discount($3); }
|
|
||||||
| GROWTH EQUAL symbol
|
|
||||||
{ driver.add_pac_expectation_growth($3); }
|
|
||||||
;
|
|
||||||
|
|
||||||
comma_hand_side : hand_side
|
comma_hand_side : hand_side
|
||||||
{ driver.add_external_function_arg($1); }
|
{ driver.add_external_function_arg($1); }
|
||||||
| comma_hand_side COMMA hand_side
|
| comma_hand_side COMMA hand_side
|
||||||
|
@ -2018,6 +2018,7 @@ estimation_options : o_datafile
|
||||||
| o_mh_replic
|
| o_mh_replic
|
||||||
| o_mh_drop
|
| o_mh_drop
|
||||||
| o_mh_jscale
|
| o_mh_jscale
|
||||||
|
| o_mh_tune_jscale
|
||||||
| o_optim
|
| o_optim
|
||||||
| o_mh_init_scale
|
| o_mh_init_scale
|
||||||
| o_mode_file
|
| o_mode_file
|
||||||
|
@ -3203,6 +3204,10 @@ o_simul_seed : SIMUL_SEED EQUAL INT_NUMBER { driver.error("'simul_seed' option i
|
||||||
o_qz_criterium : QZ_CRITERIUM EQUAL non_negative_number { driver.option_num("qz_criterium", $3); };
|
o_qz_criterium : QZ_CRITERIUM EQUAL non_negative_number { driver.option_num("qz_criterium", $3); };
|
||||||
o_qz_zero_threshold : QZ_ZERO_THRESHOLD EQUAL non_negative_number { driver.option_num("qz_zero_threshold", $3); };
|
o_qz_zero_threshold : QZ_ZERO_THRESHOLD EQUAL non_negative_number { driver.option_num("qz_zero_threshold", $3); };
|
||||||
o_file : FILE EQUAL filename { driver.option_str("file", $3); };
|
o_file : FILE EQUAL filename { driver.option_str("file", $3); };
|
||||||
|
o_pac_name : MODEL_NAME EQUAL symbol { driver.option_str("pac.model_name", $3); };
|
||||||
|
o_pac_var_name : VAR_MODEL_NAME EQUAL symbol { driver.option_str("pac.var_model_name", $3); };
|
||||||
|
o_pac_discount : DISCOUNT EQUAL symbol { driver.option_str("pac.discount", $3); };
|
||||||
|
o_pac_growth : GROWTH EQUAL symbol { driver.option_str("pac.growth", $3); };
|
||||||
o_var_name : MODEL_NAME EQUAL symbol { driver.option_str("var.model_name", $3); };
|
o_var_name : MODEL_NAME EQUAL symbol { driver.option_str("var.model_name", $3); };
|
||||||
o_var_order : ORDER EQUAL INT_NUMBER { driver.option_num("var.order", $3); };
|
o_var_order : ORDER EQUAL INT_NUMBER { driver.option_num("var.order", $3); };
|
||||||
o_series : SERIES EQUAL symbol { driver.option_str("series", $3); };
|
o_series : SERIES EQUAL symbol { driver.option_str("series", $3); };
|
||||||
|
@ -3304,6 +3309,9 @@ o_mh_replic : MH_REPLIC EQUAL INT_NUMBER { driver.option_num("mh_replic", $3); }
|
||||||
o_posterior_max_subsample_draws : POSTERIOR_MAX_SUBSAMPLE_DRAWS EQUAL INT_NUMBER { driver.option_num("posterior_max_subsample_draws", $3); };
|
o_posterior_max_subsample_draws : POSTERIOR_MAX_SUBSAMPLE_DRAWS EQUAL INT_NUMBER { driver.option_num("posterior_max_subsample_draws", $3); };
|
||||||
o_mh_drop : MH_DROP EQUAL non_negative_number { driver.option_num("mh_drop", $3); };
|
o_mh_drop : MH_DROP EQUAL non_negative_number { driver.option_num("mh_drop", $3); };
|
||||||
o_mh_jscale : MH_JSCALE EQUAL non_negative_number { driver.option_num("mh_jscale", $3); };
|
o_mh_jscale : MH_JSCALE EQUAL non_negative_number { driver.option_num("mh_jscale", $3); };
|
||||||
|
o_mh_tune_jscale : MH_TUNE_JSCALE EQUAL non_negative_number
|
||||||
|
{ driver.option_num("mh_tune_jscale.target", $3); driver.option_num("mh_tune_jscale.status", "true");}
|
||||||
|
| MH_TUNE_JSCALE {driver.option_num("mh_tune_jscale.status", "true");};
|
||||||
o_optim : OPTIM EQUAL '(' optim_options ')';
|
o_optim : OPTIM EQUAL '(' optim_options ')';
|
||||||
o_posterior_sampler_options : POSTERIOR_SAMPLER_OPTIONS EQUAL '(' sampling_options ')' ;
|
o_posterior_sampler_options : POSTERIOR_SAMPLER_OPTIONS EQUAL '(' sampling_options ')' ;
|
||||||
o_proposal_distribution : PROPOSAL_DISTRIBUTION EQUAL symbol { driver.option_str("posterior_sampler_options.posterior_sampling_method.proposal_distribution", $3); };
|
o_proposal_distribution : PROPOSAL_DISTRIBUTION EQUAL symbol { driver.option_str("posterior_sampler_options.posterior_sampling_method.proposal_distribution", $3); };
|
||||||
|
|
|
@ -140,6 +140,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
<INITIAL>simul {BEGIN DYNARE_STATEMENT; return token::SIMUL;}
|
<INITIAL>simul {BEGIN DYNARE_STATEMENT; return token::SIMUL;}
|
||||||
<INITIAL>stoch_simul {BEGIN DYNARE_STATEMENT; return token::STOCH_SIMUL;}
|
<INITIAL>stoch_simul {BEGIN DYNARE_STATEMENT; return token::STOCH_SIMUL;}
|
||||||
<INITIAL>var_model {BEGIN DYNARE_STATEMENT; return token::VAR_MODEL;}
|
<INITIAL>var_model {BEGIN DYNARE_STATEMENT; return token::VAR_MODEL;}
|
||||||
|
<INITIAL>pac_model {BEGIN DYNARE_STATEMENT; return token::PAC_MODEL;}
|
||||||
<INITIAL>dsample {BEGIN DYNARE_STATEMENT; return token::DSAMPLE;}
|
<INITIAL>dsample {BEGIN DYNARE_STATEMENT; return token::DSAMPLE;}
|
||||||
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
|
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
|
||||||
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
|
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
|
||||||
|
@ -304,6 +305,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
<DYNARE_STATEMENT>mh_drop {return token::MH_DROP;}
|
<DYNARE_STATEMENT>mh_drop {return token::MH_DROP;}
|
||||||
<DYNARE_STATEMENT>mh_jscale {return token::MH_JSCALE;}
|
<DYNARE_STATEMENT>mh_jscale {return token::MH_JSCALE;}
|
||||||
<DYNARE_STATEMENT>mh_init_scale {return token::MH_INIT_SCALE;}
|
<DYNARE_STATEMENT>mh_init_scale {return token::MH_INIT_SCALE;}
|
||||||
|
<DYNARE_STATEMENT>mh_tune_jscale {return token::MH_TUNE_JSCALE;}
|
||||||
<DYNARE_STATEMENT>mode_file {return token::MODE_FILE;}
|
<DYNARE_STATEMENT>mode_file {return token::MODE_FILE;}
|
||||||
<DYNARE_STATEMENT>mode_compute {return token::MODE_COMPUTE;}
|
<DYNARE_STATEMENT>mode_compute {return token::MODE_COMPUTE;}
|
||||||
<DYNARE_STATEMENT>mode_check {return token::MODE_CHECK;}
|
<DYNARE_STATEMENT>mode_check {return token::MODE_CHECK;}
|
||||||
|
@ -322,6 +324,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
<DYNARE_STATEMENT>kalman_algo {return token::KALMAN_ALGO;}
|
<DYNARE_STATEMENT>kalman_algo {return token::KALMAN_ALGO;}
|
||||||
<DYNARE_STATEMENT>fast_kalman_filter {return token::FAST_KALMAN_FILTER;}
|
<DYNARE_STATEMENT>fast_kalman_filter {return token::FAST_KALMAN_FILTER;}
|
||||||
<DYNARE_STATEMENT>kalman_tol {return token::KALMAN_TOL;}
|
<DYNARE_STATEMENT>kalman_tol {return token::KALMAN_TOL;}
|
||||||
|
<DYNARE_STATEMENT>undiff {return token::UNDIFF;}
|
||||||
<DYNARE_STATEMENT>diffuse_kalman_tol {return token::DIFFUSE_KALMAN_TOL;}
|
<DYNARE_STATEMENT>diffuse_kalman_tol {return token::DIFFUSE_KALMAN_TOL;}
|
||||||
<DYNARE_STATEMENT>forecast {return token::FORECAST;}
|
<DYNARE_STATEMENT>forecast {return token::FORECAST;}
|
||||||
<DYNARE_STATEMENT>smoother {return token::SMOOTHER;}
|
<DYNARE_STATEMENT>smoother {return token::SMOOTHER;}
|
||||||
|
@ -342,7 +345,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
<DYNARE_STATEMENT>optim {return token::OPTIM;}
|
<DYNARE_STATEMENT>optim {return token::OPTIM;}
|
||||||
<DYNARE_STATEMENT>periods {return token::PERIODS;}
|
<DYNARE_STATEMENT>periods {return token::PERIODS;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>model_name {return token::MODEL_NAME;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>model_name {return token::MODEL_NAME;}
|
||||||
<DYNARE_BLOCK>var_model_name {return token::VAR_MODEL_NAME;}
|
<DYNARE_STATEMENT>var_model_name {return token::VAR_MODEL_NAME;}
|
||||||
<DYNARE_STATEMENT>endogenous_terminal_period {return token::ENDOGENOUS_TERMINAL_PERIOD;}
|
<DYNARE_STATEMENT>endogenous_terminal_period {return token::ENDOGENOUS_TERMINAL_PERIOD;}
|
||||||
<DYNARE_STATEMENT>sub_draws {return token::SUB_DRAWS;}
|
<DYNARE_STATEMENT>sub_draws {return token::SUB_DRAWS;}
|
||||||
<DYNARE_STATEMENT>minimal_solving_periods {return token::MINIMAL_SOLVING_PERIODS;}
|
<DYNARE_STATEMENT>minimal_solving_periods {return token::MINIMAL_SOLVING_PERIODS;}
|
||||||
|
@ -626,6 +629,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
<DYNARE_STATEMENT>log_deflator {return token::LOG_DEFLATOR;}
|
<DYNARE_STATEMENT>log_deflator {return token::LOG_DEFLATOR;}
|
||||||
<DYNARE_STATEMENT>growth_factor {return token::GROWTH_FACTOR;}
|
<DYNARE_STATEMENT>growth_factor {return token::GROWTH_FACTOR;}
|
||||||
<DYNARE_STATEMENT>log_growth_factor {return token::LOG_GROWTH_FACTOR;}
|
<DYNARE_STATEMENT>log_growth_factor {return token::LOG_GROWTH_FACTOR;}
|
||||||
|
<DYNARE_STATEMENT>growth {return token::GROWTH;}
|
||||||
<DYNARE_STATEMENT>cova_compute {return token::COVA_COMPUTE;}
|
<DYNARE_STATEMENT>cova_compute {return token::COVA_COMPUTE;}
|
||||||
<DYNARE_STATEMENT>discretionary_tol {return token::DISCRETIONARY_TOL;}
|
<DYNARE_STATEMENT>discretionary_tol {return token::DISCRETIONARY_TOL;}
|
||||||
<DYNARE_STATEMENT>analytic_derivation {return token::ANALYTIC_DERIVATION;}
|
<DYNARE_STATEMENT>analytic_derivation {return token::ANALYTIC_DERIVATION;}
|
||||||
|
@ -678,7 +682,6 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inside a Dynare block */
|
/* Inside a Dynare block */
|
||||||
<DYNARE_BLOCK>growth {return token::GROWTH;}
|
|
||||||
<DYNARE_BLOCK>var {return token::VAR;}
|
<DYNARE_BLOCK>var {return token::VAR;}
|
||||||
<DYNARE_BLOCK>stderr {return token::STDERR;}
|
<DYNARE_BLOCK>stderr {return token::STDERR;}
|
||||||
<DYNARE_BLOCK>values {return token::VALUES;}
|
<DYNARE_BLOCK>values {return token::VALUES;}
|
||||||
|
@ -825,7 +828,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>expectation {return token::EXPECTATION;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>expectation {return token::EXPECTATION;}
|
||||||
<DYNARE_BLOCK>var_expectation {return token::VAR_EXPECTATION;}
|
<DYNARE_BLOCK>var_expectation {return token::VAR_EXPECTATION;}
|
||||||
<DYNARE_BLOCK>pac_expectation {return token::PAC_EXPECTATION;}
|
<DYNARE_BLOCK>pac_expectation {return token::PAC_EXPECTATION;}
|
||||||
<DYNARE_BLOCK>discount {return token::DISCOUNT;}
|
<DYNARE_STATEMENT>discount {return token::DISCOUNT;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>varobs {return token::VAROBS;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>varobs {return token::VAROBS;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>varexobs {return token::VAREXOBS;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>varexobs {return token::VAREXOBS;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>full {return token::FULL;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>full {return token::FULL;}
|
||||||
|
|
696
src/ExprNode.cc
696
src/ExprNode.cc
File diff suppressed because it is too large
Load Diff
125
src/ExprNode.hh
125
src/ExprNode.hh
|
@ -61,6 +61,7 @@ typedef map<int, double> eval_context_t;
|
||||||
typedef map<pair<int, vector<expr_t> >, int> deriv_node_temp_terms_t;
|
typedef map<pair<int, vector<expr_t> >, int> deriv_node_temp_terms_t;
|
||||||
|
|
||||||
//! Type for the substitution map used in the process of substitutitng diff expressions
|
//! Type for the substitution map used in the process of substitutitng diff expressions
|
||||||
|
//! diff_table[static_expr_t][lag] -> [dynamic_expr_t]
|
||||||
typedef map<expr_t, map<int, expr_t> > diff_table_t;
|
typedef map<expr_t, map<int, expr_t> > diff_table_t;
|
||||||
|
|
||||||
//! Possible types of output when writing ExprNode(s)
|
//! Possible types of output when writing ExprNode(s)
|
||||||
|
@ -271,6 +272,15 @@ class ExprNode
|
||||||
//! Used in the collection of Model Local Variables for writing as Temporary Terms in Static and Dynamic files
|
//! Used in the collection of Model Local Variables for writing as Temporary Terms in Static and Dynamic files
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const = 0;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const = 0;
|
||||||
|
|
||||||
|
//! Find lowest lag for VAR
|
||||||
|
virtual int VarMinLag() const = 0;
|
||||||
|
|
||||||
|
//! Find the maximum lag in a VAR: handles case where LHS is diff
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const = 0;
|
||||||
|
|
||||||
|
//! Finds LHS variable in a VAR equation
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const = 0;
|
||||||
|
|
||||||
//! Computes the set of all variables of a given symbol type in the expression (without information on lags)
|
//! Computes the set of all variables of a given symbol type in the expression (without information on lags)
|
||||||
/*!
|
/*!
|
||||||
Variables are stored as symb_id.
|
Variables are stored as symb_id.
|
||||||
|
@ -357,6 +367,12 @@ class ExprNode
|
||||||
/*! A negative value means that the expression contains only leaded variables */
|
/*! A negative value means that the expression contains only leaded variables */
|
||||||
virtual int maxLag() const = 0;
|
virtual int maxLag() const = 0;
|
||||||
|
|
||||||
|
//! Get Max lag of var associated with Pac model
|
||||||
|
//! Takes account of undiffed LHS variables in calculating the max lag
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const = 0;
|
||||||
|
|
||||||
|
virtual expr_t undiff() const = 0;
|
||||||
|
|
||||||
//! Returns a new expression where all the leads/lags have been shifted backwards by the same amount
|
//! Returns a new expression where all the leads/lags have been shifted backwards by the same amount
|
||||||
/*!
|
/*!
|
||||||
Only acts on endogenous, exogenous, exogenous det
|
Only acts on endogenous, exogenous, exogenous det
|
||||||
|
@ -508,13 +524,13 @@ class ExprNode
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const = 0;
|
virtual bool isVarModelReferenced(const string &model_info_name) const = 0;
|
||||||
|
|
||||||
//! Fills parameter information related to PAC equation
|
//! Fills parameter information related to PAC equation
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const = 0;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const = 0;
|
||||||
|
|
||||||
//! Adds PAC equation param info to pac_expectation
|
//! Adds PAC equation param info to pac_expectation
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg) = 0;
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg) = 0;
|
||||||
|
|
||||||
//! Fills var_model info for pac_expectation node
|
//! Fills var_model info for pac_expectation node
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg) = 0;
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) = 0;
|
||||||
|
|
||||||
//! Fills map
|
//! Fills map
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const = 0;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const = 0;
|
||||||
|
@ -550,6 +566,7 @@ public:
|
||||||
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, deriv_node_temp_terms_t &tef_terms) const;
|
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, deriv_node_temp_terms_t &tef_terms) const;
|
||||||
virtual void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const;
|
virtual void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const;
|
||||||
virtual bool containsExternalFunction() const;
|
virtual bool containsExternalFunction() const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
@ -565,6 +582,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
||||||
virtual expr_t substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
virtual expr_t substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||||
|
@ -588,9 +609,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
virtual expr_t substituteStaticAuxiliaryVariable() const;
|
virtual expr_t substituteStaticAuxiliaryVariable() const;
|
||||||
|
@ -614,6 +635,7 @@ public:
|
||||||
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, deriv_node_temp_terms_t &tef_terms) const;
|
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, deriv_node_temp_terms_t &tef_terms) const;
|
||||||
virtual void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const;
|
virtual void writeJsonOutput(ostream &output, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms, const bool isdynamic) const;
|
||||||
virtual bool containsExternalFunction() const;
|
virtual bool containsExternalFunction() const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual void computeTemporaryTerms(map<expr_t, int > &reference_count,
|
virtual void computeTemporaryTerms(map<expr_t, int > &reference_count,
|
||||||
|
@ -650,6 +672,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
||||||
virtual expr_t substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
virtual expr_t substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||||
|
@ -673,9 +699,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
//! Substitute auxiliary variables by their expression in static model
|
//! Substitute auxiliary variables by their expression in static model
|
||||||
|
@ -728,6 +754,7 @@ public:
|
||||||
int Curr_block,
|
int Curr_block,
|
||||||
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
||||||
int equation) const;
|
int equation) const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
@ -756,6 +783,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
||||||
//! Creates another UnaryOpNode with the same opcode, but with a possibly different datatree and argument
|
//! Creates another UnaryOpNode with the same opcode, but with a possibly different datatree and argument
|
||||||
|
@ -766,6 +797,7 @@ public:
|
||||||
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
|
||||||
virtual expr_t substituteAdl() const;
|
virtual expr_t substituteAdl() const;
|
||||||
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
|
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
|
||||||
|
void getDiffArgUnaryOperatorIfAny(string &op_handle) const;
|
||||||
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||||
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
|
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
|
||||||
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
|
||||||
|
@ -781,9 +813,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
//! Substitute auxiliary variables by their expression in static model
|
//! Substitute auxiliary variables by their expression in static model
|
||||||
|
@ -837,6 +869,7 @@ public:
|
||||||
int Curr_block,
|
int Curr_block,
|
||||||
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
||||||
int equation) const;
|
int equation) const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
@ -869,7 +902,8 @@ public:
|
||||||
}
|
}
|
||||||
void walkPacParametersHelper(const expr_t arg1, const expr_t arg2,
|
void walkPacParametersHelper(const expr_t arg1, const expr_t arg2,
|
||||||
pair<int, int> &lhs,
|
pair<int, int> &lhs,
|
||||||
set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
set<pair<int, pair<int, int> > > &ec_params_and_vars,
|
||||||
|
set<pair<int, pair<int, int> > > &ar_params_and_vars) const;
|
||||||
virtual expr_t toStatic(DataTree &static_datatree) const;
|
virtual expr_t toStatic(DataTree &static_datatree) const;
|
||||||
virtual void computeXrefs(EquationInfo &ei) const;
|
virtual void computeXrefs(EquationInfo &ei) const;
|
||||||
virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const;
|
virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const;
|
||||||
|
@ -880,6 +914,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
||||||
//! Creates another BinaryOpNode with the same opcode, but with a possibly different datatree and arguments
|
//! Creates another BinaryOpNode with the same opcode, but with a possibly different datatree and arguments
|
||||||
|
@ -911,9 +949,9 @@ public:
|
||||||
expr_t getNonZeroPartofEquation() const;
|
expr_t getNonZeroPartofEquation() const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > &ar_params_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
//! Substitute auxiliary variables by their expression in static model
|
//! Substitute auxiliary variables by their expression in static model
|
||||||
|
@ -965,6 +1003,7 @@ public:
|
||||||
int Curr_block,
|
int Curr_block,
|
||||||
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
||||||
int equation) const;
|
int equation) const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
@ -981,6 +1020,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
||||||
//! Creates another TrinaryOpNode with the same opcode, but with a possibly different datatree and arguments
|
//! Creates another TrinaryOpNode with the same opcode, but with a possibly different datatree and arguments
|
||||||
|
@ -1006,9 +1049,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
//! Substitute auxiliary variables by their expression in static model
|
//! Substitute auxiliary variables by their expression in static model
|
||||||
|
@ -1064,6 +1107,7 @@ public:
|
||||||
int Curr_block,
|
int Curr_block,
|
||||||
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
vector< vector<temporary_terms_t> > &v_temporary_terms,
|
||||||
int equation) const = 0;
|
int equation) const = 0;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
@ -1084,6 +1128,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
virtual expr_t substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
|
||||||
virtual expr_t substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
virtual expr_t substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
|
||||||
|
@ -1109,9 +1157,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
//! Substitute auxiliary variables by their expression in static model
|
//! Substitute auxiliary variables by their expression in static model
|
||||||
|
@ -1274,6 +1322,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual void prepareForDerivation();
|
virtual void prepareForDerivation();
|
||||||
virtual expr_t computeDerivative(int deriv_id);
|
virtual expr_t computeDerivative(int deriv_id);
|
||||||
|
@ -1296,6 +1348,7 @@ public:
|
||||||
const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
|
const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
|
||||||
deriv_node_temp_terms_t &tef_terms) const;
|
deriv_node_temp_terms_t &tef_terms) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual bool containsEndogenous(void) const;
|
virtual bool containsEndogenous(void) const;
|
||||||
|
@ -1310,9 +1363,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
virtual expr_t substituteStaticAuxiliaryVariable() const;
|
virtual expr_t substituteStaticAuxiliaryVariable() const;
|
||||||
|
@ -1322,18 +1375,19 @@ public:
|
||||||
class PacExpectationNode : public ExprNode
|
class PacExpectationNode : public ExprNode
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const string model_name, var_model_name;
|
const string model_name;
|
||||||
const int discount_symb_id, growth_symb_id;
|
string var_model_name;
|
||||||
|
int growth_symb_id;
|
||||||
bool stationary_vars_present, nonstationary_vars_present;
|
bool stationary_vars_present, nonstationary_vars_present;
|
||||||
vector<int> lhs;
|
vector<int> lhs;
|
||||||
pair<int, int> lhs_pac_var;
|
pair<int, int> lhs_pac_var;
|
||||||
int max_lag;
|
int max_lag;
|
||||||
vector<int> h0_indices, h1_indices;
|
vector<int> h0_indices, h1_indices;
|
||||||
int growth_param_index, equation_number;
|
int growth_param_index, equation_number;
|
||||||
set<pair<int, pair<int, int> > > params_and_vals;
|
set<pair<int, pair<int, int> > > ec_params_and_vars;
|
||||||
|
set<pair<int, pair<int, int> > > ar_params_and_vars;
|
||||||
public:
|
public:
|
||||||
PacExpectationNode(DataTree &datatree_arg, const string &model_name, const string &var_model_name,
|
PacExpectationNode(DataTree &datatree_arg, const string &model_name);
|
||||||
const int discount_arg, const int growth_arg);
|
|
||||||
virtual void computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference> > &reference_count,
|
virtual void computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference> > &reference_count,
|
||||||
map<NodeTreeReference, temporary_terms_t> &temp_terms_map,
|
map<NodeTreeReference, temporary_terms_t> &temp_terms_map,
|
||||||
bool is_matlab, NodeTreeReference tr) const;
|
bool is_matlab, NodeTreeReference tr) const;
|
||||||
|
@ -1353,6 +1407,10 @@ public:
|
||||||
virtual int maxExoLag() const;
|
virtual int maxExoLag() const;
|
||||||
virtual int maxLead() const;
|
virtual int maxLead() const;
|
||||||
virtual int maxLag() const;
|
virtual int maxLag() const;
|
||||||
|
virtual int VarMinLag() const;
|
||||||
|
virtual void VarMaxLag(DataTree &static_datatree, set<expr_t> &static_lhs, int &max_lag) const;
|
||||||
|
virtual int PacMaxLag(vector<int> &lhs) const;
|
||||||
|
virtual expr_t undiff() const;
|
||||||
virtual expr_t decreaseLeadsLags(int n) const;
|
virtual expr_t decreaseLeadsLags(int n) const;
|
||||||
virtual void prepareForDerivation();
|
virtual void prepareForDerivation();
|
||||||
virtual expr_t computeDerivative(int deriv_id);
|
virtual expr_t computeDerivative(int deriv_id);
|
||||||
|
@ -1375,6 +1433,7 @@ public:
|
||||||
const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
|
const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
|
||||||
deriv_node_temp_terms_t &tef_terms) const;
|
deriv_node_temp_terms_t &tef_terms) const;
|
||||||
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
|
||||||
|
virtual void collectVARLHSVariable(set<expr_t> &result) const;
|
||||||
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
virtual void collectDynamicVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||||
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
virtual void collectModelLocalVariables(map<int, expr_t> &result) const;
|
||||||
virtual bool containsEndogenous(void) const;
|
virtual bool containsEndogenous(void) const;
|
||||||
|
@ -1389,9 +1448,9 @@ public:
|
||||||
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const;
|
||||||
virtual bool isInStaticForm() const;
|
virtual bool isInStaticForm() const;
|
||||||
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
virtual void setVarExpectationIndex(map<string, pair<SymbolList, int> > &var_model_info);
|
||||||
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > ¶ms_and_vals) const;
|
virtual void walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<pair<int, pair<int, int> > > &ec_params_and_vars, set<pair<int, pair<int, int> > > ¶ms_and_vars) const;
|
||||||
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > ¶ms_and_vals_arg);
|
virtual void addParamInfoToPac(pair<int, int> &lhs_arg, set<pair<int, pair<int, int> > > &ec_params_and_vars_arg, set<pair<int, pair<int, int> > > ¶ms_and_vars_arg);
|
||||||
virtual void fillPacExpectationVarInfo(string &var_model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int equation_number_arg);
|
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg);
|
||||||
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
virtual bool isVarModelReferenced(const string &model_info_name) const;
|
||||||
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
virtual void getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const;
|
||||||
virtual expr_t substituteStaticAuxiliaryVariable() const;
|
virtual expr_t substituteStaticAuxiliaryVariable() const;
|
||||||
|
|
|
@ -324,7 +324,11 @@ ModFile::checkPass(bool nostrict, bool stochastic)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if some exogenous is not used in the model block, Issue #841
|
// Check if some exogenous is not used in the model block, Issue #841
|
||||||
set<int> unusedExo = dynamic_model.findUnusedExogenous();
|
set<int> unusedExo0 = dynamic_model.findUnusedExogenous();
|
||||||
|
set<int> unusedExo;
|
||||||
|
set_difference(unusedExo0.begin(), unusedExo0.end(),
|
||||||
|
mod_file_struct.pac_params.begin(), mod_file_struct.pac_params.end(),
|
||||||
|
inserter(unusedExo, unusedExo.begin()));
|
||||||
if (unusedExo.size() > 0)
|
if (unusedExo.size() > 0)
|
||||||
{
|
{
|
||||||
ostringstream unused_exos;
|
ostringstream unused_exos;
|
||||||
|
@ -363,35 +367,69 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create auxiliary variable and equations for Diff operator
|
// Create auxiliary variable and equations for Diff operator
|
||||||
dynamic_model.substituteDiff(diff_static_model);
|
ExprNode::subst_table_t diff_subst_table;
|
||||||
|
dynamic_model.substituteDiff(diff_static_model, diff_subst_table);
|
||||||
|
|
||||||
// Var Model
|
// Var Model
|
||||||
map<string, pair<SymbolList, int> > var_model_info_var_expectation;
|
map<string, pair<SymbolList, int> > var_model_info_var_expectation;
|
||||||
|
map<string, vector<string> > var_model_eq_tags;
|
||||||
|
map<string, pair<pair<pair<vector<int>, vector<expr_t> >,
|
||||||
|
pair<vector<bool>, vector<int> > >,
|
||||||
|
pair<pair<int, vector<bool> >, vector<int> > > >
|
||||||
|
var_model_info_pac_expectation;
|
||||||
for (vector<Statement *>::const_iterator it = statements.begin();
|
for (vector<Statement *>::const_iterator it = statements.begin();
|
||||||
it != statements.end(); it++)
|
it != statements.end(); it++)
|
||||||
{
|
{
|
||||||
VarModelStatement *vms = dynamic_cast<VarModelStatement *>(*it);
|
VarModelStatement *vms = dynamic_cast<VarModelStatement *>(*it);
|
||||||
if (vms != NULL)
|
if (vms != NULL)
|
||||||
{
|
{
|
||||||
vms->getVarModelInfoForVarExpectation(var_model_info_var_expectation);
|
string var_model_name;
|
||||||
|
vms->getVarModelInfo(var_model_name, var_model_info_var_expectation, var_model_eq_tags);
|
||||||
vector<string> var_model_eqtags;
|
vector<expr_t> lhs_expr_t;
|
||||||
vms->getVarModelEqTags(var_model_eqtags);
|
vector<int> lhs, eqnumber, orig_diff_var;
|
||||||
if (!var_model_eqtags.empty())
|
|
||||||
{
|
|
||||||
int max_lag = 0;
|
|
||||||
vector<int> eqnumber, lhs, orig_diff_var;
|
|
||||||
vector<set<pair<int, int> > > rhs;
|
vector<set<pair<int, int> > > rhs;
|
||||||
vector<bool> nonstationary, diff;
|
vector<bool> nonstationary, diff;
|
||||||
dynamic_model.getVarModelVariablesFromEqTags(var_model_eqtags,
|
vector<string> eqtags = var_model_eq_tags[var_model_name];
|
||||||
eqnumber, lhs, rhs, nonstationary);
|
dynamic_model.getVarModelVariablesFromEqTags(eqtags,
|
||||||
original_model.getVarMaxLagAndLhsDiffAndInfo(eqnumber, diff, orig_diff_var, max_lag);
|
eqnumber, lhs, lhs_expr_t, rhs, nonstationary);
|
||||||
|
original_model.checkVarMinLag(eqnumber);
|
||||||
|
int max_lag = original_model.getVarMaxLag(diff_static_model, eqnumber);
|
||||||
|
original_model.getVarLhsDiffAndInfo(eqnumber, diff, orig_diff_var);
|
||||||
vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary,
|
vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary,
|
||||||
diff, orig_diff_var, max_lag);
|
diff, orig_diff_var, max_lag);
|
||||||
string var_model_name;
|
var_model_info_pac_expectation[var_model_name] =
|
||||||
vms->getVarModelName(var_model_name);
|
make_pair(make_pair(make_pair(lhs, lhs_expr_t),
|
||||||
|
make_pair(diff, orig_diff_var)),
|
||||||
|
make_pair(make_pair(max_lag, nonstationary), eqnumber));
|
||||||
|
}
|
||||||
|
PacModelStatement *pms = dynamic_cast<PacModelStatement *>(*it);
|
||||||
|
if (pms != NULL)
|
||||||
|
{
|
||||||
|
pair<string, pair<string, pair<string, pair<int, map<string, int> > > > >
|
||||||
|
pac_model_info_pac_expectation;
|
||||||
|
pms->getPacModelInfoForPacExpectation(pac_model_info_pac_expectation);
|
||||||
|
string pac_model_name = pac_model_info_pac_expectation.first;
|
||||||
|
string var_model_name = pac_model_info_pac_expectation.second.first;
|
||||||
|
vector<string> eqtags = var_model_eq_tags[var_model_name];
|
||||||
|
if (!eqtags.empty())
|
||||||
|
{
|
||||||
|
vector<int> lhs = var_model_info_pac_expectation[var_model_name].first.first.first;
|
||||||
|
map<string, int> undiff = pac_model_info_pac_expectation.second.second.second.second;
|
||||||
|
int max_lag = var_model_info_pac_expectation[var_model_name].second.first.first;
|
||||||
|
vector<bool> nonstationary = var_model_info_pac_expectation[var_model_name].second.first.second;
|
||||||
|
if (!undiff.empty())
|
||||||
|
{
|
||||||
|
vector<expr_t> lhs_expr_t = var_model_info_pac_expectation[var_model_name].first.first.second;
|
||||||
|
vector<bool> diff = var_model_info_pac_expectation[var_model_name].first.second.first;
|
||||||
|
vector<int> orig_diff_var = var_model_info_pac_expectation[var_model_name].first.second.second;
|
||||||
|
vector<int> eqnumber = var_model_info_pac_expectation[var_model_name].second.second;
|
||||||
|
dynamic_model.getUndiffLHSForPac(lhs, lhs_expr_t, diff, orig_diff_var, eqnumber, undiff, diff_subst_table);
|
||||||
|
max_lag = original_model.getUndiffMaxLag(diff_static_model, lhs_expr_t, eqnumber);
|
||||||
|
}
|
||||||
|
pms->fillUndiffedLHS(lhs);
|
||||||
dynamic_model.walkPacParameters();
|
dynamic_model.walkPacParameters();
|
||||||
dynamic_model.fillPacExpectationVarInfo(var_model_name, lhs, max_lag, nonstationary);
|
int growth_symb_id = pac_model_info_pac_expectation.second.second.second.first;
|
||||||
|
dynamic_model.fillPacExpectationVarInfo(pac_model_name, lhs, max_lag, nonstationary, growth_symb_id);
|
||||||
dynamic_model.substitutePacExpectation();
|
dynamic_model.substitutePacExpectation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,6 +519,28 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
||||||
|
|
||||||
dynamic_model.combineDiffAuxEquations();
|
dynamic_model.combineDiffAuxEquations();
|
||||||
|
|
||||||
|
for (vector<Statement *>::const_iterator it = statements.begin();
|
||||||
|
it != statements.end(); it++)
|
||||||
|
{
|
||||||
|
VarModelStatement *vms = dynamic_cast<VarModelStatement *>(*it);
|
||||||
|
if (vms != NULL)
|
||||||
|
{
|
||||||
|
string var_model_name;
|
||||||
|
vms->getVarModelInfo(var_model_name, var_model_info_var_expectation, var_model_eq_tags);
|
||||||
|
vector<expr_t> lhs_expr_t;
|
||||||
|
vector<int> lhs, eqnumber, orig_diff_var;
|
||||||
|
vector<set<pair<int, int> > > rhs;
|
||||||
|
vector<bool> nonstationary, diff;
|
||||||
|
vector<string> eqtags = var_model_eq_tags[var_model_name];
|
||||||
|
dynamic_model.getVarModelVariablesFromEqTags(eqtags,
|
||||||
|
eqnumber, lhs, lhs_expr_t, rhs, nonstationary);
|
||||||
|
int max_lag = original_model.getVarMaxLag(diff_static_model, eqnumber);
|
||||||
|
original_model.getVarLhsDiffAndInfo(eqnumber, diff, orig_diff_var);
|
||||||
|
vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary,
|
||||||
|
diff, orig_diff_var, max_lag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (differentiate_forward_vars)
|
if (differentiate_forward_vars)
|
||||||
dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset);
|
dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset);
|
||||||
|
|
||||||
|
|
|
@ -2813,73 +2813,51 @@ ParsingDriver::add_var_expectation(string *arg1, string *arg2, string *arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
ParsingDriver::add_pac_expectation()
|
ParsingDriver::add_pac_expectation(string *var_model_name)
|
||||||
{
|
{
|
||||||
if (pac_expectation_model_name.empty())
|
expr_t pac_exp_node = data_tree->AddPacExpectation(*var_model_name);
|
||||||
error("pac_expectation: you must pass the model_name option");
|
delete var_model_name;
|
||||||
|
|
||||||
if (pac_expectation_var_model_name.empty())
|
|
||||||
error("pac_expectation: you must pass the var_model_name option");
|
|
||||||
|
|
||||||
if (pac_expectation_discount.empty())
|
|
||||||
error("pac_expectation: you must pass the discount option");
|
|
||||||
|
|
||||||
int pac_expectation_discount_id =
|
|
||||||
mod_file->symbol_table.getID(pac_expectation_discount);
|
|
||||||
|
|
||||||
int pac_expectation_growth_id = -1;
|
|
||||||
if (!pac_expectation_growth.empty())
|
|
||||||
pac_expectation_growth_id = mod_file->symbol_table.getID(pac_expectation_growth);
|
|
||||||
|
|
||||||
expr_t pac_exp_node = data_tree->AddPacExpectation(pac_expectation_model_name,
|
|
||||||
pac_expectation_var_model_name,
|
|
||||||
pac_expectation_discount_id,
|
|
||||||
pac_expectation_growth_id);
|
|
||||||
|
|
||||||
pac_expectation_model_name = pac_expectation_discount = pac_expectation_growth = "";
|
|
||||||
|
|
||||||
return pac_exp_node;
|
return pac_exp_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::add_pac_expectation_model_name(string *arg)
|
ParsingDriver::pac_model()
|
||||||
{
|
{
|
||||||
if (!pac_expectation_model_name.empty())
|
OptionsList::string_options_t::const_iterator it = options_list.string_options.find("pac.model_name");
|
||||||
error("pac_expectation: you can only pass the model_name option once");
|
if (it == options_list.string_options.end())
|
||||||
pac_expectation_model_name = *arg;
|
error("You must pass the model_name option to the pac_model statement.");
|
||||||
delete arg;
|
const string *name = new string(it->second);
|
||||||
|
|
||||||
|
it = options_list.string_options.find("pac.var_model_name");
|
||||||
|
if (it == options_list.string_options.end())
|
||||||
|
error("You must pass the var_model_name option to the pac_model statement.");
|
||||||
|
const string *var_name = new string(it->second);
|
||||||
|
|
||||||
|
it = options_list.string_options.find("pac.discount");
|
||||||
|
if (it == options_list.string_options.end())
|
||||||
|
error("You must pass the discount option to the pac_model statement.");
|
||||||
|
const string *discount = new string(it->second);
|
||||||
|
|
||||||
|
string *growth;
|
||||||
|
it = options_list.string_options.find("pac.growth");
|
||||||
|
if (it == options_list.string_options.end())
|
||||||
|
growth = new string("");
|
||||||
|
else
|
||||||
|
growth = new string(it->second);
|
||||||
|
|
||||||
|
mod_file->addStatement(new PacModelStatement(*name, *var_name, *discount, *growth, pac_undiff, mod_file->symbol_table));
|
||||||
|
|
||||||
|
symbol_list.clear();
|
||||||
|
options_list.clear();
|
||||||
|
pac_undiff.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::add_pac_expectation_var_model_name(string *arg)
|
ParsingDriver::pac_model_undiff(string *eqtag, string *order)
|
||||||
{
|
{
|
||||||
if (!pac_expectation_var_model_name.empty())
|
pac_undiff[*eqtag] = atoi(order->c_str());
|
||||||
error("pac_expectation: you can only pass the var_model_name option once");
|
delete eqtag;
|
||||||
pac_expectation_var_model_name = *arg;
|
delete order;
|
||||||
delete arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::add_pac_expectation_discount(string *arg)
|
|
||||||
{
|
|
||||||
if (!pac_expectation_discount.empty())
|
|
||||||
error("pac_expectation: you can only pass the discount option once");
|
|
||||||
check_symbol_is_parameter(arg);
|
|
||||||
pac_expectation_discount = *arg;
|
|
||||||
delete arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::add_pac_expectation_growth(string *arg)
|
|
||||||
{
|
|
||||||
if (!pac_expectation_growth.empty())
|
|
||||||
error("pac_expectation: you can only pass the growth option once");
|
|
||||||
check_symbol_existence(*arg);
|
|
||||||
SymbolType type = mod_file->symbol_table.getType(mod_file->symbol_table.getID(*arg));
|
|
||||||
if (type != eParameter && type != eEndogenous && type != eExogenous)
|
|
||||||
error("pac_expectation growth argument must either be a parameter or an endogenous or exogenous variable.");
|
|
||||||
pac_expectation_growth = *arg;
|
|
||||||
delete arg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
|
|
|
@ -234,6 +234,8 @@ private:
|
||||||
SymbolList graph_formats;
|
SymbolList graph_formats;
|
||||||
//! Temporary storage for equation tags
|
//! Temporary storage for equation tags
|
||||||
vector<pair<string, string> > eq_tags;
|
vector<pair<string, string> > eq_tags;
|
||||||
|
//! Temporary storage for pac statement undiff option
|
||||||
|
map<string, int> pac_undiff;
|
||||||
|
|
||||||
//! Map Var name to variables
|
//! Map Var name to variables
|
||||||
map<string, vector<string> > var_map;
|
map<string, vector<string> > var_map;
|
||||||
|
@ -251,9 +253,6 @@ private:
|
||||||
//! Used by VAR restrictions
|
//! Used by VAR restrictions
|
||||||
void clear_VAR_storage();
|
void clear_VAR_storage();
|
||||||
|
|
||||||
//! Used by pac_expectation
|
|
||||||
string pac_expectation_model_name, pac_expectation_var_model_name, pac_expectation_discount, pac_expectation_growth;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg) { };
|
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg) { };
|
||||||
|
|
||||||
|
@ -693,12 +692,11 @@ public:
|
||||||
//! Writes token "VAR_EXPECTATION(arg1, arg2, arg3)" to model tree
|
//! Writes token "VAR_EXPECTATION(arg1, arg2, arg3)" to model tree
|
||||||
expr_t add_var_expectation(string *arg1, string *arg2, string *arg3);
|
expr_t add_var_expectation(string *arg1, string *arg2, string *arg3);
|
||||||
//! Writes token "PAC_EXPECTATION(model_name, discount, growth)" to model tree
|
//! Writes token "PAC_EXPECTATION(model_name, discount, growth)" to model tree
|
||||||
expr_t add_pac_expectation();
|
expr_t add_pac_expectation(string *var_model_name);
|
||||||
//! Adds arguments for pac_expectation
|
//! Creates pac_model statement
|
||||||
void add_pac_expectation_model_name(string *arg);
|
void pac_model();
|
||||||
void add_pac_expectation_var_model_name(string *arg);
|
//! Add undiff option for pac_model statement
|
||||||
void add_pac_expectation_discount(string *arg);
|
void pac_model_undiff(string *eqtag, string *order);
|
||||||
void add_pac_expectation_growth(string *arg);
|
|
||||||
//! Writes token "diff(arg1)" to model tree
|
//! Writes token "diff(arg1)" to model tree
|
||||||
expr_t add_diff(expr_t arg1);
|
expr_t add_diff(expr_t arg1);
|
||||||
//! Writes token "adl(arg1, lag)" to model tree
|
//! Writes token "adl(arg1, lag)" to model tree
|
||||||
|
|
|
@ -125,6 +125,8 @@ public:
|
||||||
bool write_latex_steady_state_model_present;
|
bool write_latex_steady_state_model_present;
|
||||||
//! Histval values that do not have the appropriate lag
|
//! Histval values that do not have the appropriate lag
|
||||||
map<int, int> hist_vals_wrong_lag;
|
map<int, int> hist_vals_wrong_lag;
|
||||||
|
//! Pac growth and discount
|
||||||
|
set<int> pac_params;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Statement
|
class Statement
|
||||||
|
|
|
@ -25,6 +25,20 @@
|
||||||
|
|
||||||
#include "SymbolTable.hh"
|
#include "SymbolTable.hh"
|
||||||
|
|
||||||
|
AuxVarInfo::AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id_arg, int orig_lead_lag_arg,
|
||||||
|
int equation_number_for_multiplier_arg, int information_set_arg,
|
||||||
|
expr_t expr_node_arg, string &unary_op_handle_arg) :
|
||||||
|
symb_id(symb_id_arg),
|
||||||
|
type(type_arg),
|
||||||
|
orig_symb_id(orig_symb_id_arg),
|
||||||
|
orig_lead_lag(orig_lead_lag_arg),
|
||||||
|
equation_number_for_multiplier(equation_number_for_multiplier_arg),
|
||||||
|
information_set(information_set_arg),
|
||||||
|
expr_node(expr_node_arg),
|
||||||
|
unary_op_handle(unary_op_handle_arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
AuxVarInfo::AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id_arg, int orig_lead_lag_arg,
|
AuxVarInfo::AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id_arg, int orig_lead_lag_arg,
|
||||||
int equation_number_for_multiplier_arg, int information_set_arg,
|
int equation_number_for_multiplier_arg, int information_set_arg,
|
||||||
expr_t expr_node_arg) :
|
expr_t expr_node_arg) :
|
||||||
|
@ -34,7 +48,8 @@ AuxVarInfo::AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id_arg
|
||||||
orig_lead_lag(orig_lead_lag_arg),
|
orig_lead_lag(orig_lead_lag_arg),
|
||||||
equation_number_for_multiplier(equation_number_for_multiplier_arg),
|
equation_number_for_multiplier(equation_number_for_multiplier_arg),
|
||||||
information_set(information_set_arg),
|
information_set(information_set_arg),
|
||||||
expr_node(expr_node_arg)
|
expr_node(expr_node_arg),
|
||||||
|
unary_op_handle("")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,9 +390,16 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
|
||||||
output << ")';" << endl;
|
output << ")';" << endl;
|
||||||
break;
|
break;
|
||||||
case avDiff:
|
case avDiff:
|
||||||
|
case avDiffLag:
|
||||||
if (aux_vars[i].get_orig_symb_id() >= 0)
|
if (aux_vars[i].get_orig_symb_id() >= 0)
|
||||||
output << "M_.aux_vars(" << i+1 << ").orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ";" << endl
|
output << "M_.aux_vars(" << i+1 << ").orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ";" << endl
|
||||||
<< "M_.aux_vars(" << i+1 << ").orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
<< "M_.aux_vars(" << i+1 << ").orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||||
|
|
||||||
|
output << "M_.aux_vars(" << i+1 << ").unary_op_handle = ";
|
||||||
|
if (!aux_vars[i].get_unary_op_handle().empty())
|
||||||
|
output << aux_vars[i].get_unary_op_handle() << ";" << endl;
|
||||||
|
else
|
||||||
|
output << "'';" << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,6 +510,7 @@ SymbolTable::writeCOutput(ostream &output) const throw (NotYetFrozenException)
|
||||||
<< "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
<< "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||||
break;
|
break;
|
||||||
case avDiff:
|
case avDiff:
|
||||||
|
case avDiffLag:
|
||||||
if (aux_vars[i].get_orig_symb_id() >= 0)
|
if (aux_vars[i].get_orig_symb_id() >= 0)
|
||||||
output << "av[" << i << "].orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
|
output << "av[" << i << "].orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
|
||||||
<< "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
<< "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||||
|
@ -586,6 +609,7 @@ SymbolTable::writeCCOutput(ostream &output) const throw (NotYetFrozenException)
|
||||||
<< "av" << i << ".orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
<< "av" << i << ".orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||||
break;
|
break;
|
||||||
case avDiff:
|
case avDiff:
|
||||||
|
case avDiffLag:
|
||||||
if (aux_vars[i].get_orig_symb_id() >= 0)
|
if (aux_vars[i].get_orig_symb_id() >= 0)
|
||||||
output << "av" << i << ".orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
|
output << "av" << i << ".orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
|
||||||
<< "av" << i << ".orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
<< "av" << i << ".orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||||
|
@ -706,6 +730,29 @@ SymbolTable::addExpectationAuxiliaryVar(int information_set, int index, expr_t e
|
||||||
return symb_id;
|
return symb_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SymbolTable::addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException)
|
||||||
|
{
|
||||||
|
ostringstream varname;
|
||||||
|
int symb_id;
|
||||||
|
|
||||||
|
varname << "AUX_DIFF_LAG_" << index;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
symb_id = addSymbol(varname.str(), eEndogenous);
|
||||||
|
}
|
||||||
|
catch (AlreadyDeclaredException &e)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: you should rename your variable called " << varname.str() << ", this name is internally used by Dynare" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
aux_vars.push_back(AuxVarInfo(symb_id, avDiffLag, orig_symb_id, orig_lag, 0, 0, expr_arg));
|
||||||
|
|
||||||
|
return symb_id;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException)
|
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException)
|
||||||
{
|
{
|
||||||
|
@ -729,6 +776,29 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, i
|
||||||
return symb_id;
|
return symb_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag, string &unary_op_handle) throw (FrozenException)
|
||||||
|
{
|
||||||
|
ostringstream varname;
|
||||||
|
int symb_id;
|
||||||
|
|
||||||
|
varname << "AUX_DIFF_" << index;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
symb_id = addSymbol(varname.str(), eEndogenous);
|
||||||
|
}
|
||||||
|
catch (AlreadyDeclaredException &e)
|
||||||
|
{
|
||||||
|
cerr << "ERROR: you should rename your variable called " << varname.str() << ", this name is internally used by Dynare" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
aux_vars.push_back(AuxVarInfo(symb_id, avDiff, orig_symb_id, orig_lag, 0, 0, expr_arg, unary_op_handle));
|
||||||
|
|
||||||
|
return symb_id;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg) throw (FrozenException)
|
SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg) throw (FrozenException)
|
||||||
{
|
{
|
||||||
|
@ -1066,9 +1136,10 @@ SymbolTable::writeJuliaOutput(ostream &output) const throw (NotYetFrozenExceptio
|
||||||
<< aux_vars[i].get_orig_lead_lag() << ", typemin(Int), string()";
|
<< aux_vars[i].get_orig_lead_lag() << ", typemin(Int), string()";
|
||||||
break;
|
break;
|
||||||
case avDiff:
|
case avDiff:
|
||||||
|
case avDiffLag:
|
||||||
if (aux_vars[i].get_orig_symb_id() >= 0)
|
if (aux_vars[i].get_orig_symb_id() >= 0)
|
||||||
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", "
|
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", "
|
||||||
<< aux_vars[i].get_orig_lead_lag() << ", typemin(Int), string()";
|
<< aux_vars[i].get_orig_lead_lag() << ", typemin(Int), string(), " << aux_vars[i].get_unary_op_handle();
|
||||||
break;
|
break;
|
||||||
case avMultiplier:
|
case avMultiplier:
|
||||||
output << "typemin(Int), typemin(Int), " << aux_vars[i].get_equation_number_for_multiplier() + 1
|
output << "typemin(Int), typemin(Int), " << aux_vars[i].get_equation_number_for_multiplier() + 1
|
||||||
|
|
|
@ -44,7 +44,8 @@ enum aux_var_t
|
||||||
avDiffForward = 5, //!< Substitute for the differentiate of a forward variable
|
avDiffForward = 5, //!< Substitute for the differentiate of a forward variable
|
||||||
avMultiplier = 6, //!< Multipliers for FOC of Ramsey Problem
|
avMultiplier = 6, //!< Multipliers for FOC of Ramsey Problem
|
||||||
avVarModel = 7, //!< Variable for var_model with order > abs(min_lag()) present in model
|
avVarModel = 7, //!< Variable for var_model with order > abs(min_lag()) present in model
|
||||||
avDiff = 8 //!< Variable for Diff operator
|
avDiff = 8, //!< Variable for Diff operator
|
||||||
|
avDiffLag = 9 //!< Variable for timing between Diff operators
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Information on some auxiliary variables
|
//! Information on some auxiliary variables
|
||||||
|
@ -58,8 +59,10 @@ private:
|
||||||
int equation_number_for_multiplier; //!< Stores the original constraint equation number associated with this aux var. Only used for avMultiplier.
|
int equation_number_for_multiplier; //!< Stores the original constraint equation number associated with this aux var. Only used for avMultiplier.
|
||||||
int information_set; //! Argument of expectation operator. Only used for avExpectation.
|
int information_set; //! Argument of expectation operator. Only used for avExpectation.
|
||||||
expr_t expr_node; //! Auxiliary variable definition
|
expr_t expr_node; //! Auxiliary variable definition
|
||||||
|
string unary_op_handle; //!Unary op potentially opplied to aux vars of type avDiff
|
||||||
public:
|
public:
|
||||||
AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id, int orig_lead_lag, int equation_number_for_multiplier_arg, int information_set_arg, expr_t expr_node_arg);
|
AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id, int orig_lead_lag, int equation_number_for_multiplier_arg, int information_set_arg, expr_t expr_node_arg);
|
||||||
|
AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id, int orig_lead_lag, int equation_number_for_multiplier_arg, int information_set_arg, expr_t expr_node_arg, string &unary_op_handle);
|
||||||
int
|
int
|
||||||
get_symb_id() const
|
get_symb_id() const
|
||||||
{
|
{
|
||||||
|
@ -95,6 +98,11 @@ public:
|
||||||
{
|
{
|
||||||
return expr_node;
|
return expr_node;
|
||||||
};
|
};
|
||||||
|
string
|
||||||
|
get_unary_op_handle() const
|
||||||
|
{
|
||||||
|
return unary_op_handle;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Stores the symbol table
|
//! Stores the symbol table
|
||||||
|
@ -289,6 +297,9 @@ public:
|
||||||
//! Adds an auxiliary variable when the diff operator is encountered
|
//! Adds an auxiliary variable when the diff operator is encountered
|
||||||
int addDiffAuxiliaryVar(int index, expr_t expr_arg) throw (FrozenException);
|
int addDiffAuxiliaryVar(int index, expr_t expr_arg) throw (FrozenException);
|
||||||
int addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException);
|
int addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException);
|
||||||
|
int addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag, string &unary_op_handle) throw (FrozenException);
|
||||||
|
//! Takes care of timing between diff statements
|
||||||
|
int addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException);
|
||||||
//! Returns the number of auxiliary variables
|
//! Returns the number of auxiliary variables
|
||||||
int
|
int
|
||||||
AuxVarsSize() const
|
AuxVarsSize() const
|
||||||
|
|
Loading…
Reference in New Issue