Commit f5e5dea1 authored by Houtan Bastani's avatar Houtan Bastani

support hard-coded parameters and parameter expressions in AR matrix

parent acc197f5
...@@ -3708,18 +3708,18 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const ...@@ -3708,18 +3708,18 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const
var_model_table.setOrigDiffVar(orig_diff_var); var_model_table.setOrigDiffVar(orig_diff_var);
// Fill AR Matrix // Fill AR Matrix
map<string, map<tuple<int, int, int>, int>> ARr; map<string, map<tuple<int, int, int>, expr_t>> ARr;
fillAutoregressiveMatrix(ARr); fillAutoregressiveMatrix(ARr);
var_model_table.setAR(ARr); var_model_table.setAR(ARr);
} }
void void
DynamicModel::fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, int>> &ARr) const DynamicModel::fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr) const
{ {
for (const auto & it : var_model_table.getEqNums()) for (const auto & it : var_model_table.getEqNums())
{ {
int i = 0; int i = 0;
map<tuple<int, int, int>, int> AR; map<tuple<int, int, int>, expr_t> AR;
for (auto eqn : it.second) for (auto eqn : it.second)
equations[eqn]->get_arg2()->fillAutoregressiveRow(i++, var_model_table.getLhs(it.first), AR); equations[eqn]->get_arg2()->fillAutoregressiveRow(i++, var_model_table.getLhs(it.first), AR);
ARr[it.first] = AR; ARr[it.first] = AR;
......
...@@ -305,7 +305,7 @@ public: ...@@ -305,7 +305,7 @@ public:
void setNonZeroHessianEquations(map<int, string> &eqs); void setNonZeroHessianEquations(map<int, string> &eqs);
//! Fill Autoregressive Matrix for var_model //! Fill Autoregressive Matrix for var_model
void fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, int>> &ARr) const; void fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr) const;
//! Fill the Trend Component Model Table //! Fill the Trend Component Model Table
void fillTrendComponentModelTable() const; void fillTrendComponentModelTable() const;
......
...@@ -696,7 +696,7 @@ NumConstNode::substituteStaticAuxiliaryVariable() const ...@@ -696,7 +696,7 @@ NumConstNode::substituteStaticAuxiliaryVariable() const
} }
void void
NumConstNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const NumConstNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
} }
...@@ -1934,7 +1934,7 @@ VariableNode::getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const ...@@ -1934,7 +1934,7 @@ VariableNode::getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const
} }
void void
VariableNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const VariableNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
} }
...@@ -3572,7 +3572,7 @@ UnaryOpNode::substituteStaticAuxiliaryVariable() const ...@@ -3572,7 +3572,7 @@ UnaryOpNode::substituteStaticAuxiliaryVariable() const
} }
void void
UnaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const UnaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
arg->fillAutoregressiveRow(eqn, lhs, AR); arg->fillAutoregressiveRow(eqn, lhs, AR);
} }
...@@ -5438,14 +5438,9 @@ void ...@@ -5438,14 +5438,9 @@ void
BinaryOpNode::fillAutoregressiveRowHelper(expr_t arg1, expr_t arg2, BinaryOpNode::fillAutoregressiveRowHelper(expr_t arg1, expr_t arg2,
int eqn, int eqn,
const vector<int> &lhs, const vector<int> &lhs,
map<tuple<int, int, int>, int> &AR) const map<tuple<int, int, int>, expr_t> &AR) const
{ {
set<int> params; set<pair<int, int>> endogs, tmp;
arg1->collectVariables(SymbolType::parameter, params);
if (params.size() != 1)
return;
set<pair<int, int>> endogs;
arg2->collectDynamicVariables(SymbolType::endogenous, endogs); arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
if (endogs.size() != 1) if (endogs.size() != 1)
return; return;
...@@ -5454,19 +5449,22 @@ BinaryOpNode::fillAutoregressiveRowHelper(expr_t arg1, expr_t arg2, ...@@ -5454,19 +5449,22 @@ BinaryOpNode::fillAutoregressiveRowHelper(expr_t arg1, expr_t arg2,
if (find(lhs.begin(), lhs.end(), lhs_symb_id) == lhs.end()) if (find(lhs.begin(), lhs.end(), lhs_symb_id) == lhs.end())
return; return;
int lag = endogs.begin()->second; arg1->collectDynamicVariables(SymbolType::endogenous, tmp);
int param_symb_id = *(params.begin()); arg1->collectDynamicVariables(SymbolType::exogenous, tmp);
if (tmp.size() != 0)
return;
int lag = endogs.begin()->second;
if (AR.find(make_tuple(eqn, -lag, lhs_symb_id)) != AR.end()) if (AR.find(make_tuple(eqn, -lag, lhs_symb_id)) != AR.end())
{ {
cerr << "BinaryOpNode::fillAutoregressiveRowHelper: Error filling AR matrix: lag/symb_id encountered more than once in equtaion" << endl; cerr << "BinaryOpNode::fillAutoregressiveRowHelper: Error filling AR matrix: lag/symb_id encountered more than once in equtaion" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
AR[make_tuple(eqn, -lag, lhs_symb_id)] = param_symb_id; AR[make_tuple(eqn, -lag, lhs_symb_id)] = arg1;
} }
void void
BinaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const BinaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
if (op_code == BinaryOpcode::times) if (op_code == BinaryOpcode::times)
{ {
...@@ -6429,7 +6427,7 @@ TrinaryOpNode::substituteStaticAuxiliaryVariable() const ...@@ -6429,7 +6427,7 @@ TrinaryOpNode::substituteStaticAuxiliaryVariable() const
} }
void void
TrinaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const TrinaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
arg1->fillAutoregressiveRow(eqn, lhs, AR); arg1->fillAutoregressiveRow(eqn, lhs, AR);
arg2->fillAutoregressiveRow(eqn, lhs, AR); arg2->fillAutoregressiveRow(eqn, lhs, AR);
...@@ -7043,7 +7041,7 @@ AbstractExternalFunctionNode::substituteStaticAuxiliaryVariable() const ...@@ -7043,7 +7041,7 @@ AbstractExternalFunctionNode::substituteStaticAuxiliaryVariable() const
} }
void void
AbstractExternalFunctionNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const AbstractExternalFunctionNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
cerr << "External functions not supported in VARs" << endl; cerr << "External functions not supported in VARs" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -8523,7 +8521,7 @@ VarExpectationNode::substituteStaticAuxiliaryVariable() const ...@@ -8523,7 +8521,7 @@ VarExpectationNode::substituteStaticAuxiliaryVariable() const
} }
void void
VarExpectationNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const VarExpectationNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
cerr << "Var Expectation not supported in VARs" << endl; cerr << "Var Expectation not supported in VARs" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -9010,7 +9008,7 @@ PacExpectationNode::substituteStaticAuxiliaryVariable() const ...@@ -9010,7 +9008,7 @@ PacExpectationNode::substituteStaticAuxiliaryVariable() const
} }
void void
PacExpectationNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const PacExpectationNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const
{ {
cerr << "Pac Expectation not supported in VARs" << endl; cerr << "Pac Expectation not supported in VARs" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
...@@ -569,7 +569,7 @@ class ExprNode ...@@ -569,7 +569,7 @@ class ExprNode
virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) = 0; virtual void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) = 0;
//! Fills the AR matrix structure //! Fills the AR matrix structure
virtual void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const = 0; virtual void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const = 0;
//! Returns true if PacExpectationNode encountered //! Returns true if PacExpectationNode encountered
virtual bool containsPacExpectation(const string &pac_model_name = "") const = 0; virtual bool containsPacExpectation(const string &pac_model_name = "") const = 0;
...@@ -657,7 +657,7 @@ public: ...@@ -657,7 +657,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
...@@ -757,7 +757,7 @@ public: ...@@ -757,7 +757,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
...@@ -881,7 +881,7 @@ public: ...@@ -881,7 +881,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
...@@ -1034,8 +1034,8 @@ public: ...@@ -1034,8 +1034,8 @@ public:
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &ar_params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &ar_params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRowHelper(expr_t arg1, expr_t arg2, void fillAutoregressiveRowHelper(expr_t arg1, expr_t arg2,
int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const; int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacOptimizingPart(int lhs_orig_symb_id, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars, void getPacOptimizingPart(int lhs_orig_symb_id, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars,
set<pair<int, pair<int, int>>> &params_and_vars) const override; set<pair<int, pair<int, int>>> &params_and_vars) const override;
...@@ -1143,7 +1143,7 @@ public: ...@@ -1143,7 +1143,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
...@@ -1265,7 +1265,7 @@ public: ...@@ -1265,7 +1265,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
...@@ -1474,7 +1474,7 @@ public: ...@@ -1474,7 +1474,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
...@@ -1571,7 +1571,7 @@ public: ...@@ -1571,7 +1571,7 @@ public:
bool isInStaticForm() const override; bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override; void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override; void fillPacExpectationVarInfo(string &model_name_arg, vector<int> &lhs_arg, int max_lag_arg, int pac_max_lag_arg, vector<bool> &nonstationary_arg, int growth_symb_id_arg, int equation_number_arg) override;
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, int> &AR) const override; void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
bool containsPacExpectation(const string &pac_model_name = "") const override; bool containsPacExpectation(const string &pac_model_name = "") const override;
void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>> void getPacNonOptimizingPart(set<pair<int, pair<pair<int, int>, double>>>
&params_vars_and_scaling_factor) const override; &params_vars_and_scaling_factor) const override;
......
...@@ -421,10 +421,11 @@ VarModelTable::writeOutput(const string &basename, ostream &output) const ...@@ -421,10 +421,11 @@ VarModelTable::writeOutput(const string &basename, ostream &output) const
{ {
int eqn, lag, lhs_symb_id; int eqn, lag, lhs_symb_id;
tie (eqn, lag, lhs_symb_id) = it.first; tie (eqn, lag, lhs_symb_id) = it.first;
int param_symb_id = it.second;
int colidx = (int) distance(lhs.begin(), find(lhs.begin(), lhs.end(), lhs_symb_id)); int colidx = (int) distance(lhs.begin(), find(lhs.begin(), lhs.end(), lhs_symb_id));
ar_output << " ar(" << eqn + 1 << ", " << colidx + 1 << ", " << lag ar_output << " ar(" << eqn + 1 << ", " << colidx + 1 << ", " << lag
<< ") = params(" << symbol_table.getTypeSpecificID(param_symb_id) + 1 << ");" << endl; << ") = ";
it.second->writeOutput(ar_output, ExprNodeOutputType::matlabDynamicModel);
ar_output << endl;
} }
ar_output << " return" << endl ar_output << " return" << endl
<< "end" << endl << endl; << "end" << endl << endl;
...@@ -548,7 +549,7 @@ VarModelTable::setOrigDiffVar(map<string, vector<int>> orig_diff_var_arg) ...@@ -548,7 +549,7 @@ VarModelTable::setOrigDiffVar(map<string, vector<int>> orig_diff_var_arg)
} }
void void
VarModelTable::setAR(map<string, map<tuple<int, int, int>, int>> AR_arg) VarModelTable::setAR(map<string, map<tuple<int, int, int>, expr_t>> AR_arg)
{ {
AR = move(AR_arg); AR = move(AR_arg);
} }
......
...@@ -116,7 +116,7 @@ private: ...@@ -116,7 +116,7 @@ private:
map<string, vector<set<pair<int, int>>>> rhs; map<string, vector<set<pair<int, int>>>> rhs;
map<string, vector<bool>> diff, nonstationary; map<string, vector<bool>> diff, nonstationary;
map<string, vector<expr_t>> lhs_expr_t; map<string, vector<expr_t>> lhs_expr_t;
map<string, map<tuple<int, int, int>, int>> AR; // AR: name -> (eqn, lag, lhs_symb_id) -> param_symb_id map<string, map<tuple<int, int, int>, expr_t>> AR; // AR: name -> (eqn, lag, lhs_symb_id) -> param_expr_t
public: public:
VarModelTable(SymbolTable &symbol_table_arg); VarModelTable(SymbolTable &symbol_table_arg);
...@@ -147,7 +147,7 @@ public: ...@@ -147,7 +147,7 @@ public:
void setDiff(map<string, vector<bool>> diff_arg); void setDiff(map<string, vector<bool>> diff_arg);
void setMaxLags(map<string, vector<int>> max_lags_arg); void setMaxLags(map<string, vector<int>> max_lags_arg);
void setOrigDiffVar(map<string, vector<int>> orig_diff_var_arg); void setOrigDiffVar(map<string, vector<int>> orig_diff_var_arg);
void setAR(map<string, map<tuple<int, int, int>, int>> AR_arg); void setAR(map<string, map<tuple<int, int, int>, expr_t>> AR_arg);
//! Write output of this class //! Write output of this class
void writeOutput(const string &basename, ostream &output) const; void writeOutput(const string &basename, ostream &output) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment