create A0 and A0star matrices for trend component models
parent
fe69dced1d
commit
fc6d04b015
|
@ -4016,13 +4016,14 @@ DynamicModel::fillTrendComponentModelTable() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ECr,
|
DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &A0r,
|
||||||
|
map<string, map<tuple<int, int, int>, expr_t>> &A0starr,
|
||||||
ExprNode::subst_table_t &diff_subst_table) const
|
ExprNode::subst_table_t &diff_subst_table) const
|
||||||
{
|
{
|
||||||
for (const auto & it : trend_component_model_table.getEqNums())
|
for (const auto & it : trend_component_model_table.getEqNums())
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
map<tuple<int, int, int>, expr_t> EC;
|
map<tuple<int, int, int>, expr_t> A0, A0star;
|
||||||
vector<int> target_lhs = trend_component_model_table.getTargetLhs(it.first);
|
vector<int> target_lhs = trend_component_model_table.getTargetLhs(it.first);
|
||||||
vector<int> nontarget_eqnums = trend_component_model_table.getNonTargetEqNums(it.first);
|
vector<int> nontarget_eqnums = trend_component_model_table.getNonTargetEqNums(it.first);
|
||||||
vector<int> undiff_nontarget_lhs = getUndiffLHSForPac(it.first, diff_subst_table);
|
vector<int> undiff_nontarget_lhs = getUndiffLHSForPac(it.first, diff_subst_table);
|
||||||
|
@ -4038,8 +4039,9 @@ DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, exp
|
||||||
i = 0;
|
i = 0;
|
||||||
for (auto eqn : it.second)
|
for (auto eqn : it.second)
|
||||||
if (find(nontarget_eqnums.begin(), nontarget_eqnums.end(), eqn) != nontarget_eqnums.end())
|
if (find(nontarget_eqnums.begin(), nontarget_eqnums.end(), eqn) != nontarget_eqnums.end())
|
||||||
equations[eqn]->arg2->fillErrorCorrectionRow(i++, parsed_undiff_nontarget_lhs, target_lhs, EC);
|
equations[eqn]->arg2->fillErrorCorrectionRow(i++, parsed_undiff_nontarget_lhs, target_lhs, A0, A0star);
|
||||||
ECr[it.first] = EC;
|
A0r[it.first] = A0;
|
||||||
|
A0starr[it.first] = A0star;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4113,11 +4115,11 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel(StaticModel &static_mode
|
||||||
void
|
void
|
||||||
DynamicModel::fillTrendComponentmodelTableAREC(ExprNode::subst_table_t &diff_subst_table) const
|
DynamicModel::fillTrendComponentmodelTableAREC(ExprNode::subst_table_t &diff_subst_table) const
|
||||||
{
|
{
|
||||||
map<string, map<tuple<int, int, int>, expr_t>> ARr, ECr;
|
map<string, map<tuple<int, int, int>, expr_t>> ARr, A0r, A0starr;
|
||||||
fillAutoregressiveMatrix(ARr, true);
|
fillAutoregressiveMatrix(ARr, true);
|
||||||
trend_component_model_table.setAR(ARr);
|
trend_component_model_table.setAR(ARr);
|
||||||
fillErrorComponentMatrix(ECr, diff_subst_table);
|
fillErrorComponentMatrix(A0r, A0starr, diff_subst_table);
|
||||||
trend_component_model_table.setEC(ECr);
|
trend_component_model_table.setA0(A0r, A0starr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -323,7 +323,7 @@ public:
|
||||||
void fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr, bool is_trend_component_model) const;
|
void fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr, bool is_trend_component_model) const;
|
||||||
|
|
||||||
//! Fill Error Component Matrix for trend_component_model
|
//! Fill Error Component Matrix for trend_component_model
|
||||||
void fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ECr, ExprNode::subst_table_t &diff_subst_table) const;
|
void fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &A0r, map<string, map<tuple<int, int, int>, expr_t>> &A0starr, ExprNode::subst_table_t &diff_subst_table) const;
|
||||||
|
|
||||||
//! Fill the Trend Component Model Table
|
//! Fill the Trend Component Model Table
|
||||||
void fillTrendComponentModelTable() const;
|
void fillTrendComponentModelTable() const;
|
||||||
|
|
193
src/ExprNode.cc
193
src/ExprNode.cc
|
@ -722,7 +722,7 @@ NumConstNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<i
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NumConstNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
NumConstNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2045,7 +2045,7 @@ VariableNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<i
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VariableNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
VariableNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3891,9 +3891,9 @@ UnaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<in
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UnaryOpNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
UnaryOpNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
arg->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, EC);
|
arg->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -5857,7 +5857,8 @@ BinaryOpNode::fillErrorCorrectionRowHelper(expr_t arg1, expr_t arg2,
|
||||||
int eqn,
|
int eqn,
|
||||||
const vector<int> &nontarget_lhs,
|
const vector<int> &nontarget_lhs,
|
||||||
const vector<int> &target_lhs,
|
const vector<int> &target_lhs,
|
||||||
map<tuple<int, int, int>, expr_t> &EC) const
|
map<tuple<int, int, int>, expr_t> &A0,
|
||||||
|
map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
if (op_code != BinaryOpcode::times)
|
if (op_code != BinaryOpcode::times)
|
||||||
return;
|
return;
|
||||||
|
@ -5872,64 +5873,130 @@ BinaryOpNode::fillErrorCorrectionRowHelper(expr_t arg1, expr_t arg2,
|
||||||
if (tmp.size() != 1)
|
if (tmp.size() != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto *vn = dynamic_cast<VariableNode *>(arg2);
|
||||||
auto *bopn = dynamic_cast<BinaryOpNode *>(arg2);
|
auto *bopn = dynamic_cast<BinaryOpNode *>(arg2);
|
||||||
if (bopn == nullptr || bopn->op_code != BinaryOpcode::minus)
|
if ((bopn == nullptr || bopn->op_code != BinaryOpcode::minus)
|
||||||
|
&& vn == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
|
if (bopn != nullptr)
|
||||||
if (endogs.size() != 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
arg2->collectDynamicVariables(SymbolType::exogenous, endogs);
|
|
||||||
arg2->collectDynamicVariables(SymbolType::parameter, endogs);
|
|
||||||
if (endogs.size() != 2)
|
|
||||||
{
|
{
|
||||||
cerr << "ERROR in model; expecting param*endog or param*(endog-endog)" << endl;
|
arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
|
||||||
exit(EXIT_FAILURE);
|
if (endogs.size() != 2)
|
||||||
}
|
return;
|
||||||
|
|
||||||
auto *vn1 = dynamic_cast<VariableNode *>(bopn->arg1);
|
arg2->collectDynamicVariables(SymbolType::exogenous, endogs);
|
||||||
auto *vn2 = dynamic_cast<VariableNode *>(bopn->arg2);
|
arg2->collectDynamicVariables(SymbolType::parameter, endogs);
|
||||||
if (vn1 == nullptr || vn2 == nullptr)
|
if (endogs.size() != 2)
|
||||||
{
|
{
|
||||||
cerr << "ERROR in model; expecting param*endog or param*(endog-endog)" << endl;
|
cerr << "ERROR in model; expecting param*endog or param*(endog-endog)" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int endog1 = vn1->symb_id;
|
auto *vn1 = dynamic_cast<VariableNode *>(bopn->arg1);
|
||||||
int endog2 = vn2->symb_id;
|
auto *vn2 = dynamic_cast<VariableNode *>(bopn->arg2);
|
||||||
int orig_endog2 = endog2;
|
if (vn1 == nullptr || vn2 == nullptr)
|
||||||
|
{
|
||||||
|
cerr << "ERROR in model; expecting param*endog or param*(endog-endog)" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
bool isauxvar1 = datatree.symbol_table.isAuxiliaryVariable(endog1);
|
int endog1 = vn1->symb_id;
|
||||||
endog1 = isauxvar1 ?
|
int endog2 = vn2->symb_id;
|
||||||
datatree.symbol_table.getOrigSymbIdForDiffAuxVar(endog1) : endog1;
|
int orig_endog1 = endog1;
|
||||||
|
int orig_endog2 = endog2;
|
||||||
|
|
||||||
bool isauxvar2 = datatree.symbol_table.isAuxiliaryVariable(endog2);
|
bool isauxvar1 = datatree.symbol_table.isAuxiliaryVariable(endog1);
|
||||||
endog2 = isauxvar2 ?
|
endog1 = isauxvar1 ?
|
||||||
datatree.symbol_table.getOrigSymbIdForDiffAuxVar(endog2) : endog2;
|
datatree.symbol_table.getOrigSymbIdForDiffAuxVar(endog1) : endog1;
|
||||||
|
|
||||||
int max_lag = vn2->lag;
|
bool isauxvar2 = datatree.symbol_table.isAuxiliaryVariable(endog2);
|
||||||
int colidx = -1;
|
endog2 = isauxvar2 ?
|
||||||
if (find(nontarget_lhs.begin(), nontarget_lhs.end(), endog1) != nontarget_lhs.end()
|
datatree.symbol_table.getOrigSymbIdForDiffAuxVar(endog2) : endog2;
|
||||||
&& find(target_lhs.begin(), target_lhs.end(), endog2) != target_lhs.end())
|
|
||||||
{
|
int A0_max_lag = vn1->lag;
|
||||||
colidx = (int) distance(target_lhs.begin(), find(target_lhs.begin(), target_lhs.end(), endog2));
|
int A0star_max_lag = vn2->lag;
|
||||||
int tmp_lag = vn2->lag;
|
int A0_colidx = -1;
|
||||||
if (isauxvar2)
|
int A0star_colidx = -1;
|
||||||
tmp_lag = -1 * datatree.symbol_table.getOrigLeadLagForDiffAuxVar(orig_endog2);
|
if (find(nontarget_lhs.begin(), nontarget_lhs.end(), endog1) != nontarget_lhs.end()
|
||||||
if (tmp_lag < max_lag)
|
&& find(target_lhs.begin(), target_lhs.end(), endog2) != target_lhs.end())
|
||||||
max_lag = tmp_lag;
|
{
|
||||||
|
A0_colidx = (int) distance(nontarget_lhs.begin(), find(nontarget_lhs.begin(), nontarget_lhs.end(), endog1));
|
||||||
|
int tmp_lag = vn1->lag;
|
||||||
|
if (isauxvar1)
|
||||||
|
tmp_lag = -1 * datatree.symbol_table.getOrigLeadLagForDiffAuxVar(orig_endog1);
|
||||||
|
if (tmp_lag < A0_max_lag)
|
||||||
|
A0_max_lag = tmp_lag;
|
||||||
|
|
||||||
|
A0star_colidx = (int) distance(target_lhs.begin(), find(target_lhs.begin(), target_lhs.end(), endog2));
|
||||||
|
tmp_lag = vn2->lag;
|
||||||
|
if (isauxvar2)
|
||||||
|
tmp_lag = -1 * datatree.symbol_table.getOrigLeadLagForDiffAuxVar(orig_endog2);
|
||||||
|
if (tmp_lag < A0star_max_lag)
|
||||||
|
A0star_max_lag = tmp_lag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (A0.find(make_tuple(eqn, -A0_max_lag, A0_colidx)) != A0.end())
|
||||||
|
{
|
||||||
|
cerr << "BinaryOpNode::fillErrorCorrectionRowHelper: Error filling A0 matrix: "
|
||||||
|
<< "lag/symb_id encountered more than once in equtaion" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (A0star.find(make_tuple(eqn, -A0star_max_lag, A0star_colidx)) != A0star.end())
|
||||||
|
{
|
||||||
|
cerr << "BinaryOpNode::fillErrorCorrectionRowHelper: Error filling A0star matrix: "
|
||||||
|
<< "lag/symb_id encountered more than once in equtaion" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
A0[make_tuple(eqn, -A0_max_lag, A0_colidx)] = arg1;
|
||||||
|
A0star[make_tuple(eqn, -A0star_max_lag, A0star_colidx)] = arg1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
|
||||||
|
|
||||||
if (EC.find(make_tuple(eqn, -max_lag, colidx)) != EC.end())
|
|
||||||
{
|
{
|
||||||
cerr << "BinaryOpNode::fillErrorCorrectionRowHelper: Error filling EC matrix: "
|
arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
|
||||||
<< "lag/symb_id encountered more than once in equtaion" << endl;
|
if (endogs.size() != 1)
|
||||||
exit(EXIT_FAILURE);
|
return;
|
||||||
|
|
||||||
|
arg2->collectDynamicVariables(SymbolType::exogenous, endogs);
|
||||||
|
arg2->collectDynamicVariables(SymbolType::parameter, endogs);
|
||||||
|
if (endogs.size() != 1)
|
||||||
|
{
|
||||||
|
cerr << "ERROR in model; expecting param*endog or param*(endog-endog)" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int endog1 = vn->symb_id;
|
||||||
|
int orig_endog1 = endog1;
|
||||||
|
|
||||||
|
bool isauxvar1 = datatree.symbol_table.isAuxiliaryVariable(endog1);
|
||||||
|
endog1 = isauxvar1 ?
|
||||||
|
datatree.symbol_table.getOrigSymbIdForDiffAuxVar(endog1) : endog1;
|
||||||
|
|
||||||
|
int max_lag = vn->lag;
|
||||||
|
int colidx = -1;
|
||||||
|
if (find(nontarget_lhs.begin(), nontarget_lhs.end(), endog1) != nontarget_lhs.end())
|
||||||
|
{
|
||||||
|
colidx = (int) distance(nontarget_lhs.begin(), find(nontarget_lhs.begin(), nontarget_lhs.end(), endog1));
|
||||||
|
int tmp_lag = vn->lag;
|
||||||
|
if (isauxvar1)
|
||||||
|
tmp_lag = -1 * datatree.symbol_table.getOrigLeadLagForDiffAuxVar(orig_endog1);
|
||||||
|
if (tmp_lag < max_lag)
|
||||||
|
max_lag = tmp_lag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (A0.find(make_tuple(eqn, -max_lag, colidx)) != A0.end())
|
||||||
|
{
|
||||||
|
cerr << "BinaryOpNode::fillErrorCorrectionRowHelper: Error filling A0 matrix: "
|
||||||
|
<< "lag/symb_id encountered more than once in equtaion" << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
A0[make_tuple(eqn, -max_lag, colidx)] = arg1;
|
||||||
}
|
}
|
||||||
EC[make_tuple(eqn, -max_lag, colidx)] = arg1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -5960,12 +6027,14 @@ BinaryOpNode::replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BinaryOpNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
BinaryOpNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
fillErrorCorrectionRowHelper(arg1, arg2, eqn, nontrend_lhs, trend_lhs, EC);
|
int A0size = A0.size();
|
||||||
fillErrorCorrectionRowHelper(arg2, arg1, eqn, nontrend_lhs, trend_lhs, EC);
|
fillErrorCorrectionRowHelper(arg1, arg2, eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
arg1->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, EC);
|
if (A0size == A0.size())
|
||||||
arg2->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, EC);
|
fillErrorCorrectionRowHelper(arg2, arg1, eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
|
arg1->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
|
arg2->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -6974,11 +7043,11 @@ TrinaryOpNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TrinaryOpNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
TrinaryOpNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
arg1->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, EC);
|
arg1->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
arg2->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, EC);
|
arg2->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
arg3->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, EC);
|
arg3->fillErrorCorrectionRow(eqn, nontrend_lhs, trend_lhs, A0, A0star);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -7651,7 +7720,7 @@ AbstractExternalFunctionNode::fillAutoregressiveRow(int eqn, const vector<int> &
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AbstractExternalFunctionNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
AbstractExternalFunctionNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
cerr << "External functions not supported in Trend Component Models" << endl;
|
cerr << "External functions not supported in Trend Component Models" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -9193,7 +9262,7 @@ VarExpectationNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<t
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VarExpectationNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
VarExpectationNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
cerr << "Var Expectation not supported in Trend Component Models" << endl;
|
cerr << "Var Expectation not supported in Trend Component Models" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -9719,7 +9788,7 @@ PacExpectationNode::fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<t
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PacExpectationNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const
|
PacExpectationNode::fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const
|
||||||
{
|
{
|
||||||
cerr << "Pac Expectation not supported in Trend Component Models" << endl;
|
cerr << "Pac Expectation not supported in Trend Component Models" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -618,7 +618,8 @@ class ExprNode
|
||||||
|
|
||||||
//! Fills the EC matrix structure
|
//! Fills the EC matrix structure
|
||||||
virtual void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs,
|
virtual void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs,
|
||||||
map<tuple<int, int, int>, expr_t> &EC) const = 0;
|
map<tuple<int, int, int>, expr_t> &A0,
|
||||||
|
map<tuple<int, int, int>, expr_t> &A0star) const = 0;
|
||||||
|
|
||||||
//! Finds equations where a variable is equal to a constant
|
//! Finds equations where a variable is equal to a constant
|
||||||
virtual void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const = 0;
|
virtual void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const = 0;
|
||||||
|
@ -742,7 +743,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -836,7 +837,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -958,7 +959,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -1097,8 +1098,8 @@ public:
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRowHelper(expr_t arg1, expr_t arg2,
|
void fillErrorCorrectionRowHelper(expr_t arg1, expr_t arg2,
|
||||||
int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs,
|
int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs,
|
||||||
map<tuple<int, int, int>, expr_t> &AR) const;
|
map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -1217,7 +1218,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -1348,7 +1349,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -1567,7 +1568,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
@ -1672,7 +1673,7 @@ 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) 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>>> ¶ms_and_vars_arg, const vector<tuple<int, int, int, double>> &non_optim_vars_params_and_constants) override;
|
||||||
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
void fillPacExpectationVarInfo(const 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 growth_lag, int equation_number_arg) override;
|
||||||
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
void fillAutoregressiveRow(int eqn, const vector<int> &lhs, map<tuple<int, int, int>, expr_t> &AR) const override;
|
||||||
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &EC) const override;
|
void fillErrorCorrectionRow(int eqn, const vector<int> &nontrend_lhs, const vector<int> &trend_lhs, map<tuple<int, int, int>, expr_t> &A0, map<tuple<int, int, int>, expr_t> &A0star) const override;
|
||||||
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
void findConstantEquations(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
expr_t replaceVarsInEquation(map<VariableNode *, NumConstNode *> &table) const override;
|
||||||
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
bool containsPacExpectation(const string &pac_model_name = "") const override;
|
||||||
|
|
|
@ -111,9 +111,11 @@ TrendComponentModelTable::setAR(map<string, map<tuple<int, int, int>, expr_t>> A
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TrendComponentModelTable::setEC(map<string, map<tuple<int, int, int>, expr_t>> EC_arg)
|
TrendComponentModelTable::setA0(map<string, map<tuple<int, int, int>, expr_t>> A0_arg,
|
||||||
|
map<string, map<tuple<int, int, int>, expr_t>> A0star_arg)
|
||||||
{
|
{
|
||||||
EC = move(EC_arg);
|
A0 = move(A0_arg);
|
||||||
|
A0star = move(A0star_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string, vector<string>>
|
map<string, vector<string>>
|
||||||
|
@ -249,7 +251,7 @@ TrendComponentModelTable::writeOutput(const string &basename, ostream &output) c
|
||||||
if (names.empty())
|
if (names.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string filename = "+" + basename + "/trend_component_ar_ec.m";
|
string filename = "+" + basename + "/trend_component_ar_a0.m";
|
||||||
ofstream ar_ec_output;
|
ofstream ar_ec_output;
|
||||||
ar_ec_output.open(filename, ios::out | ios::binary);
|
ar_ec_output.open(filename, ios::out | ios::binary);
|
||||||
if (!ar_ec_output.is_open())
|
if (!ar_ec_output.is_open())
|
||||||
|
@ -257,8 +259,8 @@ TrendComponentModelTable::writeOutput(const string &basename, ostream &output) c
|
||||||
cerr << "Error: Can't open file " << filename << " for writing" << endl;
|
cerr << "Error: Can't open file " << filename << " for writing" << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
ar_ec_output << "function [ar, ec] = trend_component_ar_ec(model_name, params)" << endl
|
ar_ec_output << "function [AR, A0, A0star] = trend_component_ar_a0(model_name, params)" << endl
|
||||||
<< "%function [ar, ec] = trend_component_ar_ec(model_name, params)" << endl
|
<< "%function [AR, A0, A0star] = trend_component_ar_a0(model_name, params)" << endl
|
||||||
<< "% File automatically generated by the Dynare preprocessor" << endl << endl;
|
<< "% File automatically generated by the Dynare preprocessor" << endl << endl;
|
||||||
|
|
||||||
for (const auto &name : names)
|
for (const auto &name : names)
|
||||||
|
@ -328,32 +330,49 @@ TrendComponentModelTable::writeOutput(const string &basename, ostream &output) c
|
||||||
|
|
||||||
ar_ec_output << "if strcmp(model_name, '" << name << "')" << endl
|
ar_ec_output << "if strcmp(model_name, '" << name << "')" << endl
|
||||||
<< " % AR" << endl
|
<< " % AR" << endl
|
||||||
<< " ar = zeros(" << nontarget_lhs_vec.size() << ", " << nontarget_lhs_vec.size() << ", " << getMaxLag(name) << ");" << endl;
|
<< " AR = zeros(" << nontarget_lhs_vec.size() << ", " << nontarget_lhs_vec.size() << ", " << getMaxLag(name) << ");" << endl;
|
||||||
for (const auto & it : AR.at(name))
|
for (const auto & it : AR.at(name))
|
||||||
{
|
{
|
||||||
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 colidx = (int) distance(nontarget_lhs_vec.begin(), find(nontarget_lhs_vec.begin(), nontarget_lhs_vec.end(), lhs_symb_id));
|
int colidx = (int) distance(nontarget_lhs_vec.begin(), find(nontarget_lhs_vec.begin(), nontarget_lhs_vec.end(), lhs_symb_id));
|
||||||
ar_ec_output << " ar(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
|
ar_ec_output << " AR(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
|
||||||
it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel);
|
it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel);
|
||||||
ar_ec_output << ";" << endl;
|
ar_ec_output << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ec_lag = 0;
|
int a0_lag = 0;
|
||||||
for (const auto & it : EC.at(name))
|
for (const auto & it : A0.at(name))
|
||||||
if (get<1>(it.first) > ec_lag)
|
if (get<1>(it.first) > a0_lag)
|
||||||
ec_lag = get<1>(it.first);
|
a0_lag = get<1>(it.first);
|
||||||
ar_ec_output << endl
|
ar_ec_output << endl
|
||||||
<< " % EC" << endl
|
<< " % A0" << endl
|
||||||
<< " ec = zeros(" << nontarget_lhs_vec.size() << ", " << target_lhs_vec.size() << ", " << ec_lag << ");" << endl;
|
<< " A0 = zeros(" << nontarget_lhs_vec.size() << ", " << nontarget_lhs_vec.size() << ", " << a0_lag << ");" << endl;
|
||||||
for (const auto & it : EC.at(name))
|
for (const auto & it : A0.at(name))
|
||||||
{
|
{
|
||||||
int eqn, lag, colidx;
|
int eqn, lag, colidx;
|
||||||
tie (eqn, lag, colidx) = it.first;
|
tie (eqn, lag, colidx) = it.first;
|
||||||
ar_ec_output << " ec(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
|
ar_ec_output << " A0(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
|
||||||
it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel);
|
it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel);
|
||||||
ar_ec_output << ";" << endl;
|
ar_ec_output << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int a0star_lag = 0;
|
||||||
|
for (const auto & it : A0star.at(name))
|
||||||
|
if (get<1>(it.first) > a0star_lag)
|
||||||
|
a0star_lag = get<1>(it.first);
|
||||||
|
ar_ec_output << endl
|
||||||
|
<< " % A0star" << endl
|
||||||
|
<< " A0star = zeros(" << nontarget_lhs_vec.size() << ", " << target_lhs_vec.size() << ", " << a0star_lag << ");" << endl;
|
||||||
|
for (const auto & it : A0star.at(name))
|
||||||
|
{
|
||||||
|
int eqn, lag, colidx;
|
||||||
|
tie (eqn, lag, colidx) = it.first;
|
||||||
|
ar_ec_output << " A0star(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
|
||||||
|
it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel);
|
||||||
|
ar_ec_output << ";" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
ar_ec_output << " return" << endl
|
ar_ec_output << " return" << endl
|
||||||
<< "end" << endl << endl;
|
<< "end" << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
map<string, vector<expr_t>> lhs_expr_t;
|
map<string, vector<expr_t>> lhs_expr_t;
|
||||||
map<string, vector<int>> target_vars;
|
map<string, vector<int>> target_vars;
|
||||||
map<string, map<tuple<int, int, int>, expr_t>> AR; // AR: name -> (eqn, lag, lhs_symb_id) -> expr_t
|
map<string, map<tuple<int, int, int>, expr_t>> AR; // AR: name -> (eqn, lag, lhs_symb_id) -> expr_t
|
||||||
map<string, map<tuple<int, int, int>, expr_t>> EC; // EC: name -> (eqn, lag, col) -> expr_t
|
map<string, map<tuple<int, int, int>, expr_t>> A0, A0star; // EC: name -> (eqn, lag, col) -> expr_t
|
||||||
public:
|
public:
|
||||||
explicit TrendComponentModelTable(SymbolTable &symbol_table_arg);
|
explicit TrendComponentModelTable(SymbolTable &symbol_table_arg);
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ public:
|
||||||
void setOrigDiffVar(map<string, vector<int>> orig_diff_var_arg);
|
void setOrigDiffVar(map<string, vector<int>> orig_diff_var_arg);
|
||||||
void setTargetVar(map<string, vector<int>> target_vars_arg);
|
void setTargetVar(map<string, vector<int>> target_vars_arg);
|
||||||
void setAR(map<string, map<tuple<int, int, int>, expr_t>> AR_arg);
|
void setAR(map<string, map<tuple<int, int, int>, expr_t>> AR_arg);
|
||||||
void setEC(map<string, map<tuple<int, int, int>, expr_t>> EC_arg);
|
void setA0(map<string, map<tuple<int, int, int>, expr_t>> A0_arg,
|
||||||
|
map<string, map<tuple<int, int, int>, expr_t>> A0star_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;
|
||||||
|
|
Loading…
Reference in New Issue