relieve constraint that max lag on EC matrix is 1

issue#70
Houtan Bastani 2019-02-15 11:12:07 +01:00
parent f4837e6c94
commit b3fbb86214
No known key found for this signature in database
GPG Key ID: 000094FB955BE169
2 changed files with 8 additions and 10 deletions

View File

@ -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())

View File

@ -113,13 +113,6 @@ TrendComponentModelTable::setAR(map<string, map<tuple<int, int, int>, expr_t>> A
void
TrendComponentModelTable::setEC(map<string, map<tuple<int, int, int>, 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;
}