Commit fb8d9258 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

add pac_model statement

parent c4ae840b
......@@ -258,6 +258,114 @@ PriorPosteriorFunctionStatement::writeJsonOutput(ostream &output) const
output << "}";
}
PacModelStatement::PacModelStatement(const string &name_arg,
const string &var_name_arg,
const string &discount_arg,
const string &growth_arg,
const map<string, int> &undiff_arg,
const SymbolTable &symbol_table_arg) :
name(name_arg),
var_name(var_name_arg),
discount(discount_arg),
growth(growth_arg),
undiff(undiff_arg),
symbol_table(symbol_table_arg)
{
}
void
PacModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
mod_file_struct.pac_params.insert(symbol_table.getID(discount));
if (!growth.empty())
mod_file_struct.pac_params.insert(symbol_table.getID(growth));
}
void
PacModelStatement::fillUndiffedLHS(vector<int> &lhs_arg)
{
lhs = lhs_arg;
}
void
PacModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
output << "M_.pac." << name << ".var_model_name = '" << var_name << "';" << endl
<< "M_.pac." << name << ".discount_index = " << symbol_table.getTypeSpecificID(discount) + 1 << ";" << endl;
if (!growth.empty())
{
output << "M_.pac." << name << ".growth_index = " << symbol_table.getTypeSpecificID(growth) + 1 << ";" << endl
<< "M_.pac." << name << ".growth_type = ";
switch(symbol_table.getType(growth))
{
case eEndogenous:
output << "'endogenous';" << endl;
break;
case eExogenous:
output << "'exogenous';" << endl;
break;
case eParameter:
output << "'parameter';" << endl;
break;
default:
cerr << "pac_model: error encountered in growth type" << endl;
exit(EXIT_FAILURE);
}
}
output << "M_.pac." << name << ".lhs = [";
for (vector<int>::const_iterator it = lhs.begin(); it !=lhs.end(); it++)
{
if (it != lhs.begin())
output << " ";
output << *it + 1;
}
output << "];" << endl;
}
void
PacModelStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"pac_model\","
<< "\"model_name\": \"" << name << "\","
<< "\"var_model_name\": \"" << var_name << "\","
<< "\"discount_index\": " << symbol_table.getTypeSpecificID(discount) + 1;
if (!growth.empty())
{
output << ","
<< "\"growth_index\": " << symbol_table.getTypeSpecificID(growth) + 1 << ","
<< "\"growth_type\": ";
switch(symbol_table.getType(growth))
{
case eEndogenous:
output << "\"endogenous\"" << endl;
break;
case eExogenous:
output << "\"exogenous\"" << endl;
break;
case eParameter:
output << "\"parameter\"" << endl;
break;
default:
cerr << "pac_model: error encountered in growth type" << endl;
exit(EXIT_FAILURE);
}
}
output << "}";
}
void
PacModelStatement::getPacModelInfoForPacExpectation(pair<string, pair<string, pair<string, pair<int, map<string, int> > > > > &pac_model_info) const
{
int growth_symb_id = -1;
if (!growth.empty())
growth_symb_id = symbol_table.getID(growth);
pac_model_info = make_pair(name, make_pair(var_name, make_pair(discount, make_pair(growth_symb_id, undiff))));
}
VarModelStatement::VarModelStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
const string &name_arg,
......@@ -280,14 +388,13 @@ VarModelStatement::getVarModelInfoForVarExpectation(map<string, pair<SymbolList,
}
void
VarModelStatement::getVarModelEqTags(vector<string> &var_model_eqtags) const
VarModelStatement::getVarModelEqTags(map<string, vector<string> > &var_model_eqtags) const
{
if (!symbol_list.empty())
return;
OptionsList::vec_str_options_t::const_iterator it1 =
options_list.vector_str_options.find("var.eqtags");
var_model_eqtags = it1->second;
OptionsList::vec_str_options_t::const_iterator it = options_list.vector_str_options.find("var.eqtags");
var_model_eqtags[name] = it->second;
}
void
......
......@@ -119,6 +119,30 @@ public:
virtual void writeJsonOutput(ostream &output) const;
};
class PacModelStatement : public Statement
{
private:
const string &name;
const string &var_name;
const string &discount;
const string &growth;
const map<string, int> undiff;
const SymbolTable &symbol_table;
vector<int> lhs;
public:
PacModelStatement(const string &name_arg,
const string &var_name_arg,
const string &discount_arg,
const string &growth_arg,
const map<string, int> &undiff_arg,
const SymbolTable &symbol_table_arg);
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
virtual void writeJsonOutput(ostream &output) const;
void fillUndiffedLHS(vector<int> &lhs);
void getPacModelInfoForPacExpectation(pair<string, pair<string, pair<string, pair<int, map<string, int> > > > > &pac_model_info) const;
};
class VarModelStatement : public Statement
{
private:
......@@ -136,7 +160,7 @@ public:
const string &name_arg,
const SymbolTable &symbol_table_arg);
void getVarModelInfoForVarExpectation(map<string, pair<SymbolList, int> > &var_model_info) const;
void getVarModelEqTags(vector<string> &var_model_eqtags) const;
void getVarModelEqTags(map<string, vector<string> > &var_model_eqtags) const;
void fillVarModelInfoFromEquations(vector<int> &eqnumber_arg, vector<int> &lhs_arg,
vector<set<pair<int, int> > > &rhs_arg,
vector<bool> &nonstationary_arg,
......
......@@ -515,14 +515,13 @@ DataTree::AddVarExpectation(const int symb_id, const int forecast_horizon, const
}
expr_t
DataTree::AddPacExpectation(const string &model_name, const string &var_model_name, const int discount_id, const int growth_id)
DataTree::AddPacExpectation(const string &model_name)
{
pac_expectation_node_map_t::iterator it =
pac_expectation_node_map.find(make_pair(model_name, make_pair(var_model_name, make_pair(discount_id, growth_id))));
pac_expectation_node_map_t::iterator it = pac_expectation_node_map.find(model_name);
if (it != pac_expectation_node_map.end())
return it->second;
return new PacExpectationNode(*this, model_name, var_model_name, discount_id, growth_id);
return new PacExpectationNode(*this, model_name);
}
expr_t
......
......@@ -81,8 +81,8 @@ protected:
typedef map<pair<string, pair<int, int> >, VarExpectationNode *> var_expectation_node_map_t;
var_expectation_node_map_t var_expectation_node_map;
// (model_name, (discount, growth)) -> PacExpectationNode
typedef map<pair<string, pair<string, pair<int, int> > >, PacExpectationNode *> pac_expectation_node_map_t;
// model_name -> PacExpectationNode
typedef map<string, PacExpectationNode *> pac_expectation_node_map_t;
pac_expectation_node_map_t pac_expectation_node_map;
// ((arguments, deriv_idx), symb_id) -> FirstDerivExternalFunctionNode
......@@ -231,7 +231,7 @@ public:
//! Adds "var_expectation(arg1, arg2, model_name=arg3)" to model tree
expr_t AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name);
//! Adds pac_expectation command to model tree
expr_t AddPacExpectation(const string &model_name, const string &var_model_name, const int discount_id, const int growth_id);
expr_t AddPacExpectation(const string &model_name);
//! Adds a model local variable with its value
void AddLocalVariable(int symb_id, expr_t value) throw (LocalVariableException);
//! Adds an external function node
......
......@@ -3418,6 +3418,85 @@ DynamicModel::addEquationsForVar(map<string, pair<SymbolList, int> > &var_model_
cout << "Accounting for var_model lags not in model block: added " << count << " auxiliary variables and equations." << endl;
}
int
DynamicModel::get_undiff_max_lag(vector<int> &eqnumber, vector<int> &lhs)
{
int max_lag = 0;
for (vector<int>::const_iterator it = eqnumber.begin();
it != eqnumber.end(); it++)
{
int max_lag_tmp = dynamic_cast<BinaryOpNode *>(equations[*it])->get_arg2()->PacMaxLag(lhs);
if (max_lag_tmp > max_lag)
max_lag = max_lag_tmp;
}
return max_lag;
}
void
DynamicModel::undiff_lhs_for_pac(vector<int> &lhs, vector<bool> &diff, vector<int> &orig_diff_var,
vector<int> &eqnumber, map<string, int> &undiff, map<int, int> &undiff_table)
{
if (undiff.empty())
return;
for (map<string, int>::const_iterator it = undiff.begin();
it != undiff.end(); it++)
{
int eqn = -1;
string eqtag (it->first);
for (vector<pair<int, pair<string, string> > >::const_iterator iteqtag =
equation_tags.begin(); iteqtag != equation_tags.end(); iteqtag++)
if (iteqtag->second.first == "name"
&& iteqtag->second.second == eqtag)
{
eqn = iteqtag->first;
break;
}
if (eqn == -1)
{
cerr << "ERROR: equation tag '" << eqtag << "' not found" << endl;
exit(EXIT_FAILURE);
}
int i = 0;
bool found = false;
for (vector<int>::const_iterator it1 = eqnumber.begin();
it1 != eqnumber.end(); it1++)
if (eqn == i)
{
found = true;
break;
}
else
i++;
if (!found)
{
cerr << "ERROR: equation not found in VAR";
exit(EXIT_FAILURE);
}
if (diff.at(eqnumber[i]) != true)
{
cerr << "ERROR: the variable on the LHS of equation #" << eqn << " (VAR equation #" << eqnumber[i]
<< " with equation tag '" << eqtag
<< "') does not have the diff operator applied to it yet you are trying to undiff it." << endl;
exit(EXIT_FAILURE);
}
for (int j = it->second; j > 0; j--)
if (undiff_table.find(lhs.at(eqnumber.at(i))) == undiff_table.end())
{
cerr << "You are undiffing the LHS of equation #" << eqn << " "
<< it->second << " times but it has only been diffed " << j - 1 << " time(s)" << endl;
exit(EXIT_FAILURE);
}
else
lhs.at(eqnumber.at(i)) = undiff_table.at(lhs.at(eqnumber.at(i)));
}
}
void
DynamicModel::walkPacParameters()
{
......@@ -3436,10 +3515,11 @@ void
DynamicModel::fillPacExpectationVarInfo(string &var_model_name,
vector<int> &lhs,
int max_lag,
vector<bool> &nonstationary)
vector<bool> &nonstationary,
int growth_symb_id)
{
for (size_t i = 0; i < equations.size(); i++)
equations[i]->fillPacExpectationVarInfo(var_model_name, lhs, max_lag, nonstationary, i);
equations[i]->fillPacExpectationVarInfo(var_model_name, lhs, max_lag, nonstationary, growth_symb_id, i);
}
void
......@@ -5030,7 +5110,7 @@ DynamicModel::substituteAdl()
}
void
DynamicModel::substituteDiff(StaticModel &static_model)
DynamicModel::substituteDiff(StaticModel &static_model, map<int, int> &undiff_table)
{
// Find diff Nodes
diff_table_t diff_table;
......@@ -5046,13 +5126,13 @@ DynamicModel::substituteDiff(StaticModel &static_model)
ExprNode::subst_table_t diff_subst_table;
for (map<int, expr_t>::iterator it = local_variables_table.begin();
it != local_variables_table.end(); it++)
it->second = it->second->substituteDiff(static_model, diff_table, diff_subst_table, neweqs);
it->second = it->second->substituteDiff(static_model, diff_table, diff_subst_table, neweqs, undiff_table);
// Substitute in equations
for (int i = 0; i < (int) equations.size(); i++)
{
BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->
substituteDiff(static_model, diff_table, diff_subst_table, neweqs));
substituteDiff(static_model, diff_table, diff_subst_table, neweqs, undiff_table));
assert(substeq != NULL);
equations[i] = substeq;
}
......
......@@ -307,7 +307,11 @@ public:
void fillPacExpectationVarInfo(string &var_model_name,
vector<int> &lhs,
int max_lag,
vector<bool> &nonstationary);
vector<bool> &nonstationary,
int growth_symb_id);
//! Get the max lag for the PAC VAR
int get_undiff_max_lag(vector<int> &eqnumber, vector<int> &lhs);
//! Substitutes pac_expectation operator
void substitutePacExpectation();
......@@ -399,7 +403,11 @@ public:
void substituteAdl();
//! Substitutes diff operator
void substituteDiff(StaticModel &static_model);
void substituteDiff(StaticModel &static_model, map<int, int> &undiff_table);
//! Table to undiff LHS variables for pac vector z
void undiff_lhs_for_pac(vector<int> &lhs, vector<bool> &diff, vector<int> &orig_diff_var,
vector<int> &eqnumber, map<string, int> &undiff, map<int, int> &undiff_table);
//! Adds contents of diff_aux_equations to the back of aux_equations
void combineDiffAuxEquations();
......
......@@ -132,7 +132,7 @@ class ParsingDriver;
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
%token VALUES VAR VAREXO VAREXO_DET VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL CROSSEQUATIONS COVARIANCE WRITE_LATEX_STEADY_STATE_MODEL
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL QOQ YOY AOA PAC_EXPECTATION
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL PAC_MODEL QOQ YOY AOA UNDIFF PAC_EXPECTATION
%left COMMA
%left EQUAL_EQUAL EXCLAMATION_EQUAL
%left LESS GREATER LESS_EQUAL GREATER_EQUAL
......@@ -233,6 +233,7 @@ statement : parameters
| set_time
| data
| var_model
| pac_model
| restrictions
| prior
| prior_eq
......@@ -383,6 +384,20 @@ var_model_options : o_var_name
| o_var_eq_tags
;
pac_model : PAC_MODEL '(' pac_model_options_list ')' ';' { driver.pac_model(); } ;
pac_model_options_list : pac_model_options_list COMMA pac_model_options
| pac_model_options
;
pac_model_options : o_pac_name
| o_pac_var_name
| o_pac_discount
| o_pac_growth
| UNDIFF '(' QUOTED_STRING COMMA INT_NUMBER ')'
{ driver.pac_model_undiff($3, $5); }
;
restrictions : RESTRICTIONS '(' symbol ')' ';' { driver.begin_VAR_restrictions(); }
restrictions_list END ';' { driver.end_VAR_restrictions($3); }
;
......@@ -914,8 +929,8 @@ hand_side : '(' hand_side ')'
{ $$ = driver.add_var_expectation($3, new string("1"), $7); }
| VAR_EXPECTATION '(' symbol COMMA INT_NUMBER COMMA MODEL_NAME EQUAL NAME ')'
{ $$ = driver.add_var_expectation($3, $5, $9); }
| PAC_EXPECTATION '(' pac_expectation_options_list ')'
{ $$ = driver.add_pac_expectation(); }
| PAC_EXPECTATION '(' symbol ')'
{ $$ = driver.add_pac_expectation($3); }
| MINUS hand_side %prec UMINUS
{ $$ = driver.add_uminus($2); }
| PLUS hand_side
......@@ -974,21 +989,6 @@ hand_side : '(' hand_side ')'
{ $$ = driver.add_steady_state($3); }
;
pac_expectation_options_list : pac_expectation_options_list COMMA pac_expectation_options
| pac_expectation_options
;
pac_expectation_options : VAR_MODEL_NAME EQUAL NAME
{ driver.add_pac_expectation_var_model_name($3); }
| MODEL_NAME EQUAL NAME
{ driver.add_pac_expectation_model_name($3); }
| DISCOUNT EQUAL symbol
{ driver.add_pac_expectation_discount($3); }
| GROWTH EQUAL symbol
{ driver.add_pac_expectation_growth($3); }
;
comma_hand_side : hand_side
{ driver.add_external_function_arg($1); }
| comma_hand_side COMMA hand_side
......@@ -3203,6 +3203,10 @@ o_simul_seed : SIMUL_SEED EQUAL INT_NUMBER { driver.error("'simul_seed' option i
o_qz_criterium : QZ_CRITERIUM EQUAL non_negative_number { driver.option_num("qz_criterium", $3); };
o_qz_zero_threshold : QZ_ZERO_THRESHOLD EQUAL non_negative_number { driver.option_num("qz_zero_threshold", $3); };
o_file : FILE EQUAL filename { driver.option_str("file", $3); };
o_pac_name : MODEL_NAME EQUAL symbol { driver.option_str("pac.model_name", $3); };
o_pac_var_name : VAR_MODEL_NAME EQUAL symbol { driver.option_str("pac.var_model_name", $3); };
o_pac_discount : DISCOUNT EQUAL symbol { driver.option_str("pac.discount", $3); };
o_pac_growth : GROWTH EQUAL symbol { driver.option_str("pac.growth", $3); };
o_var_name : MODEL_NAME EQUAL symbol { driver.option_str("var.model_name", $3); };
o_var_order : ORDER EQUAL INT_NUMBER { driver.option_num("var.order", $3); };
o_series : SERIES EQUAL symbol { driver.option_str("series", $3); };
......
......@@ -140,6 +140,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<INITIAL>simul {BEGIN DYNARE_STATEMENT; return token::SIMUL;}
<INITIAL>stoch_simul {BEGIN DYNARE_STATEMENT; return token::STOCH_SIMUL;}
<INITIAL>var_model {BEGIN DYNARE_STATEMENT; return token::VAR_MODEL;}
<INITIAL>pac_model {BEGIN DYNARE_STATEMENT; return token::PAC_MODEL;}
<INITIAL>dsample {BEGIN DYNARE_STATEMENT; return token::DSAMPLE;}
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
......@@ -322,6 +323,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>kalman_algo {return token::KALMAN_ALGO;}
<DYNARE_STATEMENT>fast_kalman_filter {return token::FAST_KALMAN_FILTER;}
<DYNARE_STATEMENT>kalman_tol {return token::KALMAN_TOL;}
<DYNARE_STATEMENT>undiff {return token::UNDIFF;}
<DYNARE_STATEMENT>diffuse_kalman_tol {return token::DIFFUSE_KALMAN_TOL;}
<DYNARE_STATEMENT>forecast {return token::FORECAST;}
<DYNARE_STATEMENT>smoother {return token::SMOOTHER;}
......@@ -342,7 +344,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>optim {return token::OPTIM;}
<DYNARE_STATEMENT>periods {return token::PERIODS;}
<DYNARE_STATEMENT,DYNARE_BLOCK>model_name {return token::MODEL_NAME;}
<DYNARE_BLOCK>var_model_name {return token::VAR_MODEL_NAME;}
<DYNARE_STATEMENT>var_model_name {return token::VAR_MODEL_NAME;}
<DYNARE_STATEMENT>endogenous_terminal_period {return token::ENDOGENOUS_TERMINAL_PERIOD;}
<DYNARE_STATEMENT>sub_draws {return token::SUB_DRAWS;}
<DYNARE_STATEMENT>minimal_solving_periods {return token::MINIMAL_SOLVING_PERIODS;}
......@@ -626,6 +628,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>log_deflator {return token::LOG_DEFLATOR;}
<DYNARE_STATEMENT>growth_factor {return token::GROWTH_FACTOR;}
<DYNARE_STATEMENT>log_growth_factor {return token::LOG_GROWTH_FACTOR;}
<DYNARE_STATEMENT>growth {return token::GROWTH;}
<DYNARE_STATEMENT>cova_compute {return token::COVA_COMPUTE;}
<DYNARE_STATEMENT>discretionary_tol {return token::DISCRETIONARY_TOL;}
<DYNARE_STATEMENT>analytic_derivation {return token::ANALYTIC_DERIVATION;}
......@@ -678,7 +681,6 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
}
/* Inside a Dynare block */
<DYNARE_BLOCK>growth {return token::GROWTH;}
<DYNARE_BLOCK>var {return token::VAR;}
<DYNARE_BLOCK>stderr {return token::STDERR;}
<DYNARE_BLOCK>values {return token::VALUES;}
......@@ -825,7 +827,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT,DYNARE_BLOCK>expectation {return token::EXPECTATION;}
<DYNARE_BLOCK>var_expectation {return token::VAR_EXPECTATION;}
<DYNARE_BLOCK>pac_expectation {return token::PAC_EXPECTATION;}
<DYNARE_BLOCK>discount {return token::DISCOUNT;}
<DYNARE_STATEMENT>discount {return token::DISCOUNT;}
<DYNARE_STATEMENT,DYNARE_BLOCK>varobs {return token::VAROBS;}
<DYNARE_STATEMENT,DYNARE_BLOCK>varexobs {return token::VAREXOBS;}
<DYNARE_STATEMENT,DYNARE_BLOCK>full {return token::FULL;}
......
This diff is collapsed.
This diff is collapsed.
......@@ -324,7 +324,11 @@ ModFile::checkPass(bool nostrict, bool stochastic)
}
// Check if some exogenous is not used in the model block, Issue #841
set<int> unusedExo = dynamic_model.findUnusedExogenous();
set<int> unusedExo0 = dynamic_model.findUnusedExogenous();
set<int> unusedExo;
set_difference(unusedExo0.begin(), unusedExo0.end(),
mod_file_struct.pac_params.begin(), mod_file_struct.pac_params.end(),
inserter(unusedExo, unusedExo.begin()));
if (unusedExo.size() > 0)
{
ostringstream unused_exos;
......@@ -363,39 +367,67 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
}
// Create auxiliary variable and equations for Diff operator
dynamic_model.substituteDiff(diff_static_model);
map<int, int> undiff_table;
dynamic_model.substituteDiff(diff_static_model, undiff_table);
// Var Model
map<string, pair<SymbolList, int> > var_model_info_var_expectation;
map<string, vector<string> > var_model_eq_tags;
map<string, pair<pair<vector<int>, pair<vector<bool>, vector<int> > >, pair<pair<int, vector<bool> >, vector<int> > > > var_model_info_pac_expectation;
for (vector<Statement *>::const_iterator it = statements.begin();
it != statements.end(); it++)
{
VarModelStatement *vms = dynamic_cast<VarModelStatement *>(*it);
if (vms != NULL)
{
string var_model_name;
vms->getVarModelName(var_model_name);
vms->getVarModelEqTags(var_model_eq_tags);
vms->getVarModelInfoForVarExpectation(var_model_info_var_expectation);
vector<string> var_model_eqtags;
vms->getVarModelEqTags(var_model_eqtags);
if (!var_model_eqtags.empty())
{
int max_lag = 0;
vector<int> eqnumber, lhs, orig_diff_var;
vector<set<pair<int, int> > > rhs;
vector<bool> nonstationary, diff;
dynamic_model.getVarModelVariablesFromEqTags(var_model_eqtags,
eqnumber, lhs, rhs, nonstationary);
original_model.getVarMaxLagAndLhsDiffAndInfo(eqnumber, diff, orig_diff_var, max_lag);
vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary,
diff, orig_diff_var, max_lag);
string var_model_name;
vms->getVarModelName(var_model_name);
dynamic_model.walkPacParameters();
dynamic_model.fillPacExpectationVarInfo(var_model_name, lhs, max_lag, nonstationary);
dynamic_model.substitutePacExpectation();
}
int max_lag = 0;
vector<int> eqnumber, lhs, orig_diff_var;
vector<set<pair<int, int> > > rhs;
vector<bool> nonstationary, diff;
vector<string> eqtags = var_model_eq_tags[var_model_name];
dynamic_model.getVarModelVariablesFromEqTags(eqtags,
eqnumber, lhs, rhs, nonstationary);
original_model.getVarMaxLagAndLhsDiffAndInfo(eqnumber, diff, orig_diff_var, max_lag);
vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary,
diff, orig_diff_var, max_lag);
var_model_info_pac_expectation[var_model_name] =
make_pair(make_pair(lhs, make_pair(diff, orig_diff_var)), make_pair(make_pair(max_lag, nonstationary), eqnumber));
}
}
PacModelStatement *pms = dynamic_cast<PacModelStatement *>(*it);
if (pms != NULL)
{
pair<string, pair<string, pair<string, pair<int, map<string, int> > > > > pac_model_info_pac_expectation;
pms->getPacModelInfoForPacExpectation(pac_model_info_pac_expectation);
string pac_model_name = pac_model_info_pac_expectation.first;
string var_model_name = pac_model_info_pac_expectation.second.first;
vector<string> eqtags = var_model_eq_tags[var_model_name];
if (!eqtags.empty())
{
vector<int> lhs = var_model_info_pac_expectation[var_model_name].first.first;
map<string, int> undiff = pac_model_info_pac_expectation.second.second.second.second;
int max_lag = var_model_info_pac_expectation[var_model_name].second.first.first;
vector<bool> nonstationary = var_model_info_pac_expectation[var_model_name].second.first.second;
if (!undiff.empty())
{
vector<bool> diff = var_model_info_pac_expectation[var_model_name].first.second.first;
vector<int> orig_diff_var = var_model_info_pac_expectation[var_model_name].first.second.second;
vector<int> eqnumber = var_model_info_pac_expectation[var_model_name].second.second;
dynamic_model.undiff_lhs_for_pac(lhs, diff, orig_diff_var, eqnumber, undiff, undiff_table);
max_lag = dynamic_model.get_undiff_max_lag(eqnumber, lhs);
}
pms->fillUndiffedLHS(lhs);
dynamic_model.walkPacParameters();
int growth_symb_id = pac_model_info_pac_expectation.second.second.second.first;
dynamic_model.fillPacExpectationVarInfo(pac_model_name, lhs, max_lag, nonstationary, growth_symb_id);
dynamic_model.substitutePacExpectation();
}
}
}
if (!var_model_info_var_expectation.empty())
{
......
......@@ -2813,73 +2813,51 @@ ParsingDriver::add_var_expectation(string *arg1, string *arg2, string *arg3)
}
expr_t
ParsingDriver::add_pac_expectation()