From b3fbb862142eac0ea265e9bccacff2db3c6dec2a Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 15 Feb 2019 11:12:07 +0100 Subject: [PATCH] relieve constraint that max lag on EC matrix is 1 --- src/ExprNode.cc | 2 +- src/SubModel.cc | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ExprNode.cc b/src/ExprNode.cc index 7aacb79e..04bd29f5 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -5826,7 +5826,7 @@ BinaryOpNode::fillErrorCorrectionRowHelper(expr_t arg1, expr_t arg2, endog2 = isauxvar2 ? datatree.symbol_table.getOrigSymbIdForDiffAuxVar(endog2) : endog2; - int max_lag = 0; + int max_lag = vn2->lag; int colidx = -1; if (find(nontarget_lhs.begin(), nontarget_lhs.end(), endog1) != nontarget_lhs.end() && find(target_lhs.begin(), target_lhs.end(), endog2) != target_lhs.end()) diff --git a/src/SubModel.cc b/src/SubModel.cc index 586ae450..267b8242 100644 --- a/src/SubModel.cc +++ b/src/SubModel.cc @@ -113,13 +113,6 @@ TrendComponentModelTable::setAR(map, expr_t>> A void TrendComponentModelTable::setEC(map, expr_t>> EC_arg) { - for (const auto & itmap1 : EC_arg) - for (const auto &itmap2 : itmap1.second) - if (get<1>(itmap2.first) != 1) - { - cerr << "Error in EC component: lag must be equal to 1" << endl; - exit(EXIT_FAILURE); - } EC = move(EC_arg); } @@ -345,14 +338,19 @@ TrendComponentModelTable::writeOutput(const string &basename, ostream &output) c it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel); ar_ec_output << ";" << endl; } + + int ec_lag = 0; + for (const auto & it : EC.at(name)) + if (get<1>(it.first) > ec_lag) + ec_lag = get<1>(it.first); ar_ec_output << endl << " % EC" << endl - << " ec = zeros(" << nontarget_lhs_vec.size() << ", " << target_lhs_vec.size() << ", 1);" << endl; + << " ec = zeros(" << nontarget_lhs_vec.size() << ", " << target_lhs_vec.size() << ", " << ec_lag << ");" << endl; for (const auto & it : EC.at(name)) { int eqn, lag, colidx; tie (eqn, lag, colidx) = it.first; - ar_ec_output << " ec(" << eqn + 1 << ", " << colidx + 1 << ", 1) = "; + ar_ec_output << " ec(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = "; it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel); ar_ec_output << ";" << endl; }