preprocessor: var_estimation: remove unnecessary equation specifiers in syntax

time-shift
Houtan Bastani 2017-05-19 14:20:26 +02:00
parent 17f4310214
commit 9b450f1531
5 changed files with 19 additions and 25 deletions

View File

@ -340,17 +340,13 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
for (crossequation_restrictions_t::const_iterator it = crossequation_restrictions.begin(); for (crossequation_restrictions_t::const_iterator it = crossequation_restrictions.begin();
it != crossequation_restrictions.end(); it++, idx++, nrestrictions++) it != crossequation_restrictions.end(); it++, idx++, nrestrictions++)
{ {
output << Mstr << "crossequation_restriction{" << idx << "}.eq1 = '" output << Mstr << "crossequation_restriction{" << idx << "}.val = "
<< symbol_table.getName(it->first.first) << "';" << endl << it->second << ";" << endl;
<< Mstr << "crossequation_restriction{" << idx << "}.eq2 = '"
<< symbol_table.getName(it->first.second) << "';" << endl
<< Mstr << "crossequation_restriction{" << idx << "}.val = "
<< it->second.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 = '" output << Mstr << "crossequation_restriction{" << idx << "}.lseq = '"
<< symbol_table.getName(ls.first.first) << "';" << endl << 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 << symbol_table.getName(ls.first.second.first) << "';" << endl
<< Mstr << "crossequation_restriction{" << idx << "}.lslag = " << Mstr << "crossequation_restriction{" << idx << "}.lslag = "
<< ls.first.second.second << ";" << endl << ls.first.second.second << ";" << endl
@ -358,12 +354,12 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b
ls.second->writeOutput(output); ls.second->writeOutput(output);
output << ";" << endl; 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) if (rs.first.first >= 0)
{ {
output << Mstr << "crossequation_restriction{" << idx << "}.rseq = '" output << Mstr << "crossequation_restriction{" << idx << "}.rseq = '"
<< symbol_table.getName(rs.first.first) << "';" << endl << 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 << symbol_table.getName(rs.first.second.first) << "';" << endl
<< Mstr << "crossequation_restriction{" << idx << "}.rslag = " << Mstr << "crossequation_restriction{" << idx << "}.rslag = "
<< rs.first.second.second << ";" << endl << rs.first.second.second << ";" << endl

View File

@ -134,7 +134,7 @@ private:
const map<int, map<int, SymbolList> > exclusion_restrictions; 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; 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; 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 crossequation_restrictions_t crossequation_restrictions;
const map<pair<int, int>, double> covariance_number_restriction; const map<pair<int, int>, double> covariance_number_restriction;
const map<pair<int, int>, pair<int, int> > covariance_pair_restriction; const map<pair<int, int>, pair<int, int> > covariance_pair_restriction;

View File

@ -380,9 +380,9 @@ restrictions_list : restrictions_list restriction
restriction : EXCLUSION LAG INT_NUMBER ';' restriction_exclusion_equation_list restriction : EXCLUSION LAG INT_NUMBER ';' restriction_exclusion_equation_list
{ driver.add_VAR_exclusion_restriction($3); } { driver.add_VAR_exclusion_restriction($3); }
| RESTRICTION EQUATION '(' symbol ')' restriction_equation_equality ';' | RESTRICTION EQUATION '(' symbol ')' restriction_equation_equality ';'
{ driver.add_VAR_restriction_equation_or_crossequation_final($4, NULL); } { driver.add_VAR_restriction_equation_or_crossequation_final($4); }
| RESTRICTION CROSSEQUATIONS '(' symbol COMMA symbol ')' restriction_crossequation_equality ';' | RESTRICTION CROSSEQUATIONS restriction_crossequation_equality ';'
{ driver.add_VAR_restriction_equation_or_crossequation_final($4, $6); } { driver.add_VAR_restriction_equation_or_crossequation_final(NULL); }
| RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL number ';' | RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL number ';'
{ driver.add_VAR_covariance_number_restriction($4, $6, $9); } { driver.add_VAR_covariance_number_restriction($4, $6, $9); }
| RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL '(' symbol COMMA symbol ')' ';' | RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL '(' symbol COMMA symbol ')' ';'

View File

@ -576,18 +576,16 @@ ParsingDriver::multiply_arg2_by_neg_one()
} }
void 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 (name != NULL)
if (name2 == NULL)
equation_restrictions[symb_id1] = var_restriction_equation_or_crossequation;
else
{ {
int symb_id2 = name2 == NULL ? -1 : mod_file->symbol_table.getID(*name2); int symb_id = mod_file->symbol_table.getID(*name);
crossequation_restrictions[make_pair(symb_id1, symb_id2)] = var_restriction_equation_or_crossequation; equation_restrictions[symb_id] = var_restriction_equation_or_crossequation;
delete name2; delete name;
} }
delete name1; else
crossequation_restrictions.push_back(var_restriction_equation_or_crossequation);
} }
void void

View File

@ -272,7 +272,7 @@ public:
vector<var_restriction_eq_crosseq_t> var_restriction_eq_or_crosseq; 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; 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<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 //! > covariance restrictions
map<pair<int, int>, double> covariance_number_restriction; map<pair<int, int>, double> covariance_number_restriction;
map<pair<int, int>, pair<int, int> > covariance_pair_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_eq_or_crosseq(expr_t expr);
void add_VAR_restriction_equation_or_crossequation(string *numberstr); void add_VAR_restriction_equation_or_crossequation(string *numberstr);
void multiply_arg2_by_neg_one(); 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_number_restriction(string *name1, string *name2, string *valuestr);
void add_VAR_covariance_pair_restriction(string *name11, string *name12, string *name21, string *name22); void add_VAR_covariance_pair_restriction(string *name11, string *name12, string *name21, string *name22);
//! Runs VAR estimation process //! Runs VAR estimation process