diff --git a/ComputingTasks.cc b/ComputingTasks.cc index d856b1ad2686ae026272abb99947322ece5708a8..e792360a2ebd4c135eb2f712a9f61ae22e58ca97 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -340,17 +340,13 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b for (crossequation_restrictions_t::const_iterator it = crossequation_restrictions.begin(); it != crossequation_restrictions.end(); it++, idx++, nrestrictions++) { - output << Mstr << "crossequation_restriction{" << idx << "}.eq1 = '" - << symbol_table.getName(it->first.first) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.eq2 = '" - << symbol_table.getName(it->first.second) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.val = " - << it->second.second << ";" << endl; + output << Mstr << "crossequation_restriction{" << idx << "}.val = " + << it->second << ";" << endl; - var_restriction_eq_crosseq_t ls = it->second.first.first; + var_restriction_eq_crosseq_t ls = it->first.first; output << Mstr << "crossequation_restriction{" << idx << "}.lseq = '" << symbol_table.getName(ls.first.first) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.ls2 = '" + << Mstr << "crossequation_restriction{" << idx << "}.lsvar = '" << symbol_table.getName(ls.first.second.first) << "';" << endl << Mstr << "crossequation_restriction{" << idx << "}.lslag = " << ls.first.second.second << ";" << endl @@ -358,12 +354,12 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b ls.second->writeOutput(output); output << ";" << endl; - var_restriction_eq_crosseq_t rs = it->second.first.second; + var_restriction_eq_crosseq_t rs = it->first.second; if (rs.first.first >= 0) { output << Mstr << "crossequation_restriction{" << idx << "}.rseq = '" << symbol_table.getName(rs.first.first) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.rs2 = '" + << Mstr << "crossequation_restriction{" << idx << "}.rsvar = '" << symbol_table.getName(rs.first.second.first) << "';" << endl << Mstr << "crossequation_restriction{" << idx << "}.rslag = " << rs.first.second.second << ";" << endl diff --git a/ComputingTasks.hh b/ComputingTasks.hh index 326f2826161426231278fc99aab1a6cb8ec5d8a8..94a0ecfb36229ba5f077a96cc67f4459a8abe2cb 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -134,7 +134,7 @@ private: const map<int, map<int, SymbolList> > exclusion_restrictions; typedef map<int, pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> > equation_restrictions_t; const equation_restrictions_t equation_restrictions; - typedef map<pair<int, int>, pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> > crossequation_restrictions_t; + typedef vector<pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> > crossequation_restrictions_t; const crossequation_restrictions_t crossequation_restrictions; const map<pair<int, int>, double> covariance_number_restriction; const map<pair<int, int>, pair<int, int> > covariance_pair_restriction; diff --git a/DynareBison.yy b/DynareBison.yy index 8e8f9d4f8f0abf0f131278feee3da87ae1dd5d97..11e2506e75301ff387eb7d1cd6c945c5c1ab44d2 100644 --- a/DynareBison.yy +++ b/DynareBison.yy @@ -380,9 +380,9 @@ restrictions_list : restrictions_list restriction restriction : EXCLUSION LAG INT_NUMBER ';' restriction_exclusion_equation_list { driver.add_VAR_exclusion_restriction($3); } | RESTRICTION EQUATION '(' symbol ')' restriction_equation_equality ';' - { driver.add_VAR_restriction_equation_or_crossequation_final($4, NULL); } - | RESTRICTION CROSSEQUATIONS '(' symbol COMMA symbol ')' restriction_crossequation_equality ';' - { driver.add_VAR_restriction_equation_or_crossequation_final($4, $6); } + { driver.add_VAR_restriction_equation_or_crossequation_final($4); } + | RESTRICTION CROSSEQUATIONS restriction_crossequation_equality ';' + { driver.add_VAR_restriction_equation_or_crossequation_final(NULL); } | RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL number ';' { driver.add_VAR_covariance_number_restriction($4, $6, $9); } | RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL '(' symbol COMMA symbol ')' ';' diff --git a/ParsingDriver.cc b/ParsingDriver.cc index 2e1c5a2a27d5c76f57dc4f7a82be0727d0a06441..9fd948870cdad5e970c594b1456e7167a5f5e303 100644 --- a/ParsingDriver.cc +++ b/ParsingDriver.cc @@ -576,18 +576,16 @@ ParsingDriver::multiply_arg2_by_neg_one() } void -ParsingDriver::add_VAR_restriction_equation_or_crossequation_final(string *name1, string *name2) +ParsingDriver::add_VAR_restriction_equation_or_crossequation_final(string *name) { - int symb_id1 = mod_file->symbol_table.getID(*name1); - if (name2 == NULL) - equation_restrictions[symb_id1] = var_restriction_equation_or_crossequation; - else + if (name != NULL) { - int symb_id2 = name2 == NULL ? -1 : mod_file->symbol_table.getID(*name2); - crossequation_restrictions[make_pair(symb_id1, symb_id2)] = var_restriction_equation_or_crossequation; - delete name2; + int symb_id = mod_file->symbol_table.getID(*name); + equation_restrictions[symb_id] = var_restriction_equation_or_crossequation; + delete name; } - delete name1; + else + crossequation_restrictions.push_back(var_restriction_equation_or_crossequation); } void diff --git a/ParsingDriver.hh b/ParsingDriver.hh index c6ff4cfddd0847ca5f843cc4e177cdfb546c59d8..0198f52dbabbd658636f0581b039127cd4677f7d 100644 --- a/ParsingDriver.hh +++ b/ParsingDriver.hh @@ -272,7 +272,7 @@ public: vector<var_restriction_eq_crosseq_t> var_restriction_eq_or_crosseq; pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> var_restriction_equation_or_crossequation; map<int, pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> > equation_restrictions; - map<pair<int, int>, pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> > crossequation_restrictions; + vector<pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double> > crossequation_restrictions; //! > covariance restrictions map<pair<int, int>, double> covariance_number_restriction; map<pair<int, int>, pair<int, int> > covariance_pair_restriction; @@ -789,7 +789,7 @@ public: void add_VAR_restriction_eq_or_crosseq(expr_t expr); void add_VAR_restriction_equation_or_crossequation(string *numberstr); void multiply_arg2_by_neg_one(); - void add_VAR_restriction_equation_or_crossequation_final(string *name1, string *name2); + void add_VAR_restriction_equation_or_crossequation_final(string *name); void add_VAR_covariance_number_restriction(string *name1, string *name2, string *valuestr); void add_VAR_covariance_pair_restriction(string *name11, string *name12, string *name21, string *name22); //! Runs VAR estimation process