C++11: convert SymbolType to a class enum

issue#70
Sébastien Villemot 2018-07-17 18:34:07 +02:00
parent c12088f314
commit d6055c1407
14 changed files with 485 additions and 487 deletions

View File

@ -139,20 +139,20 @@ enum BlockSimulationType
//! Enumeration of possible symbol types
/*! Warning: do not to change existing values for 0 to 4: the values matter for homotopy_setup command */
enum SymbolType
enum class SymbolType
{
eEndogenous = 0, //!< Endogenous
eExogenous = 1, //!< Exogenous
eExogenousDet = 2, //!< Exogenous deterministic
eParameter = 4, //!< Parameter
eModelLocalVariable = 10, //!< Local variable whose scope is model (pound expression)
eModFileLocalVariable = 11, //!< Local variable whose scope is mod file (model excluded)
eExternalFunction = 12, //!< External (user-defined) function
eTrend = 13, //!< Trend variable
eStatementDeclaredVariable = 14, //!< Local variable assigned within a Statement (see subsample statement for example)
eLogTrend = 15, //!< Log-trend variable
eUnusedEndogenous = 16,
eEndogenousVAR = 17 //!< Variables declared in a var_model statement
endogenous = 0, //!< Endogenous
exogenous = 1, //!< Exogenous
exogenousDet = 2, //!< Exogenous deterministic
parameter = 4, //!< Parameter
modelLocalVariable = 10, //!< Local variable whose scope is model (pound expression)
modFileLocalVariable = 11, //!< Local variable whose scope is mod file (model excluded)
externalFunction = 12, //!< External (user-defined) function
trend = 13, //!< Trend variable
statementDeclaredVariable = 14, //!< Local variable assigned within a Statement (see subsample statement for example)
logTrend = 15, //!< Log-trend variable
unusedEndogenous = 16,
endogenousVAR = 17 //!< Variables declared in a var_model statement
};
enum ExpressionType

View File

@ -298,13 +298,13 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min
<< "M_.pac." << name << ".growth_type = ";
switch(symbol_table.getType(growth))
{
case eEndogenous:
case SymbolType::endogenous:
output << "'endogenous';" << endl;
break;
case eExogenous:
case SymbolType::exogenous:
output << "'exogenous';" << endl;
break;
case eParameter:
case SymbolType::parameter:
output << "'parameter';" << endl;
break;
default:
@ -354,13 +354,13 @@ PacModelStatement::writeJsonOutput(ostream &output) const
<< "\"growth_type\": ";
switch(symbol_table.getType(growth))
{
case eEndogenous:
case SymbolType::endogenous:
output << "\"endogenous\"" << endl;
break;
case eExogenous:
case SymbolType::exogenous:
output << "\"exogenous\"" << endl;
break;
case eParameter:
case SymbolType::parameter:
output << "\"parameter\"" << endl;
break;
default:
@ -1060,7 +1060,7 @@ RamseyPolicyStatement::checkRamseyPolicyList()
cerr << "ERROR: ramsey_policy: " << it << " was not declared." << endl;
exit(EXIT_FAILURE);
}
if (symbol_table.getType(it) != eEndogenous)
if (symbol_table.getType(it) != SymbolType::endogenous)
{
cerr << "ERROR: ramsey_policy: " << it << " is not endogenous." << endl;
exit(EXIT_FAILURE);
@ -1528,9 +1528,9 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
switch (it.type)
{
case 1:
if (symb_type == eExogenous)
if (symb_type == SymbolType::exogenous)
output << "estim_params_.var_exo = [estim_params_.var_exo; ";
else if (symb_type == eEndogenous)
else if (symb_type == SymbolType::endogenous)
output << "estim_params_.var_endo = [estim_params_.var_endo; ";
output << symb_id;
break;
@ -1539,9 +1539,9 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
<< symb_id;
break;
case 3:
if (symb_type == eExogenous)
if (symb_type == SymbolType::exogenous)
output << "estim_params_.corrx = [estim_params_.corrx; ";
else if (symb_type == eEndogenous)
else if (symb_type == SymbolType::endogenous)
output << "estim_params_.corrn = [estim_params_.corrn; ";
output << symb_id << " " << symbol_table.getTypeSpecificID(it.name2)+1;
break;
@ -1644,21 +1644,21 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
if (it.type < 3)
{
if (symb_type == eExogenous)
if (symb_type == SymbolType::exogenous)
{
output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symb_id << ");" << endl;
output << "estim_params_.var_exo(tmp1,2) = ";
it.init_val->writeOutput(output);
output << ";" << endl;
}
else if (symb_type == eEndogenous)
else if (symb_type == SymbolType::endogenous)
{
output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symb_id << ");" << endl;
output << "estim_params_.var_endo(tmp1,2) = ";
it.init_val->writeOutput(output);
output << ";" << endl;
}
else if (symb_type == eParameter)
else if (symb_type == SymbolType::parameter)
{
output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symb_id << ");" << endl;
output << "estim_params_.param_vals(tmp1,2) = ";
@ -1668,7 +1668,7 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
}
else
{
if (symb_type == eExogenous)
if (symb_type == SymbolType::exogenous)
{
output << "tmp1 = find((estim_params_.corrx(:,1)==" << symb_id << " & estim_params_.corrx(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | "
<< "(estim_params_.corrx(:,2)==" << symb_id << " & estim_params_.corrx(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl;
@ -1676,7 +1676,7 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
it.init_val->writeOutput(output);
output << ";" << endl;
}
else if (symb_type == eEndogenous)
else if (symb_type == SymbolType::endogenous)
{
output << "tmp1 = find((estim_params_.corrn(:,1)==" << symb_id << " & estim_params_.corrn(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | "
<< "(estim_params_.corrn(:,2)==" << symb_id << " & estim_params_.corrn(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl;
@ -1740,7 +1740,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
if (it.type < 3)
{
if (symb_type == eExogenous)
if (symb_type == SymbolType::exogenous)
{
output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symb_id << ");" << endl;
@ -1752,7 +1752,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
it.up_bound->writeOutput(output);
output << ";" << endl;
}
else if (symb_type == eEndogenous)
else if (symb_type == SymbolType::endogenous)
{
output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symb_id << ");" << endl;
@ -1764,7 +1764,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
it.up_bound->writeOutput(output);
output << ";" << endl;
}
else if (symb_type == eParameter)
else if (symb_type == SymbolType::parameter)
{
output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symb_id << ");" << endl;
@ -1779,7 +1779,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
}
else
{
if (symb_type == eExogenous)
if (symb_type == SymbolType::exogenous)
{
output << "tmp1 = find((estim_params_.corrx(:,1)==" << symb_id << " & estim_params_.corrx(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | "
<< "(estim_params_.corrx(:,2)==" << symb_id << " & estim_params_.corrx(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl;
@ -1792,7 +1792,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
it.up_bound->writeOutput(output);
output << ";" << endl;
}
else if (symb_type == eEndogenous)
else if (symb_type == SymbolType::endogenous)
{
output << "tmp1 = find((estim_params_.corrn(:,1)==" << symb_id << " & estim_params_.corrn(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | "
<< "(estim_params_.corrn(:,2)==" << symb_id << " & estim_params_.corrn(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl;
@ -1856,7 +1856,7 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename,
for (const auto & trend_element : trend_elements)
{
SymbolType type = symbol_table.getType(trend_element.first);
if (type == eEndogenous)
if (type == SymbolType::endogenous)
{
output << "tmp1 = strmatch('" << trend_element.first << "',options_.varobs,'exact');" << endl;
output << "options_.trend_coeffs{tmp1} = '";
@ -1876,7 +1876,7 @@ ObservationTrendsStatement::writeJsonOutput(ostream &output) const
bool printed = false;
for (const auto & trend_element : trend_elements)
{
if (symbol_table.getType(trend_element.first) == eEndogenous)
if (symbol_table.getType(trend_element.first) == SymbolType::endogenous)
{
if (printed)
output << ", ";
@ -3562,9 +3562,9 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename, bool m
// Initialize associated subsample substructures in estimation_info
const SymbolType symb_type = symbol_table.getType(name1);
string lhs_field;
if (symb_type == eParameter)
if (symb_type == SymbolType::parameter)
lhs_field = "parameter";
else if (symb_type == eExogenous || symb_type == eExogenousDet)
else if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
lhs_field = "structural_innovation";
else
lhs_field = "measurement_error";
@ -3648,9 +3648,9 @@ SubsamplesEqualStatement::writeOutput(ostream &output, const string &basename, b
// Initialize associated subsample substructures in estimation_info
const SymbolType symb_type = symbol_table.getType(to_name1);
string lhs_field;
if (symb_type == eParameter)
if (symb_type == SymbolType::parameter)
lhs_field = "parameter";
else if (symb_type == eExogenous || symb_type == eExogenousDet)
else if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
lhs_field = "structural_innovation";
else
lhs_field = "measurement_error";
@ -3909,7 +3909,7 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
bool
BasicPriorStatement::is_structural_innovation(const SymbolType symb_type) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
return true;
return false;
}
@ -3917,7 +3917,7 @@ BasicPriorStatement::is_structural_innovation(const SymbolType symb_type) const
void
BasicPriorStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
lhs_field = "structural_innovation";
else
lhs_field = "measurement_error";
@ -4314,7 +4314,7 @@ PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
void
PriorEqualStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
lhs_field = "structural_innovation";
else
lhs_field = "measurement_error";
@ -4416,7 +4416,7 @@ BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
bool
BasicOptionsStatement::is_structural_innovation(const SymbolType symb_type) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
return true;
return false;
}
@ -4424,7 +4424,7 @@ BasicOptionsStatement::is_structural_innovation(const SymbolType symb_type) cons
void
BasicOptionsStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
lhs_field = "structural_innovation";
else
lhs_field = "measurement_error";
@ -4692,7 +4692,7 @@ OptionsEqualStatement::writeJsonOutput(ostream &output) const
void
OptionsEqualStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
if (symb_type == SymbolType::exogenous || symb_type == SymbolType::exogenousDet)
lhs_field = "structural_innovation";
else
lhs_field = "measurement_error";

View File

@ -79,7 +79,7 @@ bool
DataTree::ParamUsedWithLeadLagInternal() const
{
for (const auto & it : variable_node_map)
if (symbol_table.getType(it.first.first) == eParameter && it.first.second != 0)
if (symbol_table.getType(it.first.first) == SymbolType::parameter && it.first.second != 0)
return true;
return false;
}
@ -507,7 +507,7 @@ DataTree::AddExpectation(int iArg1, expr_t iArg2)
expr_t
DataTree::AddVarExpectation(const int symb_id, const int forecast_horizon, const string &model_name)
{
assert(symbol_table.getType(symb_id) == eEndogenous);
assert(symbol_table.getType(symb_id) == SymbolType::endogenous);
auto it = var_expectation_node_map.find({ model_name, symb_id, forecast_horizon });
if (it != var_expectation_node_map.end())
@ -535,7 +535,7 @@ DataTree::AddEqual(expr_t iArg1, expr_t iArg2)
void
DataTree::AddLocalVariable(int symb_id, expr_t value) noexcept(false)
{
assert(symbol_table.getType(symb_id) == eModelLocalVariable);
assert(symbol_table.getType(symb_id) == SymbolType::modelLocalVariable);
// Throw an exception if symbol already declared
auto it = local_variables_table.find(symb_id);
@ -549,7 +549,7 @@ DataTree::AddLocalVariable(int symb_id, expr_t value) noexcept(false)
expr_t
DataTree::AddExternalFunction(int symb_id, const vector<expr_t> &arguments)
{
assert(symbol_table.getType(symb_id) == eExternalFunction);
assert(symbol_table.getType(symb_id) == SymbolType::externalFunction);
auto it = external_function_node_map.find({ arguments, symb_id });
if (it != external_function_node_map.end())
@ -561,7 +561,7 @@ DataTree::AddExternalFunction(int symb_id, const vector<expr_t> &arguments)
expr_t
DataTree::AddFirstDerivExternalFunction(int top_level_symb_id, const vector<expr_t> &arguments, int input_index)
{
assert(symbol_table.getType(top_level_symb_id) == eExternalFunction);
assert(symbol_table.getType(top_level_symb_id) == SymbolType::externalFunction);
auto it
= first_deriv_external_function_node_map.find({ arguments, input_index, top_level_symb_id });
@ -574,7 +574,7 @@ DataTree::AddFirstDerivExternalFunction(int top_level_symb_id, const vector<expr
expr_t
DataTree::AddSecondDerivExternalFunction(int top_level_symb_id, const vector<expr_t> &arguments, int input_index1, int input_index2)
{
assert(symbol_table.getType(top_level_symb_id) == eExternalFunction);
assert(symbol_table.getType(top_level_symb_id) == SymbolType::externalFunction);
auto it
= second_deriv_external_function_node_map.find({ arguments, input_index1, input_index2,

View File

@ -57,7 +57,7 @@ DynamicModel::AddVariable(int symb_id, int lag)
void
DynamicModel::compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, int lag, const map_idx_t &map_idx) const
{
auto it = first_derivatives.find({ eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag) });
auto it = first_derivatives.find({ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, symb_id), lag) });
if (it != first_derivatives.end())
(it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
else
@ -468,7 +468,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
int variable_ID = getBlockVariableID(block, i);
int equation_ID = getBlockEquationID(block, i);
EquationType equ_type = getBlockEquationType(block, i);
string sModel = symbol_table.getName(symbol_table.getID(eEndogenous, variable_ID));
string sModel = symbol_table.getName(symbol_table.getID(SymbolType::endogenous, variable_ID));
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2();
@ -520,7 +520,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
goto evaluation;
feedback_variables.push_back(variable_ID);
output << " % equation " << equation_ID+1 << " variable : " << sModel
<< " (" << variable_ID+1 << ") " << c_Equation_Type(equ_type) << " symb_id=" << symbol_table.getID(eEndogenous, variable_ID) << endl;
<< " (" << variable_ID+1 << ") " << c_Equation_Type(equ_type) << " symb_id=" << symbol_table.getID(SymbolType::endogenous, variable_ID) << endl;
output << " " << "residual(" << i+1-block_recursive << ") = (";
goto end;
case SOLVE_TWO_BOUNDARIES_COMPLETE:
@ -529,7 +529,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
goto evaluation;
feedback_variables.push_back(variable_ID);
output << " % equation " << equation_ID+1 << " variable : " << sModel
<< " (" << variable_ID+1 << ") " << c_Equation_Type(equ_type) << " symb_id=" << symbol_table.getID(eEndogenous, variable_ID) << endl;
<< " (" << variable_ID+1 << ") " << c_Equation_Type(equ_type) << " symb_id=" << symbol_table.getID(SymbolType::endogenous, variable_ID) << endl;
Ufoss << " b(" << i+1-block_recursive << "+Per_J_) = -residual(" << i+1-block_recursive << ", it_)";
Uf[equation_ID] += Ufoss.str();
Ufoss.str("");
@ -577,7 +577,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
output << " g1(" << eq+1 << ", " << count_col << ") = ";
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << "; % variable=" << symbol_table.getName(symbol_table.getID(eEndogenous, varr))
output << "; % variable=" << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, varr))
<< "(" << lag
<< ") " << varr+1 << ", " << var+1
<< ", equation=" << eqr+1 << ", " << eq+1 << endl;
@ -600,7 +600,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
expr_t id = it->second;
output << " g1_x(" << eqr+1 << ", " << count_col << ") = ";
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << "; % variable=" << symbol_table.getName(symbol_table.getID(eExogenous, var))
output << "; % variable=" << symbol_table.getName(symbol_table.getID(SymbolType::exogenous, var))
<< "(" << lag
<< ") " << var+1
<< ", equation=" << eq+1 << endl;
@ -623,7 +623,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
expr_t id = it->second;
output << " g1_xd(" << eqr+1 << ", " << count_col << ") = ";
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << "; % variable=" << symbol_table.getName(symbol_table.getID(eExogenous, var))
output << "; % variable=" << symbol_table.getName(symbol_table.getID(SymbolType::exogenous, var))
<< "(" << lag
<< ") " << var+1
<< ", equation=" << eq+1 << endl;
@ -647,7 +647,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
output << " g1_o(" << eqr+1 << ", " << /*var+1+(lag+block_max_lag)*block_size*/ count_col << ") = ";
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << "; % variable=" << symbol_table.getName(symbol_table.getID(eEndogenous, var))
output << "; % variable=" << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, var))
<< "(" << lag
<< ") " << var+1
<< ", equation=" << eq+1 << endl;
@ -680,7 +680,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
{
output << " g1(" << eq+1 << ", " << var+1-block_recursive << ") = ";
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << "; % variable=" << symbol_table.getName(symbol_table.getID(eEndogenous, varr))
output << "; % variable=" << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, varr))
<< "(" << lag
<< ") " << varr+1
<< ", equation=" << eqr+1 << endl;
@ -737,7 +737,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
output << " " << tmp_output.str();
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << ";";
output << " %2 variable=" << symbol_table.getName(symbol_table.getID(eEndogenous, varr))
output << " %2 variable=" << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, varr))
<< "(" << lag << ") " << varr+1
<< ", equation=" << eqr+1 << " (" << eq+1 << ")" << endl;
}
@ -827,7 +827,7 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
exo.push_back(i);
map<pair< int, pair<int, int>>, expr_t> first_derivatives_reordered_endo;
map<pair< pair<int, int>, pair<int, int>>, expr_t> first_derivatives_reordered_exo;
map<pair< pair<int, SymbolType>, pair<int, int>>, expr_t> first_derivatives_reordered_exo;
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
@ -835,9 +835,9 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
int symb = getSymbIDByDerivID(deriv_id);
unsigned int var = symbol_table.getTypeSpecificID(symb);
int lag = getLagByDerivID(deriv_id);
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
first_derivatives_reordered_endo[{ lag, make_pair(var, eq) }] = first_derivative.second;
else if (getTypeByDerivID(deriv_id) == eExogenous || getTypeByDerivID(deriv_id) == eExogenousDet)
else if (getTypeByDerivID(deriv_id) == SymbolType::exogenous || getTypeByDerivID(deriv_id) == SymbolType::exogenousDet)
first_derivatives_reordered_exo[{ { lag, getTypeByDerivID(deriv_id) }, { var, eq } }] = first_derivative.second;
}
int prev_var = -1;
@ -857,24 +857,23 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
}
prev_var = -1;
prev_lag = -999999999;
int prev_type = -1;
SymbolType prev_type{SymbolType::unusedEndogenous}; // Any non-exogenous type would do here
int count_col_exo = 0;
int count_col_det_exo = 0;
for (map<pair< pair<int, int>, pair<int, int>>, expr_t>::const_iterator it = first_derivatives_reordered_exo.begin();
it != first_derivatives_reordered_exo.end(); it++)
for (const auto & it : first_derivatives_reordered_exo)
{
int var = it->first.second.first;
int lag = it->first.first.first;
int type = it->first.first.second;
int var{it.first.second.first};
int lag{it.first.first.first};
SymbolType type{it.first.first.second};
if (prev_var != var || prev_lag != lag || prev_type != type)
{
prev_var = var;
prev_lag = lag;
prev_type = type;
if (type == eExogenous)
if (type == SymbolType::exogenous)
count_col_exo++;
else if (type == eExogenousDet)
else if (type == SymbolType::exogenousDet)
count_col_det_exo++;
}
}
@ -922,7 +921,7 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
expr_t d1 = first_derivative.second;
unsigned int eq = first_derivative.first.first;
@ -952,7 +951,7 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
{
FLDU_ fldu(it->second);
fldu.write(code_file, instruction_number);
FLDV_ fldv(eEndogenous, it->first.first, it->first.second);
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first.first), it->first.second};
fldv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
fbinary.write(code_file, instruction_number);
@ -1007,13 +1006,12 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
prev_var = -1;
prev_lag = -999999999;
count_col_exo = 0;
for (map<pair< pair<int, int>, pair<int, int>>, expr_t>::const_iterator it = first_derivatives_reordered_exo.begin();
it != first_derivatives_reordered_exo.end(); it++)
for (const auto & it : first_derivatives_reordered_exo)
{
unsigned int eq = it->first.second.second;
int var = it->first.second.first;
int lag = it->first.first.first;
expr_t d1 = it->second;
int eq{it.first.second.second};
int var{it.first.second.first};
int lag{it.first.first.first};
expr_t d1{it.second};
FNUMEXPR_ fnumexpr(FirstExoDerivative, eq, var, lag);
fnumexpr.write(code_file, instruction_number);
if (prev_var != var || prev_lag != lag)
@ -1361,7 +1359,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
{
FLDU_ fldu(Uf[v].Ufl->u);
fldu.write(code_file, instruction_number);
FLDV_ fldv(eEndogenous, Uf[v].Ufl->var, Uf[v].Ufl->lag);
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var), Uf[v].Ufl->lag};
fldv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
@ -2891,7 +2889,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
// Print variableID if exists with current period, otherwise print 0
try
{
int varID = getDerivID(symbol_table.getID(eEndogenous, endoID), lag);
int varID = getDerivID(symbol_table.getID(SymbolType::endogenous, endoID), lag);
output << " " << getDynJacobianCol(varID) + 1;
if (lag == -1)
{
@ -2973,7 +2971,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
for (int lag = -max_endo_lag; lag < 0; lag++)
try
{
getDerivID(symbol_table.getID(eEndogenous, variable_reordered[endoID]), lag);
getDerivID(symbol_table.getID(SymbolType::endogenous, variable_reordered[endoID]), lag);
if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[endoID]+1) == state_var.end())
state_var.push_back(variable_reordered[endoID]+1);
}
@ -3232,7 +3230,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
int eq = first_derivative.first.first;
int symb = getSymbIDByDerivID(deriv_id);
@ -3264,7 +3262,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
int n_obs = symbol_table.observedVariablesNbr();
int n_state = state_var.size();
for (vector<int>::const_iterator it = state_var.begin(); it != state_var.end(); it++)
if (symbol_table.isObservedVariable(symbol_table.getID(eEndogenous, *it-1)))
if (symbol_table.isObservedVariable(symbol_table.getID(SymbolType::endogenous, *it-1)))
n_obs--;
int n = n_obs + n_state;
@ -3464,7 +3462,7 @@ DynamicModel::collect_first_order_derivatives_endogenous()
map<pair<int, pair<int, int >>, expr_t> endo_derivatives;
for (auto & first_derivative : first_derivatives)
{
if (getTypeByDerivID(first_derivative.first.second) == eEndogenous)
if (getTypeByDerivID(first_derivative.first.second) == SymbolType::endogenous)
{
int eq = first_derivative.first.first;
int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first.second));
@ -3521,9 +3519,9 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
}
nonstationary.push_back(nonstationary_bool);
equations[eqn]->get_arg1()->collectDynamicVariables(eEndogenous, lhs_set);
equations[eqn]->get_arg1()->collectDynamicVariables(eExogenous, lhs_tmp_set);
equations[eqn]->get_arg1()->collectDynamicVariables(eParameter, lhs_tmp_set);
equations[eqn]->get_arg1()->collectDynamicVariables(SymbolType::endogenous, lhs_set);
equations[eqn]->get_arg1()->collectDynamicVariables(SymbolType::exogenous, lhs_tmp_set);
equations[eqn]->get_arg1()->collectDynamicVariables(SymbolType::parameter, lhs_tmp_set);
if (lhs_set.size() != 1 || !lhs_tmp_set.empty())
{
@ -3548,7 +3546,7 @@ DynamicModel::getVarModelVariablesFromEqTags(vector<string> &var_model_eqtags,
equations[eqn]->get_arg1()->collectVARLHSVariable(lhs_expr_t_set);
lhs_expr_t.push_back(*(lhs_expr_t_set.begin()));
equations[eqn]->get_arg2()->collectDynamicVariables(eEndogenous, rhs_set);
equations[eqn]->get_arg2()->collectDynamicVariables(SymbolType::endogenous, rhs_set);
for (it = rhs_set.begin(); it != rhs_set.end(); it++)
if (it->second > 0)
{
@ -3616,7 +3614,7 @@ DynamicModel::getVarLhsDiffAndInfo(vector<int> &eqnumber, vector<bool> &diff,
if (diff.back())
{
set<pair<int, int>> diff_set;
equations[*it]->get_arg1()->collectDynamicVariables(eEndogenous, diff_set);
equations[*it]->get_arg1()->collectDynamicVariables(SymbolType::endogenous, diff_set);
if (diff_set.size() != 1)
{
@ -3847,7 +3845,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
it != deriv_id_table.end(); it++)
{
SymbolType type = symbol_table.getType(it->first.first);
if (type == eEndogenous || (jacobianExo && (type == eExogenous || type == eExogenousDet)))
if (type == SymbolType::endogenous || (jacobianExo && (type == SymbolType::exogenous || type == SymbolType::exogenousDet)))
vars.insert(it->second);
}
@ -4126,9 +4124,9 @@ DynamicModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_endo_derivat
for (int i = 0; i < block_nb_recursives; i++)
{
if (getBlockEquationType(block, i) == E_EVALUATE_S)
recursive_variables[getDerivID(symbol_table.getID(eEndogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationRenormalizedExpr(block, i);
recursive_variables[getDerivID(symbol_table.getID(SymbolType::endogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationRenormalizedExpr(block, i);
else
recursive_variables[getDerivID(symbol_table.getID(eEndogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationExpr(block, i);
recursive_variables[getDerivID(symbol_table.getID(SymbolType::endogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationExpr(block, i);
}
map<pair<pair<int, pair<int, int>>, pair<int, int>>, int> Derivatives = get_Derivatives(block);
map<pair<pair<int, pair<int, int>>, pair<int, int>>, int>::const_iterator it = Derivatives.begin();
@ -4143,15 +4141,15 @@ DynamicModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_endo_derivat
int eqr = it_l.second.first;
int varr = it_l.second.second;
if (Deriv_type == 0)
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = first_derivatives[{ eqr, getDerivID(symbol_table.getID(eEndogenous, varr), lag) }];
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = first_derivatives[{ eqr, getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag) }];
else if (Deriv_type == 1)
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables);
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag), recursive_variables);
else if (Deriv_type == 2)
{
if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursives)
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables);
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag), recursive_variables);
else
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables);
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag), recursive_variables);
}
tmp_derivatives.emplace_back(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[{ eqr, { varr, lag } }]));
}
@ -4199,7 +4197,7 @@ DynamicModel::collect_block_first_order_derivatives()
lag_var_t lag_var;
switch (getTypeByDerivID(first_derivative.first.second))
{
case eEndogenous:
case SymbolType::endogenous:
block_var = variable_2_block[var];
if (block_eq == block_var)
{
@ -4208,7 +4206,7 @@ DynamicModel::collect_block_first_order_derivatives()
if (lag > 0 && lag > endo_max_leadlag_block[block_eq].second)
endo_max_leadlag_block[block_eq] = { endo_max_leadlag_block[block_eq].first, lag };
tmp_derivative = derivative_endo[block_eq];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eEndogenous, var), lag) }];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, var), lag) }];
derivative_endo[block_eq] = tmp_derivative;
}
else
@ -4232,7 +4230,7 @@ DynamicModel::collect_block_first_order_derivatives()
}
}
}
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eEndogenous, var), lag) }];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, var), lag) }];
derivative_other_endo[block_eq] = tmp_derivative;
lag_var = other_endo_block[block_eq];
if (lag_var.find(lag) == lag_var.end())
@ -4241,7 +4239,7 @@ DynamicModel::collect_block_first_order_derivatives()
other_endo_block[block_eq] = lag_var;
}
break;
case eExogenous:
case SymbolType::exogenous:
if (lag < 0 && lag < -exo_max_leadlag_block[block_eq].first)
exo_max_leadlag_block[block_eq] = { -lag, exo_max_leadlag_block[block_eq].second };
if (lag > 0 && lag > exo_max_leadlag_block[block_eq].second)
@ -4261,7 +4259,7 @@ DynamicModel::collect_block_first_order_derivatives()
}
}
}
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eExogenous, var), lag) }];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(SymbolType::exogenous, var), lag) }];
derivative_exo[block_eq] = tmp_derivative;
lag_var = exo_block[block_eq];
if (lag_var.find(lag) == lag_var.end())
@ -4269,7 +4267,7 @@ DynamicModel::collect_block_first_order_derivatives()
lag_var[lag].insert(var);
exo_block[block_eq] = lag_var;
break;
case eExogenousDet:
case SymbolType::exogenousDet:
if (lag < 0 && lag < -exo_det_max_leadlag_block[block_eq].first)
exo_det_max_leadlag_block[block_eq] = { -lag, exo_det_max_leadlag_block[block_eq].second };
if (lag > 0 && lag > exo_det_max_leadlag_block[block_eq].second)
@ -4289,7 +4287,7 @@ DynamicModel::collect_block_first_order_derivatives()
}
}
}
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eExogenous, var), lag) }];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(SymbolType::exogenous, var), lag) }];
derivative_exo_det[block_eq] = tmp_derivative;
lag_var = exo_det_block[block_eq];
if (lag_var.find(lag) == lag_var.end())
@ -4488,7 +4486,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const boo
int max_eq_lead = 0;
int max_eq_lag = 0;
for (auto & equation : equations)
equation->collectDynamicVariables(eEndogenous, dynvars);
equation->collectDynamicVariables(SymbolType::endogenous, dynvars);
for (const auto & dynvar : dynvars)
{
@ -4502,7 +4500,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const boo
// Get Discount Factor
assert(symbol_table.exists("optimal_policy_discount_factor"));
int symb_id = symbol_table.getID("optimal_policy_discount_factor");
assert(symbol_table.getType(symb_id) == eParameter);
assert(symbol_table.getType(symb_id) == SymbolType::parameter);
expr_t discount_factor_node = AddVariable(symb_id, 0);
// Create (modified) Lagrangian (so that we can take the derivative once at time t)
@ -4533,7 +4531,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const boo
for (deriv_id_table_t::const_iterator it = deriv_id_table.begin();
it != deriv_id_table.end(); it++)
// For all endogenous variables with zero lag
if (symbol_table.getType(it->first.first) == eEndogenous && it->first.second == 0)
if (symbol_table.getType(it->first.first) == SymbolType::endogenous && it->first.second == 0)
neweqs.push_back(AddEqual(equations[0]->getNonZeroPartofEquation()->getDerivative(it->second), Zero));
// Add new equations
@ -4602,7 +4600,7 @@ DynamicModel::findUnusedEndogenous()
{
set<int> usedEndo, unusedEndo;
for (auto & equation : equations)
equation->collectVariables(eEndogenous, usedEndo);
equation->collectVariables(SymbolType::endogenous, usedEndo);
set<int> allEndo = symbol_table.getEndogenous();
set_difference(allEndo.begin(), allEndo.end(),
usedEndo.begin(), usedEndo.end(),
@ -4615,7 +4613,7 @@ DynamicModel::findUnusedExogenous()
{
set<int> usedExo, unusedExo, unobservedExo;
for (auto & equation : equations)
equation->collectVariables(eExogenous, usedExo);
equation->collectVariables(SymbolType::exogenous, usedExo);
set<int> observedExo = symbol_table.getObservedExogenous();
set<int> allExo = symbol_table.getExogenous();
set_difference(allExo.begin(), allExo.end(),
@ -4634,9 +4632,9 @@ DynamicModel::setLeadsLagsOrig()
for (auto & equation : equations)
{
equation->collectDynamicVariables(eEndogenous, dynvars);
equation->collectDynamicVariables(eExogenous, dynvars);
equation->collectDynamicVariables(eExogenousDet, dynvars);
equation->collectDynamicVariables(SymbolType::endogenous, dynvars);
equation->collectDynamicVariables(SymbolType::exogenous, dynvars);
equation->collectDynamicVariables(SymbolType::exogenousDet, dynvars);
}
for (const auto & dynvar : dynvars)
@ -4651,19 +4649,19 @@ DynamicModel::setLeadsLagsOrig()
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
if (max_endo_lead_orig < lag)
max_endo_lead_orig = lag;
else if (-max_endo_lag_orig > lag)
max_endo_lag_orig = -lag;
break;
case eExogenous:
case SymbolType::exogenous:
if (max_exo_lead_orig < lag)
max_exo_lead_orig = lag;
else if (-max_exo_lag_orig > lag)
max_exo_lag_orig = -lag;
break;
case eExogenousDet:
case SymbolType::exogenousDet:
if (max_exo_det_lead_orig < lag)
max_exo_det_lead_orig = lag;
else if (-max_exo_det_lag_orig > lag)
@ -4681,17 +4679,17 @@ DynamicModel::computeDerivIDs()
set<pair<int, int>> dynvars;
for (auto & equation : equations)
equation->collectDynamicVariables(eEndogenous, dynvars);
equation->collectDynamicVariables(SymbolType::endogenous, dynvars);
dynJacobianColsNbr = dynvars.size();
for (auto & equation : equations)
{
equation->collectDynamicVariables(eExogenous, dynvars);
equation->collectDynamicVariables(eExogenousDet, dynvars);
equation->collectDynamicVariables(eParameter, dynvars);
equation->collectDynamicVariables(eTrend, dynvars);
equation->collectDynamicVariables(eLogTrend, dynvars);
equation->collectDynamicVariables(SymbolType::exogenous, dynvars);
equation->collectDynamicVariables(SymbolType::exogenousDet, dynvars);
equation->collectDynamicVariables(SymbolType::parameter, dynvars);
equation->collectDynamicVariables(SymbolType::trend, dynvars);
equation->collectDynamicVariables(SymbolType::logTrend, dynvars);
}
for (const auto & dynvar : dynvars)
@ -4704,26 +4702,26 @@ DynamicModel::computeDerivIDs()
We don't want these to be affected by lead/lags on parameters: they
are accepted for facilitating variable flipping, but are simply
ignored. */
if (max_lead < lag && type != eParameter)
if (max_lead < lag && type != SymbolType::parameter)
max_lead = lag;
else if (-max_lag > lag && type != eParameter)
else if (-max_lag > lag && type != SymbolType::parameter)
max_lag = -lag;
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
if (max_endo_lead < lag)
max_endo_lead = lag;
else if (-max_endo_lag > lag)
max_endo_lag = -lag;
break;
case eExogenous:
case SymbolType::exogenous:
if (max_exo_lead < lag)
max_exo_lead = lag;
else if (-max_exo_lag > lag)
max_exo_lag = -lag;
break;
case eExogenousDet:
case SymbolType::exogenousDet:
if (max_exo_det_lead < lag)
max_exo_det_lead = lag;
else if (-max_exo_det_lag > lag)
@ -4779,7 +4777,7 @@ void
DynamicModel::addAllParamDerivId(set<int> &deriv_id_set)
{
for (size_t i = 0; i < inv_deriv_id_table.size(); i++)
if (symbol_table.getType(inv_deriv_id_table[i].first) == eParameter)
if (symbol_table.getType(inv_deriv_id_table[i].first) == SymbolType::parameter)
deriv_id_set.insert(i);
}
@ -4801,22 +4799,22 @@ DynamicModel::computeDynJacobianCols(bool jacobianExo)
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
ordered_dyn_endo[{ lag, tsid }] = deriv_id;
break;
case eExogenous:
case SymbolType::exogenous:
// At this point, dynJacobianColsNbr contains the number of dynamic endogenous
if (jacobianExo)
dyn_jacobian_cols_table[deriv_id] = dynJacobianColsNbr + tsid;
break;
case eExogenousDet:
case SymbolType::exogenousDet:
// At this point, dynJacobianColsNbr contains the number of dynamic endogenous
if (jacobianExo)
dyn_jacobian_cols_table[deriv_id] = dynJacobianColsNbr + symbol_table.exo_nbr() + tsid;
break;
case eParameter:
case eTrend:
case eLogTrend:
case SymbolType::parameter:
case SymbolType::trend:
case SymbolType::logTrend:
// We don't assign a dynamic jacobian column to parameters or trend variables
break;
default:
@ -4852,8 +4850,8 @@ DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context
{
for (deriv_id_table_t::const_iterator it = deriv_id_table.begin();
it != deriv_id_table.end(); it++)
if (symbol_table.getType(it->first.first) == eTrend
|| symbol_table.getType(it->first.first) == eLogTrend)
if (symbol_table.getType(it->first.first) == SymbolType::trend
|| symbol_table.getType(it->first.first) == SymbolType::logTrend)
for (int eq = 0; eq < (int) equations.size(); eq++)
{
expr_t homogeneq = AddMinus(equations[eq]->get_arg1(),
@ -4866,7 +4864,7 @@ DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context
testeq = testeq->getDerivative(it->second); // d F / d Trend
for (deriv_id_table_t::const_iterator endogit = deriv_id_table.begin();
endogit != deriv_id_table.end(); endogit++)
if (symbol_table.getType(endogit->first.first) == eEndogenous)
if (symbol_table.getType(endogit->first.first) == SymbolType::endogenous)
{
double nearZero = testeq->getDerivative(endogit->second)->eval(eval_context); // eval d F / d Trend d Endog
if (fabs(nearZero) > zero_band)
@ -5171,7 +5169,7 @@ DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_mode
// Substitute in used model local variables
set<int> used_local_vars;
for (auto & equation : equations)
equation->collectVariables(eModelLocalVariable, used_local_vars);
equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
for (int used_local_var : used_local_vars)
{
@ -5396,7 +5394,7 @@ DynamicModel::substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbe
// Find matching unary ops that may be outside of diffs (i.e., those with different lags)
set<int> used_local_vars;
for (int eqnumber : eqnumbers)
equations[eqnumber]->collectVariables(eModelLocalVariable, used_local_vars);
equations[eqnumber]->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
// Only substitute unary ops in model local variables that appear in VAR equations
for (auto & it : local_variables_table)
@ -5436,7 +5434,7 @@ DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t
{
set<int> used_local_vars;
for (const auto & equation : equations)
equation->collectVariables(eModelLocalVariable, used_local_vars);
equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
// Only substitute diffs in model local variables that appear in VAR equations
diff_table_t diff_table;
@ -5612,7 +5610,7 @@ DynamicModel::isModelLocalVariableUsed() const
size_t i = 0;
while (i < equations.size() && used_local_vars.size() == 0)
{
equations[i]->collectVariables(eModelLocalVariable, used_local_vars);
equations[i]->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
i++;
}
return used_local_vars.size() > 0;
@ -5831,7 +5829,7 @@ DynamicModel::writeJsonDynamicModelInfo(ostream &output) const
{
if (lag != -max_endo_lag)
output << ",";
int varID = getDerivID(symbol_table.getID(eEndogenous, endoID), lag);
int varID = getDerivID(symbol_table.getID(SymbolType::endogenous, endoID), lag);
output << " " << getDynJacobianCol(varID) + 1;
if (lag == -1)
{

View File

@ -688,13 +688,13 @@ change_type : CHANGE_TYPE '(' change_type_arg ')' change_type_var_list ';'
;
change_type_arg : PARAMETERS
{ $$ = eParameter; }
{ $$ = SymbolType::parameter; }
| VAR
{ $$ = eEndogenous; }
{ $$ = SymbolType::endogenous; }
| VAREXO
{ $$ = eExogenous; }
{ $$ = SymbolType::exogenous; }
| VAREXO_DET
{ $$ = eExogenousDet; }
{ $$ = SymbolType::exogenousDet; }
;
change_type_var_list : symbol
@ -894,11 +894,11 @@ hand_side : '(' hand_side ')'
| symbol
{ $$ = driver.add_model_variable($1); }
| symbol PIPE_E
{ $$ = driver.declare_or_change_type(eEndogenous, $1); }
{ $$ = driver.declare_or_change_type(SymbolType::endogenous, $1); }
| symbol PIPE_X
{ $$ = driver.declare_or_change_type(eExogenous, $1); }
{ $$ = driver.declare_or_change_type(SymbolType::exogenous, $1); }
| symbol PIPE_P
{ $$ = driver.declare_or_change_type(eParameter, $1); }
{ $$ = driver.declare_or_change_type(SymbolType::parameter, $1); }
| non_negative_number
{ $$ = driver.add_non_negative_constant($1); }
| hand_side PLUS hand_side

View File

@ -139,7 +139,7 @@ void
ExprNode::collectEndogenous(set<pair<int, int>> &result) const
{
set<pair<int, int>> symb_ids;
collectDynamicVariables(eEndogenous, symb_ids);
collectDynamicVariables(SymbolType::endogenous, symb_ids);
for (const auto & symb_id : symb_ids)
result.emplace(datatree.symbol_table.getTypeSpecificID(symb_id.first), symb_id.second);
}
@ -148,7 +148,7 @@ void
ExprNode::collectExogenous(set<pair<int, int>> &result) const
{
set<pair<int, int>> symb_ids;
collectDynamicVariables(eExogenous, symb_ids);
collectDynamicVariables(SymbolType::exogenous, symb_ids);
for (const auto & symb_id : symb_ids)
result.emplace(datatree.symbol_table.getTypeSpecificID(symb_id.first), symb_id.second);
}
@ -685,8 +685,8 @@ VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, int lag_arg)
datatree.variable_node_map[{ symb_id, lag }] = this;
// It makes sense to allow a lead/lag on parameters: during steady state calibration, endogenous and parameters can be swapped
assert(type != eExternalFunction
&& (lag == 0 || (type != eModelLocalVariable && type != eModFileLocalVariable)));
assert(type != SymbolType::externalFunction
&& (lag == 0 || (type != SymbolType::modelLocalVariable && type != SymbolType::modFileLocalVariable)));
}
void
@ -700,27 +700,27 @@ VariableNode::prepareForDerivation()
// Fill in non_null_derivatives
switch (type)
{
case eEndogenous:
case eExogenous:
case eExogenousDet:
case eParameter:
case eTrend:
case eLogTrend:
case SymbolType::endogenous:
case SymbolType::exogenous:
case SymbolType::exogenousDet:
case SymbolType::parameter:
case SymbolType::trend:
case SymbolType::logTrend:
// For a variable or a parameter, the only non-null derivative is with respect to itself
non_null_derivatives.insert(datatree.getDerivID(symb_id, lag));
break;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
datatree.local_variables_table[symb_id]->prepareForDerivation();
// Non null derivatives are those of the value of the local parameter
non_null_derivatives = datatree.local_variables_table[symb_id]->non_null_derivatives;
break;
case eModFileLocalVariable:
case eStatementDeclaredVariable:
case eUnusedEndogenous:
case SymbolType::modFileLocalVariable:
case SymbolType::statementDeclaredVariable:
case SymbolType::unusedEndogenous:
// Such a variable is never derived
break;
case eExternalFunction:
case eEndogenousVAR:
case SymbolType::externalFunction:
case SymbolType::endogenousVAR:
cerr << "VariableNode::prepareForDerivation: impossible case" << endl;
exit(EXIT_FAILURE);
}
@ -731,29 +731,29 @@ VariableNode::computeDerivative(int deriv_id)
{
switch (type)
{
case eEndogenous:
case eExogenous:
case eExogenousDet:
case eParameter:
case eTrend:
case eLogTrend:
case SymbolType::endogenous:
case SymbolType::exogenous:
case SymbolType::exogenousDet:
case SymbolType::parameter:
case SymbolType::trend:
case SymbolType::logTrend:
if (deriv_id == datatree.getDerivID(symb_id, lag))
return datatree.One;
else
return datatree.Zero;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->getDerivative(deriv_id);
case eModFileLocalVariable:
case SymbolType::modFileLocalVariable:
cerr << "ModFileLocalVariable is not derivable" << endl;
exit(EXIT_FAILURE);
case eStatementDeclaredVariable:
case SymbolType::statementDeclaredVariable:
cerr << "eStatementDeclaredVariable is not derivable" << endl;
exit(EXIT_FAILURE);
case eUnusedEndogenous:
case SymbolType::unusedEndogenous:
cerr << "eUnusedEndogenous is not derivable" << endl;
exit(EXIT_FAILURE);
case eExternalFunction:
case eEndogenousVAR:
case SymbolType::externalFunction:
case SymbolType::endogenousVAR:
cerr << "Impossible case!" << endl;
exit(EXIT_FAILURE);
}
@ -767,7 +767,7 @@ VariableNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, t
auto it = temporary_terms.find(const_cast<VariableNode *>(this));
if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx);
if (type == eModelLocalVariable)
if (type == SymbolType::modelLocalVariable)
datatree.local_variables_table[symb_id]->collectTemporary_terms(temporary_terms, temporary_terms_inuse, Curr_Block);
}
@ -810,7 +810,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "\\bar";
output << "{" << datatree.symbol_table.getTeXName(symb_id);
if (output_type == oLatexDynamicModel
&& (type == eEndogenous || type == eExogenous || type == eExogenousDet || type == eModelLocalVariable || type == eTrend || type == eLogTrend))
&& (type == SymbolType::endogenous || type == SymbolType::exogenous || type == SymbolType::exogenousDet || type == SymbolType::modelLocalVariable || type == SymbolType::trend || type == SymbolType::logTrend))
{
output << "_{t";
if (lag != 0)
@ -829,14 +829,14 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
int tsid = datatree.symbol_table.getTypeSpecificID(symb_id);
switch (type)
{
case eParameter:
case SymbolType::parameter:
if (output_type == oMatlabOutsideModel)
output << "M_.params" << "(" << tsid + 1 << ")";
else
output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type);
break;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
if (output_type == oMatlabDynamicModelSparse || output_type == oMatlabStaticModelSparse
|| output_type == oMatlabDynamicSteadyStateOperator || output_type == oMatlabDynamicSparseSteadyStateOperator
|| output_type == oCDynamicSteadyStateOperator)
@ -851,11 +851,11 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << datatree.symbol_table.getName(symb_id) << "__";
break;
case eModFileLocalVariable:
case SymbolType::modFileLocalVariable:
output << datatree.symbol_table.getName(symb_id);
break;
case eEndogenous:
case SymbolType::endogenous:
switch (output_type)
{
case oJuliaDynamicModel:
@ -906,7 +906,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
}
break;
case eExogenous:
case SymbolType::exogenous:
i = tsid + ARRAY_SUBSCRIPT_OFFSET(output_type);
switch (output_type)
{
@ -959,7 +959,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
}
break;
case eExogenousDet:
case SymbolType::exogenousDet:
i = tsid + datatree.symbol_table.exo_nbr() + ARRAY_SUBSCRIPT_OFFSET(output_type);
switch (output_type)
{
@ -1012,12 +1012,12 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
}
break;
case eExternalFunction:
case eTrend:
case eLogTrend:
case eStatementDeclaredVariable:
case eUnusedEndogenous:
case eEndogenousVAR:
case SymbolType::externalFunction:
case SymbolType::trend:
case SymbolType::logTrend:
case SymbolType::statementDeclaredVariable:
case SymbolType::unusedEndogenous:
case SymbolType::endogenousVAR:
cerr << "Impossible case" << endl;
exit(EXIT_FAILURE);
}
@ -1026,7 +1026,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
expr_t
VariableNode::substituteStaticAuxiliaryVariable() const
{
if (type == eEndogenous)
if (type == SymbolType::endogenous)
{
try
{
@ -1055,12 +1055,12 @@ VariableNode::compile(ostream &CompileCode, unsigned int &instruction_number,
const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
const deriv_node_temp_terms_t &tef_terms) const
{
if (type == eModelLocalVariable || type == eModFileLocalVariable)
if (type == SymbolType::modelLocalVariable || type == SymbolType::modFileLocalVariable)
datatree.local_variables_table[symb_id]->compile(CompileCode, instruction_number, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic, tef_terms);
else
{
int tsid = datatree.symbol_table.getTypeSpecificID(symb_id);
if (type == eExogenousDet)
if (type == SymbolType::exogenousDet)
tsid += datatree.symbol_table.exo_nbr();
if (!lhs_rhs)
{
@ -1068,26 +1068,26 @@ VariableNode::compile(ostream &CompileCode, unsigned int &instruction_number,
{
if (steady_dynamic) // steady state values in a dynamic model
{
FLDVS_ fldvs(type, tsid);
FLDVS_ fldvs{static_cast<uint8_t>(type), static_cast<unsigned int>(tsid)};
fldvs.write(CompileCode, instruction_number);
}
else
{
if (type == eParameter)
if (type == SymbolType::parameter)
{
FLDV_ fldv(type, tsid);
FLDV_ fldv{static_cast<int>(type), static_cast<unsigned int>(tsid)};
fldv.write(CompileCode, instruction_number);
}
else
{
FLDV_ fldv(type, tsid, lag);
FLDV_ fldv{static_cast<int>(type), static_cast<unsigned int>(tsid), lag};
fldv.write(CompileCode, instruction_number);
}
}
}
else
{
FLDSV_ fldsv(type, tsid);
FLDSV_ fldsv{static_cast<uint8_t>(type), static_cast<unsigned int>(tsid)};
fldsv.write(CompileCode, instruction_number);
}
}
@ -1102,21 +1102,21 @@ VariableNode::compile(ostream &CompileCode, unsigned int &instruction_number,
}
else
{
if (type == eParameter)
if (type == SymbolType::parameter)
{
FSTPV_ fstpv(type, tsid);
FSTPV_ fstpv{static_cast<int>(type), static_cast<unsigned int>(tsid)};
fstpv.write(CompileCode, instruction_number);
}
else
{
FSTPV_ fstpv(type, tsid, lag);
FSTPV_ fstpv{static_cast<int>(type), static_cast<unsigned int>(tsid), lag};
fstpv.write(CompileCode, instruction_number);
}
}
}
else
{
FSTPSV_ fstpsv(type, tsid);
FSTPSV_ fstpsv{static_cast<uint8_t>(type), static_cast<unsigned int>(tsid)};
fstpsv.write(CompileCode, instruction_number);
}
}
@ -1131,14 +1131,14 @@ VariableNode::computeTemporaryTerms(map<expr_t, int> &reference_count,
vector<vector<temporary_terms_t>> &v_temporary_terms,
int equation) const
{
if (type == eModelLocalVariable)
if (type == SymbolType::modelLocalVariable)
datatree.local_variables_table[symb_id]->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation);
}
void
VariableNode::collectVARLHSVariable(set<expr_t> &result) const
{
if (type == eEndogenous && lag == 0)
if (type == SymbolType::endogenous && lag == 0)
result.insert(const_cast<VariableNode *>(this));
else
{
@ -1152,7 +1152,7 @@ VariableNode::collectDynamicVariables(SymbolType type_arg, set<pair<int, int>> &
{
if (type == type_arg)
result.emplace(symb_id, lag);
if (type == eModelLocalVariable)
if (type == SymbolType::modelLocalVariable)
datatree.local_variables_table[symb_id]->collectDynamicVariables(type_arg, result);
}
@ -1171,7 +1171,7 @@ VariableNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr
the flag is equal to 2.
- an expression equal to the RHS if flag = 0 and equal to NULL elsewhere
*/
if (type == eEndogenous)
if (type == SymbolType::endogenous)
{
if (datatree.symbol_table.getTypeSpecificID(symb_id) == var_endo && lag == 0)
/* the endogenous variable */
@ -1181,7 +1181,7 @@ VariableNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr
}
else
{
if (type == eParameter)
if (type == SymbolType::parameter)
return { 0, datatree.AddVariableInternal(symb_id, 0) };
else
return { 0, datatree.AddVariableInternal(symb_id, lag) };
@ -1193,12 +1193,12 @@ VariableNode::getChainRuleDerivative(int deriv_id, const map<int, expr_t> &recur
{
switch (type)
{
case eEndogenous:
case eExogenous:
case eExogenousDet:
case eParameter:
case eTrend:
case eLogTrend:
case SymbolType::endogenous:
case SymbolType::exogenous:
case SymbolType::exogenousDet:
case SymbolType::parameter:
case SymbolType::trend:
case SymbolType::logTrend:
if (deriv_id == datatree.getDerivID(symb_id, lag))
return datatree.One;
else
@ -1224,19 +1224,19 @@ VariableNode::getChainRuleDerivative(int deriv_id, const map<int, expr_t> &recur
else
return datatree.Zero;
}
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->getChainRuleDerivative(deriv_id, recursive_variables);
case eModFileLocalVariable:
case SymbolType::modFileLocalVariable:
cerr << "ModFileLocalVariable is not derivable" << endl;
exit(EXIT_FAILURE);
case eStatementDeclaredVariable:
case SymbolType::statementDeclaredVariable:
cerr << "eStatementDeclaredVariable is not derivable" << endl;
exit(EXIT_FAILURE);
case eUnusedEndogenous:
case SymbolType::unusedEndogenous:
cerr << "eUnusedEndogenous is not derivable" << endl;
exit(EXIT_FAILURE);
case eExternalFunction:
case eEndogenousVAR:
case SymbolType::externalFunction:
case SymbolType::endogenousVAR:
cerr << "Impossible case!" << endl;
exit(EXIT_FAILURE);
}
@ -1255,26 +1255,26 @@ VariableNode::computeXrefs(EquationInfo &ei) const
{
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
ei.endo.emplace(symb_id, lag);
break;
case eExogenous:
case SymbolType::exogenous:
ei.exo.emplace(symb_id, lag);
break;
case eExogenousDet:
case SymbolType::exogenousDet:
ei.exo_det.emplace(symb_id, lag);
break;
case eParameter:
case SymbolType::parameter:
ei.param.emplace(symb_id, 0);
break;
case eTrend:
case eLogTrend:
case eModelLocalVariable:
case eModFileLocalVariable:
case eStatementDeclaredVariable:
case eUnusedEndogenous:
case eExternalFunction:
case eEndogenousVAR:
case SymbolType::trend:
case SymbolType::logTrend:
case SymbolType::modelLocalVariable:
case SymbolType::modFileLocalVariable:
case SymbolType::statementDeclaredVariable:
case SymbolType::unusedEndogenous:
case SymbolType::externalFunction:
case SymbolType::endogenousVAR:
break;
}
}
@ -1290,9 +1290,9 @@ VariableNode::maxEndoLead() const
{
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
return max(lag, 0);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->maxEndoLead();
default:
return 0;
@ -1304,9 +1304,9 @@ VariableNode::maxExoLead() const
{
switch (type)
{
case eExogenous:
case SymbolType::exogenous:
return max(lag, 0);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->maxExoLead();
default:
return 0;
@ -1318,9 +1318,9 @@ VariableNode::maxEndoLag() const
{
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
return max(-lag, 0);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->maxEndoLag();
default:
return 0;
@ -1332,9 +1332,9 @@ VariableNode::maxExoLag() const
{
switch (type)
{
case eExogenous:
case SymbolType::exogenous:
return max(-lag, 0);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->maxExoLag();
default:
return 0;
@ -1346,11 +1346,11 @@ VariableNode::maxLead() const
{
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
return lag;
case eExogenous:
case SymbolType::exogenous:
return lag;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->maxLead();
default:
return 0;
@ -1362,14 +1362,14 @@ VariableNode::VarMinLag() const
{
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
return -lag;
case eExogenous:
case SymbolType::exogenous:
if (lag > 0)
return -lag;
else
return 1; // Can have contemporaneus exog in VAR
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->VarMinLag();
default:
return 1;
@ -1381,11 +1381,11 @@ VariableNode::maxLag() const
{
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
return -lag;
case eExogenous:
case SymbolType::exogenous:
return -lag;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->maxLag();
default:
return 0;
@ -1453,13 +1453,13 @@ VariableNode::decreaseLeadsLags(int n) const
{
switch (type)
{
case eEndogenous:
case eExogenous:
case eExogenousDet:
case eTrend:
case eLogTrend:
case SymbolType::endogenous:
case SymbolType::exogenous:
case SymbolType::exogenousDet:
case SymbolType::trend:
case SymbolType::logTrend:
return datatree.AddVariable(symb_id, lag-n);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
return datatree.local_variables_table[symb_id]->decreaseLeadsLags(n);
default:
return const_cast<VariableNode *>(this);
@ -1481,12 +1481,12 @@ VariableNode::substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vecto
expr_t value;
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
if (lag <= 1)
return const_cast<VariableNode *>(this);
else
return createEndoLeadAuxiliaryVarForMyself(subst_table, neweqs);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
value = datatree.local_variables_table[symb_id];
if (value->maxEndoLead() <= 1)
return const_cast<VariableNode *>(this);
@ -1506,7 +1506,7 @@ VariableNode::substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector
int cur_lag;
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
if (lag >= -1)
return const_cast<VariableNode *>(this);
@ -1537,7 +1537,7 @@ VariableNode::substituteEndoLagGreaterThanTwo(subst_table_t &subst_table, vector
}
return substexpr;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
value = datatree.local_variables_table[symb_id];
if (value->maxEndoLag() <= 1)
return const_cast<VariableNode *>(this);
@ -1554,12 +1554,12 @@ VariableNode::substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode
expr_t value;
switch (type)
{
case eExogenous:
case SymbolType::exogenous:
if (lag <= 0)
return const_cast<VariableNode *>(this);
else
return createExoLeadAuxiliaryVarForMyself(subst_table, neweqs);
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
value = datatree.local_variables_table[symb_id];
if (value->maxExoLead() == 0)
return const_cast<VariableNode *>(this);
@ -1579,7 +1579,7 @@ VariableNode::substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *
int cur_lag;
switch (type)
{
case eExogenous:
case SymbolType::exogenous:
if (lag >= 0)
return const_cast<VariableNode *>(this);
@ -1610,7 +1610,7 @@ VariableNode::substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *
}
return substexpr;
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
value = datatree.local_variables_table[symb_id];
if (value->maxExoLag() == 0)
return const_cast<VariableNode *>(this);
@ -1633,7 +1633,7 @@ VariableNode::differentiateForwardVars(const vector<string> &subset, subst_table
expr_t value;
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
assert(lag <= 1);
if (lag <= 0
|| (subset.size() > 0
@ -1656,7 +1656,7 @@ VariableNode::differentiateForwardVars(const vector<string> &subset, subst_table
}
return datatree.AddPlus(datatree.AddVariable(symb_id, 0), diffvar);
}
case eModelLocalVariable:
case SymbolType::modelLocalVariable:
value = datatree.local_variables_table[symb_id];
if (value->maxEndoLead() <= 0)
return const_cast<VariableNode *>(this);
@ -1691,7 +1691,7 @@ VariableNode::containsPacExpectation() const
bool
VariableNode::containsEndogenous() const
{
if (type == eEndogenous)
if (type == SymbolType::endogenous)
return true;
else
return false;
@ -1700,15 +1700,15 @@ VariableNode::containsEndogenous() const
bool
VariableNode::containsExogenous() const
{
return (type == eExogenous || type == eExogenousDet);
return (type == SymbolType::exogenous || type == SymbolType::exogenousDet);
}
expr_t
VariableNode::replaceTrendVar() const
{
if (get_type() == eTrend)
if (get_type() == SymbolType::trend)
return datatree.One;
else if (get_type() == eLogTrend)
else if (get_type() == SymbolType::logTrend)
return datatree.Zero;
else
return const_cast<VariableNode *>(this);
@ -1745,12 +1745,12 @@ VariableNode::countDiffs() const
expr_t
VariableNode::removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const
{
if ((get_type() != eTrend && get_type() != eLogTrend) || get_lag() == 0)
if ((get_type() != SymbolType::trend && get_type() != SymbolType::logTrend) || get_lag() == 0)
return const_cast<VariableNode *>(this);
map<int, expr_t>::const_iterator it = trend_symbols_map.find(symb_id);
expr_t noTrendLeadLagNode = new VariableNode(datatree, it->first, 0);
bool log_trend = get_type() == eLogTrend;
bool log_trend = get_type() == SymbolType::logTrend;
expr_t trend = it->second;
if (get_lag() > 0)
@ -1823,7 +1823,7 @@ void
VariableNode::getEndosAndMaxLags(map<string, int> &model_endos_and_lags) const
{
string varname = datatree.symbol_table.getName(symb_id);
if (type == eEndogenous)
if (type == SymbolType::endogenous)
if (model_endos_and_lags.find(varname) == model_endos_and_lags.end())
model_endos_and_lags[varname] = min(model_endos_and_lags[varname], lag);
else
@ -1932,7 +1932,7 @@ UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
case oSteadyState:
if (datatree.isDynamic())
{
if (datatree.getTypeByDerivID(deriv_id) == eParameter)
if (datatree.getTypeByDerivID(deriv_id) == SymbolType::parameter)
{
auto *varg = dynamic_cast<VariableNode *>(arg);
if (varg == nullptr)
@ -1941,7 +1941,7 @@ UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
<< "standalone variables (like STEADY_STATE(y)) to be derivable w.r.t. parameters" << endl;
exit(EXIT_FAILURE);
}
if (datatree.symbol_table.getType(varg->symb_id) == eEndogenous)
if (datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous)
return datatree.AddSteadyStateParamDeriv(arg, datatree.getSymbIDByDerivID(deriv_id));
else
return datatree.Zero;
@ -1953,18 +1953,18 @@ UnaryOpNode::composeDerivatives(expr_t darg, int deriv_id)
return darg;
case oSteadyStateParamDeriv:
assert(datatree.isDynamic());
if (datatree.getTypeByDerivID(deriv_id) == eParameter)
if (datatree.getTypeByDerivID(deriv_id) == SymbolType::parameter)
{
auto *varg = dynamic_cast<VariableNode *>(arg);
assert(varg != nullptr);
assert(datatree.symbol_table.getType(varg->symb_id) == eEndogenous);
assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
return datatree.AddSteadyStateParam2ndDeriv(arg, param1_symb_id, datatree.getSymbIDByDerivID(deriv_id));
}
else
return datatree.Zero;
case oSteadyStateParam2ndDeriv:
assert(datatree.isDynamic());
if (datatree.getTypeByDerivID(deriv_id) == eParameter)
if (datatree.getTypeByDerivID(deriv_id) == SymbolType::parameter)
{
cerr << "3rd derivative of STEADY_STATE node w.r.t. three parameters not implemented" << endl;
exit(EXIT_FAILURE);
@ -2295,8 +2295,8 @@ UnaryOpNode::writeJsonOutput(ostream &output,
{
auto *varg = dynamic_cast<VariableNode *>(arg);
assert(varg != nullptr);
assert(datatree.symbol_table.getType(varg->symb_id) == eEndogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == eParameter);
assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
int tsid_param = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
output << "ss_param_deriv(" << tsid_endo+1 << "," << tsid_param+1 << ")";
@ -2306,9 +2306,9 @@ UnaryOpNode::writeJsonOutput(ostream &output,
{
auto *varg = dynamic_cast<VariableNode *>(arg);
assert(varg != nullptr);
assert(datatree.symbol_table.getType(varg->symb_id) == eEndogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == eParameter);
assert(datatree.symbol_table.getType(param2_symb_id) == eParameter);
assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
assert(datatree.symbol_table.getType(param2_symb_id) == SymbolType::parameter);
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
int tsid_param1 = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
int tsid_param2 = datatree.symbol_table.getTypeSpecificID(param2_symb_id);
@ -2461,8 +2461,8 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
{
auto *varg = dynamic_cast<VariableNode *>(arg);
assert(varg != nullptr);
assert(datatree.symbol_table.getType(varg->symb_id) == eEndogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == eParameter);
assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
int tsid_param = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
assert(IS_MATLAB(output_type));
@ -2473,9 +2473,9 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
{
auto *varg = dynamic_cast<VariableNode *>(arg);
assert(varg != nullptr);
assert(datatree.symbol_table.getType(varg->symb_id) == eEndogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == eParameter);
assert(datatree.symbol_table.getType(param2_symb_id) == eParameter);
assert(datatree.symbol_table.getType(varg->symb_id) == SymbolType::endogenous);
assert(datatree.symbol_table.getType(param1_symb_id) == SymbolType::parameter);
assert(datatree.symbol_table.getType(param2_symb_id) == SymbolType::parameter);
int tsid_endo = datatree.symbol_table.getTypeSpecificID(varg->symb_id);
int tsid_param1 = datatree.symbol_table.getTypeSpecificID(param1_symb_id);
int tsid_param2 = datatree.symbol_table.getTypeSpecificID(param2_symb_id);
@ -4541,19 +4541,19 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr
case oEqual:
if (!is_endogenous_present_1 && !is_endogenous_present_2)
{
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), datatree.AddMinus(expr_t_2, expr_t_1)) };
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(SymbolType::endogenous, var_endo), 0), datatree.AddMinus(expr_t_2, expr_t_1)) };
}
else if (is_endogenous_present_1 && is_endogenous_present_2)
{
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), datatree.Zero) };
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(SymbolType::endogenous, var_endo), 0), datatree.Zero) };
}
else if (!is_endogenous_present_1 && is_endogenous_present_2)
{
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), /*datatree.AddUMinus(expr_t_1)*/ expr_t_1) };
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(SymbolType::endogenous, var_endo), 0), /*datatree.AddUMinus(expr_t_1)*/ expr_t_1) };
}
else if (is_endogenous_present_1 && !is_endogenous_present_2)
{
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), expr_t_2) };
return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(SymbolType::endogenous, var_endo), 0), expr_t_2) };
}
break;
case oMax:
@ -5005,12 +5005,12 @@ BinaryOpNode::walkPacParametersHelper(const expr_t arg1, const expr_t arg2,
set<pair<int, pair<int, int>>> &ar_params_and_vars) const
{
set<int> params;
arg1->collectVariables(eParameter, params);
arg1->collectVariables(SymbolType::parameter, params);
if (params.size() != 1)
return;
set<pair<int, int>> endogs;
arg2->collectDynamicVariables(eEndogenous, endogs);
arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
if (endogs.size() == 1)
ar_params_and_vars.emplace(*(params.begin()), *(endogs.begin()));
else if (endogs.size() >= 2)
@ -5022,10 +5022,10 @@ BinaryOpNode::walkPacParametersHelper(const expr_t arg1, const expr_t arg2,
auto *test_arg2 = dynamic_cast<VariableNode *>(testarg2->get_arg2());
if (test_arg1 != nullptr && test_arg2 != nullptr && lhs.first != -1)
{
test_arg1->collectDynamicVariables(eEndogenous, endogs);
test_arg1->collectDynamicVariables(SymbolType::endogenous, endogs);
ec_params_and_vars.emplace(*(params.begin()), *(endogs.begin()));
endogs.clear();
test_arg2->collectDynamicVariables(eEndogenous, endogs);
test_arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
ec_params_and_vars.emplace(*(params.begin()), *(endogs.begin()));
}
}
@ -5047,7 +5047,7 @@ BinaryOpNode::walkPacParameters(bool &pac_encountered, pair<int, int> &lhs, set<
else if (op_code == oEqual)
{
set<pair<int, int>> general_lhs;
arg1->collectDynamicVariables(eEndogenous, general_lhs);
arg1->collectDynamicVariables(SymbolType::endogenous, general_lhs);
if (general_lhs.size() == 1)
lhs = *(general_lhs.begin());
}
@ -8460,7 +8460,7 @@ PacExpectationNode::substitutePacExpectation(map<const PacExpectationNode *, con
param_name_h0 << "h0_" << model_name
<< "_var_" << datatree.symbol_table.getName(*it)
<< "_lag_" << i;
int new_param_symb_id = datatree.symbol_table.addSymbol(param_name_h0.str(), eParameter);
int new_param_symb_id = datatree.symbol_table.addSymbol(param_name_h0.str(), SymbolType::parameter);
h0_indices.push_back(new_param_symb_id);
subExpr = datatree.AddPlus(subExpr,
datatree.AddTimes(datatree.AddVariable(new_param_symb_id),
@ -8475,7 +8475,7 @@ PacExpectationNode::substitutePacExpectation(map<const PacExpectationNode *, con
param_name_h1 << "h1_" << model_name
<< "_var_" << datatree.symbol_table.getName(*it)
<< "_lag_" << i;
int new_param_symb_id = datatree.symbol_table.addSymbol(param_name_h1.str(), eParameter);
int new_param_symb_id = datatree.symbol_table.addSymbol(param_name_h1.str(), SymbolType::parameter);
h1_indices.push_back(new_param_symb_id);
subExpr = datatree.AddPlus(subExpr,
datatree.AddTimes(datatree.AddVariable(new_param_symb_id),
@ -8486,7 +8486,7 @@ PacExpectationNode::substitutePacExpectation(map<const PacExpectationNode *, con
{
growth_param_index = datatree.symbol_table.addSymbol(model_name +
"_pac_growth_neutrality_correction",
eParameter);
SymbolType::parameter);
subExpr = datatree.AddPlus(subExpr,
datatree.AddTimes(datatree.AddVariable(growth_param_index),
datatree.AddVariable(growth_symb_id)));

View File

@ -83,8 +83,8 @@ ModFile::evalAllExpressions(bool warn_uninit, const bool nopreprocessoroutput)
for (int id = 0; id <= symbol_table.maxID(); id++)
{
SymbolType type = symbol_table.getType(id);
if ((type == eEndogenous || type == eExogenous || type == eExogenousDet
|| type == eParameter || type == eModelLocalVariable)
if ((type == SymbolType::endogenous || type == SymbolType::exogenous || type == SymbolType::exogenousDet
|| type == SymbolType::parameter || type == SymbolType::modelLocalVariable)
&& global_eval_context.find(id) == global_eval_context.end())
{
if (warn_uninit)
@ -214,7 +214,7 @@ ModFile::checkPass(bool nostrict, bool stochastic)
if (symbol_table.exists("dsge_prior_weight"))
{
if (symbol_table.getType("dsge_prior_weight") != eParameter)
if (symbol_table.getType("dsge_prior_weight") != SymbolType::parameter)
{
cerr << "ERROR: dsge_prior_weight may only be used as a parameter." << endl;
exit(EXIT_FAILURE);
@ -357,7 +357,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
set<int> unusedEndogs = dynamic_model.findUnusedEndogenous();
for (int unusedEndog : unusedEndogs)
{
symbol_table.changeType(unusedEndog, eUnusedEndogenous);
symbol_table.changeType(unusedEndog, SymbolType::unusedEndogenous);
warnings << "WARNING: '" << symbol_table.getName(unusedEndog)
<< "' not used in model block, removed by nostrict command-line option" << endl;
}
@ -554,7 +554,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
if (mod_file_struct.dsge_var_estimated || !mod_file_struct.dsge_var_calibrated.empty())
try
{
int sid = symbol_table.addSymbol("dsge_prior_weight", eParameter);
int sid = symbol_table.addSymbol("dsge_prior_weight", SymbolType::parameter);
if (!mod_file_struct.dsge_var_calibrated.empty())
addStatementAtFront(new InitParamStatement(sid,
expressions_tree.AddNonNegativeConstant(mod_file_struct.dsge_var_calibrated),

View File

@ -128,7 +128,7 @@ ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, boo
{
if (verbose)
cerr << "ERROR: Could not normalize the model. Variable "
<< symbol_table.getName(symbol_table.getID(eEndogenous, it - mate_map.begin()))
<< symbol_table.getName(symbol_table.getID(SymbolType::endogenous, it - mate_map.begin()))
<< " is not in the maximum cardinality matching." << endl;
check = false;
}
@ -208,12 +208,12 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian
contemporaneous_jacobian[{ it->first.first, it->first.second }] = 0;
try
{
if (first_derivatives.find({ it->first.first, getDerivID(symbol_table.getID(eEndogenous, it->first.second), 0) }) == first_derivatives.end())
first_derivatives[{ it->first.first, getDerivID(symbol_table.getID(eEndogenous, it->first.second), 0) }] = Zero;
if (first_derivatives.find({ it->first.first, getDerivID(symbol_table.getID(SymbolType::endogenous, it->first.second), 0) }) == first_derivatives.end())
first_derivatives[{ it->first.first, getDerivID(symbol_table.getID(SymbolType::endogenous, it->first.second), 0) }] = Zero;
}
catch (DataTree::UnknownDerivIDException &e)
{
cerr << "The variable " << symbol_table.getName(symbol_table.getID(eEndogenous, it->first.second))
cerr << "The variable " << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, it->first.second))
<< " does not appear at the current period (i.e. with no lead and no lag); this case is not handled by the 'block' option of the 'model' block." << endl;
exit(EXIT_FAILURE);
}
@ -238,7 +238,7 @@ ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
continue;
int symb_id = lhs->get_symb_id();
if (symbol_table.getType(symb_id) != eEndogenous)
if (symbol_table.getType(symb_id) != SymbolType::endogenous)
continue;
set<pair<int, int>> endo;
@ -260,7 +260,7 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
it != first_derivatives.end(); it++)
{
int deriv_id = it->first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
expr_t Id = it->second;
int eq = it->first.first;
@ -457,7 +457,7 @@ ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int>>, expr_t
derivative->second->collectEndogenous(result);
auto d_endo_variable = result.find({ var, 0 });
//Determine whether the equation could be evaluated rather than to be solved
if (lhs->isVariableNodeEqualTo(eEndogenous, Index_Var_IM[i], 0) && derivative->second->isNumConstNodeEqualTo(1))
if (lhs->isVariableNodeEqualTo(SymbolType::endogenous, Index_Var_IM[i], 0) && derivative->second->isNumConstNodeEqualTo(1))
{
Equation_Simulation_Type = E_EVALUATE;
}
@ -1120,7 +1120,7 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
// All used model local variables are automatically set as temporary variables
set<int> used_local_vars;
for (auto & equation : equations)
equation->collectVariables(eModelLocalVariable, used_local_vars);
equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
for (int used_local_var : used_local_vars)
{
@ -1459,7 +1459,7 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
const temporary_terms_t tt;
for (auto equation : equations)
equation->collectVariables(eModelLocalVariable, used_local_vars);
equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
output << "\"model_local_variables\": [";
bool printed = false;
@ -1621,7 +1621,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
int eq = first_derivative.first.first;
int symb = getSymbIDByDerivID(deriv_id);

View File

@ -127,9 +127,9 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type)
if (!all_values_required)
return unused;
if (type == eEndogenous)
if (type == SymbolType::endogenous)
unused = symbol_table.getEndogenous();
else if (type == eExogenous)
else if (type == SymbolType::exogenous)
unused = symbol_table.getExogenous();
else
{
@ -158,11 +158,11 @@ InitOrEndValStatement::writeInitValues(ostream &output) const
SymbolType type = symbol_table.getType(symb_id);
int tsid = symbol_table.getTypeSpecificID(symb_id) + 1;
if (type == eEndogenous)
if (type == SymbolType::endogenous)
output << "oo_.steady_state";
else if (type == eExogenous)
else if (type == SymbolType::exogenous)
output << "oo_.exo_steady_state";
else if (type == eExogenousDet)
else if (type == SymbolType::exogenousDet)
output << "oo_.exo_det_steady_state";
output << "( " << tsid << " ) = ";
@ -195,8 +195,8 @@ InitValStatement::InitValStatement(const init_values_t &init_values_arg,
void
InitValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
set<int> exogs = getUninitializedVariables(eExogenous);
set<int> endogs = getUninitializedVariables(eEndogenous);
set<int> exogs = getUninitializedVariables(SymbolType::exogenous);
set<int> endogs = getUninitializedVariables(SymbolType::endogenous);
if (endogs.size() > 0)
{
@ -259,8 +259,8 @@ EndValStatement::EndValStatement(const init_values_t &init_values_arg,
void
EndValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
set<int> exogs = getUninitializedVariables(eExogenous);
set<int> endogs = getUninitializedVariables(eEndogenous);
set<int> exogs = getUninitializedVariables(SymbolType::exogenous);
set<int> endogs = getUninitializedVariables(SymbolType::endogenous);
if (endogs.size() > 0)
{
@ -375,18 +375,18 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
SymbolType type = symbol_table.getType(symb_id);
// For a lag greater than 1 on endo, or for any exo, lookup for auxiliary variable
if ((type == eEndogenous && lag < 0) || type == eExogenous)
if ((type == SymbolType::endogenous && lag < 0) || type == SymbolType::exogenous)
{
try
{
// This function call must remain the 1st statement in this block
symb_id = symbol_table.searchAuxiliaryVars(symb_id, lag);
lag = 0;
type = eEndogenous;
type = SymbolType::endogenous;
}
catch (SymbolTable::SearchFailedException &e)
{
if (type == eEndogenous)
if (type == SymbolType::endogenous)
{
cerr << "HISTVAL: internal error of Dynare, please contact the developers";
exit(EXIT_FAILURE);
@ -398,11 +398,11 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
int tsid = symbol_table.getTypeSpecificID(symb_id) + 1;
if (type == eEndogenous)
if (type == SymbolType::endogenous)
output << "M_.endo_histval( " << tsid << ", M_.maximum_lag + " << lag << ") = ";
else if (type == eExogenous)
else if (type == SymbolType::exogenous)
output << "M_.exo_histval( " << tsid << ", M_.maximum_lag + " << lag << ") = ";
else if (type == eExogenousDet)
else if (type == SymbolType::exogenousDet)
output << "M_.exo_det_histval( " << tsid << ", M_.maximum_lag + " << lag << ") = ";
expression->writeOutput(output);
@ -494,7 +494,7 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename, bool min
const SymbolType type = symbol_table.getType(symb_id);
const int tsid = symbol_table.getTypeSpecificID(symb_id) + 1;
output << "options_.homotopy_values = vertcat(options_.homotopy_values, [ " << type << ", " << tsid << ", ";
output << "options_.homotopy_values = vertcat(options_.homotopy_values, [ " << static_cast<int>(type) << ", " << tsid << ", ";
if (expression1 != nullptr)
expression1->writeOutput(output);
else
@ -590,16 +590,16 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
{
switch (symbol_table.getType(it.first))
{
case eParameter:
case SymbolType::parameter:
output << "M_.params";
break;
case eEndogenous:
case SymbolType::endogenous:
output << "oo_.steady_state";
break;
case eExogenous:
case SymbolType::exogenous:
output << "oo_.exo_steady_state";
break;
case eExogenousDet:
case SymbolType::exogenousDet:
output << "oo_.exo_det_steady_state";
break;
default:

View File

@ -36,7 +36,7 @@ ParsingDriver::symbol_exists_and_is_not_modfile_local_or_external_function(const
SymbolType type = mod_file->symbol_table.getType(s);
return (type != eModFileLocalVariable && type != eExternalFunction);
return (type != SymbolType::modFileLocalVariable && type != SymbolType::externalFunction);
}
void
@ -59,7 +59,7 @@ ParsingDriver::check_symbol_is_parameter(string *name)
{
check_symbol_existence(*name);
int symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eParameter)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::parameter)
error(*name + " is not a parameter");
}
@ -208,7 +208,7 @@ ParsingDriver::declare_symbol(const string *name, SymbolType type, const string
void
ParsingDriver::declare_endogenous(string *name, string *tex_name, vector<pair<string *, string *> *> *partition_value)
{
declare_symbol(name, eEndogenous, tex_name, partition_value);
declare_symbol(name, SymbolType::endogenous, tex_name, partition_value);
delete name;
if (tex_name != nullptr)
delete tex_name;
@ -230,21 +230,21 @@ ParsingDriver::declare_var_endogenous(string *name)
if (mod_file->symbol_table.exists(*name))
{
SymbolType type = mod_file->symbol_table.getType(*name);
if (type != eEndogenous && type != eExogenous && type != eExogenousDet)
if (type != SymbolType::endogenous && type != SymbolType::exogenous && type != SymbolType::exogenousDet)
error("Symbol " + *name + " used in a VAR must be either endogenous or "
+"exogenous if it is also used elsewhere in the .mod file");
add_in_symbol_list(name);
return;
}
declare_symbol(name, eEndogenousVAR, nullptr, nullptr);
declare_symbol(name, SymbolType::endogenousVAR, nullptr, nullptr);
add_in_symbol_list(name);
}
void
ParsingDriver::declare_exogenous(string *name, string *tex_name, vector<pair<string *, string *> *> *partition_value)
{
declare_symbol(name, eExogenous, tex_name, partition_value);
declare_symbol(name, SymbolType::exogenous, tex_name, partition_value);
delete name;
if (tex_name != nullptr)
delete tex_name;
@ -263,7 +263,7 @@ ParsingDriver::declare_exogenous(string *name, string *tex_name, vector<pair<str
void
ParsingDriver::declare_exogenous_det(string *name, string *tex_name, vector<pair<string *, string *> *> *partition_value)
{
declare_symbol(name, eExogenousDet, tex_name, partition_value);
declare_symbol(name, SymbolType::exogenousDet, tex_name, partition_value);
delete name;
if (tex_name != nullptr)
delete tex_name;
@ -282,7 +282,7 @@ ParsingDriver::declare_exogenous_det(string *name, string *tex_name, vector<pair
void
ParsingDriver::declare_parameter(string *name, string *tex_name, vector<pair<string *, string *> *> *partition_value)
{
declare_symbol(name, eParameter, tex_name, partition_value);
declare_symbol(name, SymbolType::parameter, tex_name, partition_value);
delete name;
if (tex_name != nullptr)
delete tex_name;
@ -304,7 +304,7 @@ ParsingDriver::declare_statement_local_variable(string *name)
if (mod_file->symbol_table.exists(*name))
error("Symbol " + *name + " cannot be assigned within a statement "
+"while being assigned elsewhere in the modfile");
declare_symbol(name, eStatementDeclaredVariable, nullptr, nullptr);
declare_symbol(name, SymbolType::statementDeclaredVariable, nullptr, nullptr);
delete name;
}
@ -326,7 +326,7 @@ ParsingDriver::begin_trend()
void
ParsingDriver::declare_trend_var(bool log_trend, string *name, string *tex_name)
{
declare_symbol(name, log_trend ? eLogTrend : eTrend, tex_name, nullptr);
declare_symbol(name, log_trend ? SymbolType::logTrend : SymbolType::trend, tex_name, nullptr);
declared_trend_vars.push_back(mod_file->symbol_table.getID(*name));
delete name;
if (tex_name != nullptr)
@ -354,7 +354,7 @@ ParsingDriver::add_predetermined_variable(string *name)
try
{
int symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eEndogenous)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::endogenous)
error("Predetermined variables must be endogenous variables");
mod_file->symbol_table.markPredetermined(symb_id);
@ -373,13 +373,13 @@ ParsingDriver::add_equation_tags(string *key, string *value)
transform(key->begin(), key->end(), key->begin(), ::tolower);
if (key->compare("endogenous") == 0)
declare_or_change_type(eEndogenous, value);
declare_or_change_type(SymbolType::endogenous, value);
else if (key->compare("exogenous") == 0)
declare_or_change_type(eExogenous, value);
declare_or_change_type(SymbolType::exogenous, value);
else if (key->compare("parameter") == 0)
declare_or_change_type(eParameter, value);
declare_or_change_type(SymbolType::parameter, value);
if (!(key->compare("endogenous") == 0
|| key->compare("exogenous") == 0
@ -459,13 +459,13 @@ ParsingDriver::declare_or_change_type(SymbolType new_type, string *name)
{
switch (new_type)
{
case eEndogenous:
case SymbolType::endogenous:
declare_endogenous(new string(*name));
break;
case eExogenous:
case SymbolType::exogenous:
declare_exogenous(new string(*name));
break;
case eParameter:
case SymbolType::parameter:
declare_parameter(new string(*name));
break;
default:
@ -484,21 +484,21 @@ ParsingDriver::add_model_variable(int symb_id, int lag)
assert(symb_id >= 0);
SymbolType type = mod_file->symbol_table.getType(symb_id);
if (type == eModFileLocalVariable)
if (type == SymbolType::modFileLocalVariable)
error("Variable " + mod_file->symbol_table.getName(symb_id) +
" not allowed inside model declaration. Its scope is only outside model.");
if (type == eExternalFunction)
if (type == SymbolType::externalFunction)
error("Symbol " + mod_file->symbol_table.getName(symb_id) +
" is a function name external to Dynare. It cannot be used like a variable without input argument inside model.");
if (type == eModelLocalVariable && lag != 0)
if (type == SymbolType::modelLocalVariable && lag != 0)
error("Model local variable " + mod_file->symbol_table.getName(symb_id) + " cannot be given a lead or a lag.");
if (dynamic_cast<StaticModel *>(model_tree) != nullptr && lag != 0)
error("Leads and lags on variables are forbidden in 'planner_objective'.");
if (dynamic_cast<StaticModel *>(model_tree) != nullptr && type == eModelLocalVariable)
if (dynamic_cast<StaticModel *>(model_tree) != nullptr && type == SymbolType::modelLocalVariable)
error("Model local variable " + mod_file->symbol_table.getName(symb_id) + " cannot be used in 'planner_objective'.");
// It makes sense to allow a lead/lag on parameters: during steady state calibration, endogenous and parameters can be swapped
@ -510,17 +510,17 @@ ParsingDriver::add_expression_variable(string *name)
{
// If symbol doesn't exist, then declare it as a mod file local variable
if (!mod_file->symbol_table.exists(*name))
mod_file->symbol_table.addSymbol(*name, eModFileLocalVariable);
mod_file->symbol_table.addSymbol(*name, SymbolType::modFileLocalVariable);
// This check must come after the previous one!
if (mod_file->symbol_table.getType(*name) == eModelLocalVariable)
if (mod_file->symbol_table.getType(*name) == SymbolType::modelLocalVariable)
error("Variable " + *name + " not allowed outside model declaration. Its scope is only inside model.");
if (mod_file->symbol_table.getType(*name) == eTrend
|| mod_file->symbol_table.getType(*name) == eLogTrend)
if (mod_file->symbol_table.getType(*name) == SymbolType::trend
|| mod_file->symbol_table.getType(*name) == SymbolType::logTrend)
error("Variable " + *name + " not allowed outside model declaration, because it is a trend variable.");
if (mod_file->symbol_table.getType(*name) == eExternalFunction)
if (mod_file->symbol_table.getType(*name) == SymbolType::externalFunction)
error("Symbol '" + *name + "' is the name of a MATLAB/Octave function, and cannot be used as a variable.");
int symb_id = mod_file->symbol_table.getID(*name);
@ -561,7 +561,7 @@ ParsingDriver::end_nonstationary_var(bool log_deflator, expr_t deflator)
}
set<int> r;
deflator->collectVariables(eEndogenous, r);
deflator->collectVariables(SymbolType::endogenous, r);
for (int it : r)
if (dynamic_model->isNonstationary(it))
error("The deflator contains a non-stationary endogenous variable. This is not allowed. Please use only stationary endogenous and/or {log_}trend_vars.");
@ -767,9 +767,9 @@ ParsingDriver::init_val(string *name, expr_t rhs)
int symb_id = mod_file->symbol_table.getID(*name);
SymbolType type = mod_file->symbol_table.getType(symb_id);
if (type != eEndogenous
&& type != eExogenous
&& type != eExogenousDet)
if (type != SymbolType::endogenous
&& type != SymbolType::exogenous
&& type != SymbolType::exogenousDet)
error("initval/endval: " + *name + " should be an endogenous or exogenous variable");
init_values.emplace_back(symb_id, rhs);
@ -799,9 +799,9 @@ ParsingDriver::hist_val(string *name, string *lag, expr_t rhs)
int symb_id = mod_file->symbol_table.getID(*name);
SymbolType type = mod_file->symbol_table.getType(symb_id);
if (type != eEndogenous
&& type != eExogenous
&& type != eExogenousDet)
if (type != SymbolType::endogenous
&& type != SymbolType::exogenous
&& type != SymbolType::exogenousDet)
error("histval: " + *name + " should be an endogenous or exogenous variable");
int ilag = stoi(*lag);
@ -829,9 +829,9 @@ ParsingDriver::homotopy_val(string *name, expr_t val1, expr_t val2)
int symb_id = mod_file->symbol_table.getID(*name);
SymbolType type = mod_file->symbol_table.getType(symb_id);
if (type != eParameter
&& type != eExogenous
&& type != eExogenousDet)
if (type != SymbolType::parameter
&& type != SymbolType::exogenous
&& type != SymbolType::exogenousDet)
error("homotopy_val: " + *name + " should be a parameter or exogenous variable");
homotopy_values.emplace_back(symb_id, make_pair(val1, val2));
@ -926,7 +926,7 @@ ParsingDriver::differentiate_forward_vars_some()
it != mod_file->differentiate_forward_vars_subset.end(); ++it)
{
check_symbol_existence(*it);
if (mod_file->symbol_table.getType(*it) != eEndogenous)
if (mod_file->symbol_table.getType(*it) != SymbolType::endogenous)
error("Symbol " + *it + " is not an endogenous");
}
symbol_list.clear();
@ -1042,12 +1042,12 @@ ParsingDriver::add_det_shock(string *var, bool conditional_forecast)
if (conditional_forecast)
{
if (type != eEndogenous)
if (type != SymbolType::endogenous)
error("conditional_forecast_paths: shocks can only be applied to endogenous variables");
}
else
{
if (type != eExogenous && type != eExogenousDet)
if (type != SymbolType::exogenous && type != SymbolType::exogenousDet)
error("shocks: shocks can only be applied to exogenous variables");
}
@ -1569,7 +1569,7 @@ ParsingDriver::option_symbol_list(const string &name_option)
vector<string> shocks = symbol_list.get_symbols();
for (vector<string>::const_iterator it = shocks.begin();
it != shocks.end(); it++)
if (mod_file->symbol_table.getType(*it) != eExogenous)
if (mod_file->symbol_table.getType(*it) != SymbolType::exogenous)
error("Variables passed to irf_shocks must be exogenous. Caused by: " + *it);
}
@ -1578,7 +1578,7 @@ ParsingDriver::option_symbol_list(const string &name_option)
vector<string> parameters = symbol_list.get_symbols();
for (vector<string>::const_iterator it = parameters.begin();
it != parameters.end(); it++)
if (mod_file->symbol_table.getType(*it) != eParameter)
if (mod_file->symbol_table.getType(*it) != SymbolType::parameter)
error("Variables passed to the parameters option of the markov_switching statement must be parameters. Caused by: " + *it);
}
@ -1700,7 +1700,7 @@ ParsingDriver::add_estimated_params_element()
switch (estim_params.type)
{
case 1:
if (type != eEndogenous && type != eExogenous)
if (type != SymbolType::endogenous && type != SymbolType::exogenous)
error(estim_params.name + " must be an endogenous or an exogenous variable");
break;
case 2:
@ -1709,7 +1709,7 @@ ParsingDriver::add_estimated_params_element()
case 3:
check_symbol_existence(estim_params.name2);
SymbolType type2 = mod_file->symbol_table.getType(estim_params.name2);
if ((type != eEndogenous && type != eExogenous) || type != type2)
if ((type != SymbolType::endogenous && type != SymbolType::exogenous) || type != type2)
error(estim_params.name + " and " + estim_params.name2 + " must either be both endogenous variables or both exogenous");
break;
}
@ -1744,7 +1744,7 @@ ParsingDriver::add_osr_params_element()
{
check_symbol_existence(osr_params.name);
SymbolType type = mod_file->symbol_table.getType(osr_params.name);
if (type != eParameter)
if (type != SymbolType::parameter)
error(osr_params.name + " must be a parameter to be used in the osr_bounds block");
osr_params_list.push_back(osr_params);
osr_params.init(*data_tree);
@ -1830,7 +1830,7 @@ ParsingDriver::check_symbol_is_statement_variable(string *name)
{
check_symbol_existence(*name);
int symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eStatementDeclaredVariable)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::statementDeclaredVariable)
error(*name + " is not a variable assigned in a statement");
}
@ -2012,9 +2012,9 @@ ParsingDriver::check_symbol_is_endogenous_or_exogenous(string *name)
int symb_id = mod_file->symbol_table.getID(*name);
switch (mod_file->symbol_table.getType(symb_id))
{
case eEndogenous:
case eExogenous:
case eExogenousDet:
case SymbolType::endogenous:
case SymbolType::exogenous:
case SymbolType::exogenousDet:
break;
default:
error(*name + " is neither endogenous or exogenous.");
@ -2028,8 +2028,8 @@ ParsingDriver::check_symbol_is_exogenous(string *name)
int symb_id = mod_file->symbol_table.getID(*name);
switch (mod_file->symbol_table.getType(symb_id))
{
case eExogenous:
case eExogenousDet:
case SymbolType::exogenous:
case SymbolType::exogenousDet:
break;
default:
error(*name + " is not exogenous.");
@ -2174,7 +2174,7 @@ ParsingDriver::add_varobs(string *name)
{
check_symbol_existence(*name);
int symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eEndogenous)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::endogenous)
error("varobs: " + *name + " is not an endogenous variable");
mod_file->symbol_table.addObservedVariable(symb_id);
delete name;
@ -2192,7 +2192,7 @@ ParsingDriver::add_varexobs(string *name)
{
check_symbol_existence(*name);
int symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eExogenous)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::exogenous)
error("varexobs: " + *name + " is not an exogenous variable");
mod_file->symbol_table.addObservedExogenousVariable(symb_id);
delete name;
@ -2219,7 +2219,7 @@ void
ParsingDriver::set_optim_weights(string *name, expr_t value)
{
check_symbol_existence(*name);
if (mod_file->symbol_table.getType(*name) != eEndogenous)
if (mod_file->symbol_table.getType(*name) != SymbolType::endogenous)
error("optim_weights: " + *name + " isn't an endogenous variable");
if (var_weights.find(*name) != var_weights.end())
error("optim_weights: " + *name + " declared twice");
@ -2231,11 +2231,11 @@ void
ParsingDriver::set_optim_weights(string *name1, string *name2, expr_t value)
{
check_symbol_existence(*name1);
if (mod_file->symbol_table.getType(*name1) != eEndogenous)
if (mod_file->symbol_table.getType(*name1) != SymbolType::endogenous)
error("optim_weights: " + *name1 + " isn't an endogenous variable");
check_symbol_existence(*name2);
if (mod_file->symbol_table.getType(*name2) != eEndogenous)
if (mod_file->symbol_table.getType(*name2) != SymbolType::endogenous)
error("optim_weights: " + *name2 + " isn't an endogenous variable");
pair<string, string> covar_key(*name1, *name2);
@ -2657,7 +2657,7 @@ ParsingDriver::add_model_equal_with_zero_rhs(expr_t arg)
void
ParsingDriver::declare_model_local_variable(string *name, string *tex_name)
{
declare_symbol(name, eModelLocalVariable, tex_name, nullptr);
declare_symbol(name, SymbolType::modelLocalVariable, tex_name, nullptr);
delete name;
if (tex_name != nullptr)
delete tex_name;
@ -2669,13 +2669,13 @@ ParsingDriver::declare_and_init_model_local_variable(string *name, expr_t rhs)
int symb_id;
try
{
symb_id = mod_file->symbol_table.addSymbol(*name, eModelLocalVariable);
symb_id = mod_file->symbol_table.addSymbol(*name, SymbolType::modelLocalVariable);
}
catch (SymbolTable::AlreadyDeclaredException &e)
{
// It can have already been declared in a steady_state_model block, check that it is indeed a ModelLocalVariable
symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eModelLocalVariable)
if (mod_file->symbol_table.getType(symb_id) != SymbolType::modelLocalVariable)
error(*name + " has wrong type or was already used on the right-hand side. You cannot use it on the left-hand side of a pound ('#') expression");
}
@ -3070,7 +3070,7 @@ ParsingDriver::external_function_option(const string &name_option, const string
{
if (opt.empty())
error("An argument must be passed to the 'name' option of the external_function() statement.");
declare_symbol(&opt, eExternalFunction, nullptr, nullptr);
declare_symbol(&opt, SymbolType::externalFunction, nullptr, nullptr);
current_external_function_id = mod_file->symbol_table.getID(opt);
}
else if (name_option == "first_deriv_provided")
@ -3079,7 +3079,7 @@ ParsingDriver::external_function_option(const string &name_option, const string
current_external_function_options.firstDerivSymbID = eExtFunSetButNoNameProvided;
else
{
declare_symbol(&opt, eExternalFunction, nullptr, nullptr);
declare_symbol(&opt, SymbolType::externalFunction, nullptr, nullptr);
current_external_function_options.firstDerivSymbID = mod_file->symbol_table.getID(opt);
}
}
@ -3089,7 +3089,7 @@ ParsingDriver::external_function_option(const string &name_option, const string
current_external_function_options.secondDerivSymbID = eExtFunSetButNoNameProvided;
else
{
declare_symbol(&opt, eExternalFunction, nullptr, nullptr);
declare_symbol(&opt, SymbolType::externalFunction, nullptr, nullptr);
current_external_function_options.secondDerivSymbID = mod_file->symbol_table.getID(opt);
}
}
@ -3180,7 +3180,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
{
expr_t nid;
if (mod_file->symbol_table.exists(*function_name))
if (mod_file->symbol_table.getType(*function_name) != eExternalFunction)
if (mod_file->symbol_table.getType(*function_name) != SymbolType::externalFunction)
if (!in_model_block)
{
if (stack_external_function_args.top().size() > 0)
@ -3238,7 +3238,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
error("To use an external function (" + *function_name +
") within the model block, you must first declare it via the external_function() statement.");
}
declare_symbol(function_name, eExternalFunction, nullptr, nullptr);
declare_symbol(function_name, SymbolType::externalFunction, nullptr, nullptr);
current_external_function_options.nargs = stack_external_function_args.top().size();
mod_file->external_functions_table.addExternalFunction(mod_file->symbol_table.getID(*function_name),
current_external_function_options, in_model_block);
@ -3304,11 +3304,11 @@ ParsingDriver::add_steady_state_model_equal(string *varname, expr_t expr)
catch (SymbolTable::UnknownSymbolNameException &e)
{
// Unknown symbol, declare it as a ModFileLocalVariable
id = mod_file->symbol_table.addSymbol(*varname, eModFileLocalVariable);
id = mod_file->symbol_table.addSymbol(*varname, SymbolType::modFileLocalVariable);
}
SymbolType type = mod_file->symbol_table.getType(id);
if (type != eEndogenous && type != eModFileLocalVariable && type != eParameter)
if (type != SymbolType::endogenous && type != SymbolType::modFileLocalVariable && type != SymbolType::parameter)
error(*varname + " has incorrect type");
mod_file->steady_state_model.addDefinition(id, expr);
@ -3332,10 +3332,10 @@ ParsingDriver::add_steady_state_model_equal_multiple(expr_t expr)
catch (SymbolTable::UnknownSymbolNameException &e)
{
// Unknown symbol, declare it as a ModFileLocalVariable
id = mod_file->symbol_table.addSymbol(symb, eModFileLocalVariable);
id = mod_file->symbol_table.addSymbol(symb, SymbolType::modFileLocalVariable);
}
SymbolType type = mod_file->symbol_table.getType(id);
if (type != eEndogenous && type != eModFileLocalVariable && type != eParameter)
if (type != SymbolType::endogenous && type != SymbolType::modFileLocalVariable && type != SymbolType::parameter)
error(symb + " has incorrect type");
ids.push_back(id);
}
@ -3385,13 +3385,13 @@ ParsingDriver::add_moment_calibration_item(string *endo1, string *endo2, string
check_symbol_existence(*endo1);
c.endo1 = mod_file->symbol_table.getID(*endo1);
if (mod_file->symbol_table.getType(*endo1) != eEndogenous)
if (mod_file->symbol_table.getType(*endo1) != SymbolType::endogenous)
error("Variable " + *endo1 + " is not an endogenous.");
delete endo1;
check_symbol_existence(*endo2);
c.endo2 = mod_file->symbol_table.getID(*endo2);
if (mod_file->symbol_table.getType(*endo2) != eEndogenous)
if (mod_file->symbol_table.getType(*endo2) != SymbolType::endogenous)
error("Variable " + *endo2 + " is not an endogenous.");
delete endo2;
@ -3423,7 +3423,7 @@ ParsingDriver::add_irf_calibration_item(string *endo, string *periods, string *e
check_symbol_existence(*endo);
c.endo = mod_file->symbol_table.getID(*endo);
if (mod_file->symbol_table.getType(*endo) != eEndogenous)
if (mod_file->symbol_table.getType(*endo) != SymbolType::endogenous)
error("Variable " + *endo + " is not an endogenous.");
delete endo;
@ -3432,7 +3432,7 @@ ParsingDriver::add_irf_calibration_item(string *endo, string *periods, string *e
check_symbol_existence(*exo);
c.exo = mod_file->symbol_table.getID(*exo);
if (mod_file->symbol_table.getType(*exo) != eExogenous)
if (mod_file->symbol_table.getType(*exo) != SymbolType::exogenous)
error("Variable " + *endo + " is not an exogenous.");
delete exo;
@ -3544,7 +3544,7 @@ ParsingDriver::add_ramsey_constraint(const string *name, BinaryOpcode op_code, c
int symb_id = mod_file->symbol_table.getID(*name);
SymbolType type = mod_file->symbol_table.getType(symb_id);
if (type != eEndogenous)
if (type != SymbolType::endogenous)
error("ramsey_constraints: " + *name + " should be an endogenous variable");
RamseyConstraintsStatement::Constraint C;
@ -3563,7 +3563,7 @@ ParsingDriver::add_shock_group_element(string *name)
int symb_id = mod_file->symbol_table.getID(*name);
SymbolType type = mod_file->symbol_table.getType(symb_id);
if (type != eExogenous)
if (type != SymbolType::exogenous)
error("shock_groups: " + *name + " should be an exogenous variable");
shock_group.push_back(*name);

View File

@ -43,7 +43,7 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
for (const auto & det_shock : det_shocks)
{
int id = symbol_table.getTypeSpecificID(det_shock.first) + 1;
bool exo_det = (symbol_table.getType(det_shock.first) == eExogenousDet);
bool exo_det = (symbol_table.getType(det_shock.first) == SymbolType::exogenousDet);
for (size_t i = 0; i < det_shock.second.size(); i++)
{
@ -220,10 +220,10 @@ ShocksStatement::writeVarOrStdShock(ostream &output, var_and_std_shocks_t::const
bool stddev) const
{
SymbolType type = symbol_table.getType(it->first);
assert(type == eExogenous || symbol_table.isObservedVariable(it->first));
assert(type == SymbolType::exogenous || symbol_table.isObservedVariable(it->first));
int id;
if (type == eExogenous)
if (type == SymbolType::exogenous)
{
output << "M_.Sigma_e(";
id = symbol_table.getTypeSpecificID(it->first) + 1;
@ -261,11 +261,11 @@ ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t:
{
SymbolType type1 = symbol_table.getType(it->first.first);
SymbolType type2 = symbol_table.getType(it->first.second);
assert((type1 == eExogenous && type2 == eExogenous)
assert((type1 == SymbolType::exogenous && type2 == SymbolType::exogenous)
|| (symbol_table.isObservedVariable(it->first.first) && symbol_table.isObservedVariable(it->first.second)));
string matrix, corr_matrix;
int id1, id2;
if (type1 == eExogenous)
if (type1 == SymbolType::exogenous)
{
matrix = "M_.Sigma_e";
corr_matrix = "M_.Correlation_matrix";
@ -319,7 +319,7 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
Also Determine if there is a calibrated measurement error */
for (auto var_shock : var_shocks)
{
if (symbol_table.getType(var_shock.first) != eExogenous
if (symbol_table.getType(var_shock.first) != SymbolType::exogenous
&& !symbol_table.isObservedVariable(var_shock.first))
{
cerr << "shocks: setting a variance on '"
@ -330,7 +330,7 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
for (auto std_shock : std_shocks)
{
if (symbol_table.getType(std_shock.first) != eExogenous
if (symbol_table.getType(std_shock.first) != SymbolType::exogenous
&& !symbol_table.isObservedVariable(std_shock.first))
{
cerr << "shocks: setting a standard error on '"
@ -344,8 +344,8 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
int symb_id1 = covar_shock.first.first;
int symb_id2 = covar_shock.first.second;
if (!((symbol_table.getType(symb_id1) == eExogenous
&& symbol_table.getType(symb_id2) == eExogenous)
if (!((symbol_table.getType(symb_id1) == SymbolType::exogenous
&& symbol_table.getType(symb_id2) == SymbolType::exogenous)
|| (symbol_table.isObservedVariable(symb_id1)
&& symbol_table.isObservedVariable(symb_id2))))
{
@ -361,8 +361,8 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
int symb_id1 = corr_shock.first.first;
int symb_id2 = corr_shock.first.second;
if (!((symbol_table.getType(symb_id1) == eExogenous
&& symbol_table.getType(symb_id2) == eExogenous)
if (!((symbol_table.getType(symb_id1) == SymbolType::exogenous
&& symbol_table.getType(symb_id2) == SymbolType::exogenous)
|| (symbol_table.isObservedVariable(symb_id1)
&& symbol_table.isObservedVariable(symb_id2))))
{
@ -378,13 +378,13 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
// Fill in mod_file_struct.parameters_with_shocks_values (related to #469)
for (auto var_shock : var_shocks)
var_shock.second->collectVariables(eParameter, mod_file_struct.parameters_within_shocks_values);
var_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
for (auto std_shock : std_shocks)
std_shock.second->collectVariables(eParameter, mod_file_struct.parameters_within_shocks_values);
std_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
for (const auto & covar_shock : covar_shocks)
covar_shock.second->collectVariables(eParameter, mod_file_struct.parameters_within_shocks_values);
covar_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
for (const auto & corr_shock : corr_shocks)
corr_shock.second->collectVariables(eParameter, mod_file_struct.parameters_within_shocks_values);
corr_shock.second->collectVariables(SymbolType::parameter, mod_file_struct.parameters_within_shocks_values);
}

View File

@ -40,7 +40,7 @@ StaticModel::StaticModel(SymbolTable &symbol_table_arg,
void
StaticModel::compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, map_idx_t &map_idx, temporary_terms_t temporary_terms) const
{
auto it = first_derivatives.find({ eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), 0) });
auto it = first_derivatives.find({ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, symb_id), 0) });
if (it != first_derivatives.end())
(it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
else
@ -294,7 +294,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &basename) const
int variable_ID = getBlockVariableID(block, i);
int equation_ID = getBlockEquationID(block, i);
EquationType equ_type = getBlockEquationType(block, i);
string sModel = symbol_table.getName(symbol_table.getID(eEndogenous, variable_ID));
string sModel = symbol_table.getName(symbol_table.getID(SymbolType::endogenous, variable_ID));
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2();
@ -376,7 +376,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &basename) const
expr_t id = it->second.second;
output << " g1(" << eq+1-block_recursive << ", " << var+1-block_recursive << ") = ";
id->writeOutput(output, local_output_type, local_temporary_terms, {});
output << "; % variable=" << symbol_table.getName(symbol_table.getID(eEndogenous, varr))
output << "; % variable=" << symbol_table.getName(symbol_table.getID(SymbolType::endogenous, varr))
<< "(" << 0
<< ") " << varr+1
<< ", equation=" << eqr+1 << endl;
@ -455,7 +455,7 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
expr_t d1 = first_derivative.second;
unsigned int eq = first_derivative.first.first;
@ -485,7 +485,7 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
{
FLDSU_ fldsu(it->second);
fldsu.write(code_file, instruction_number);
FLDSV_ fldsv(eEndogenous, it->first);
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), it->first};
fldsv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
fbinary.write(code_file, instruction_number);
@ -522,7 +522,7 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
expr_t d1 = first_derivative.second;
unsigned int eq = first_derivative.first.first;
@ -786,7 +786,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
{
FLDSU_ fldsu(Uf[v].Ufl->u);
fldsu.write(code_file, instruction_number);
FLDSV_ fldsv(eEndogenous, Uf[v].Ufl->var);
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), Uf[v].Ufl->var};
fldsv.write(code_file, instruction_number);
FBINARY_ fbinary(oTimes);
@ -1025,7 +1025,7 @@ StaticModel::collect_first_order_derivatives_endogenous()
map<pair<int, pair<int, int >>, expr_t> endo_derivatives;
for (auto & first_derivative : first_derivatives)
{
if (getTypeByDerivID(first_derivative.first.second) == eEndogenous)
if (getTypeByDerivID(first_derivative.first.second) == SymbolType::endogenous)
{
int eq = first_derivative.first.first;
int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first.second));
@ -1061,7 +1061,7 @@ StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms
for (int i = 0; i < symbol_table.endo_nbr(); i++)
{
int id = symbol_table.getID(eEndogenous, i);
int id = symbol_table.getID(SymbolType::endogenous, i);
// if (!symbol_table.isAuxiliaryVariableButNotMultiplier(id))
vars.insert(getDerivID(id, 0));
}
@ -2111,7 +2111,7 @@ StaticModel::writeOutput(ostream &output, bool block) const
for (const auto & first_derivative : first_derivatives)
{
int deriv_id = first_derivative.first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous)
if (getTypeByDerivID(deriv_id) == SymbolType::endogenous)
{
int eq = first_derivative.first.first;
int symb = getSymbIDByDerivID(deriv_id);
@ -2132,9 +2132,9 @@ SymbolType
StaticModel::getTypeByDerivID(int deriv_id) const noexcept(false)
{
if (deriv_id < symbol_table.endo_nbr())
return eEndogenous;
return SymbolType::endogenous;
else if (deriv_id < symbol_table.endo_nbr() + symbol_table.param_nbr())
return eParameter;
return SymbolType::parameter;
else
throw UnknownDerivIDException();
}
@ -2149,9 +2149,9 @@ int
StaticModel::getSymbIDByDerivID(int deriv_id) const noexcept(false)
{
if (deriv_id < symbol_table.endo_nbr())
return symbol_table.getID(eEndogenous, deriv_id);
return symbol_table.getID(SymbolType::endogenous, deriv_id);
else if (deriv_id < symbol_table.endo_nbr() + symbol_table.param_nbr())
return symbol_table.getID(eParameter, deriv_id - symbol_table.endo_nbr());
return symbol_table.getID(SymbolType::parameter, deriv_id - symbol_table.endo_nbr());
else
throw UnknownDerivIDException();
}
@ -2159,9 +2159,9 @@ StaticModel::getSymbIDByDerivID(int deriv_id) const noexcept(false)
int
StaticModel::getDerivID(int symb_id, int lag) const noexcept(false)
{
if (symbol_table.getType(symb_id) == eEndogenous)
if (symbol_table.getType(symb_id) == SymbolType::endogenous)
return symbol_table.getTypeSpecificID(symb_id);
else if (symbol_table.getType(symb_id) == eParameter)
else if (symbol_table.getType(symb_id) == SymbolType::parameter)
return symbol_table.getTypeSpecificID(symb_id) + symbol_table.endo_nbr();
else
return -1;
@ -2245,9 +2245,9 @@ StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives)
for (int i = 0; i < block_nb_recursives; i++)
{
if (getBlockEquationType(block, i) == E_EVALUATE_S)
recursive_variables[getDerivID(symbol_table.getID(eEndogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationRenormalizedExpr(block, i);
recursive_variables[getDerivID(symbol_table.getID(SymbolType::endogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationRenormalizedExpr(block, i);
else
recursive_variables[getDerivID(symbol_table.getID(eEndogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationExpr(block, i);
recursive_variables[getDerivID(symbol_table.getID(SymbolType::endogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationExpr(block, i);
}
map<pair<pair<int, pair<int, int>>, pair<int, int>>, int> Derivatives = get_Derivatives(block);
map<pair<pair<int, pair<int, int>>, pair<int, int>>, int>::const_iterator it = Derivatives.begin();
@ -2262,15 +2262,15 @@ StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives)
int eqr = it_l.second.first;
int varr = it_l.second.second;
if (Deriv_type == 0)
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = first_derivatives[{ eqr, getDerivID(symbol_table.getID(eEndogenous, varr), lag) }];
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = first_derivatives[{ eqr, getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag) }];
else if (Deriv_type == 1)
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables);
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag), recursive_variables);
else if (Deriv_type == 2)
{
if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursives)
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables);
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag), recursive_variables);
else
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables);
first_chain_rule_derivatives[{ eqr, { varr, lag } }] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), lag), recursive_variables);
}
tmp_derivatives.emplace_back(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))]));
}
@ -2281,9 +2281,9 @@ StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives)
for (int i = 0; i < block_nb_recursives; i++)
{
if (getBlockEquationType(block, i) == E_EVALUATE_S)
recursive_variables[getDerivID(symbol_table.getID(eEndogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationRenormalizedExpr(block, i);
recursive_variables[getDerivID(symbol_table.getID(SymbolType::endogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationRenormalizedExpr(block, i);
else
recursive_variables[getDerivID(symbol_table.getID(eEndogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationExpr(block, i);
recursive_variables[getDerivID(symbol_table.getID(SymbolType::endogenous, getBlockVariableID(block, i)), 0)] = getBlockEquationExpr(block, i);
}
for (int eq = block_nb_recursives; eq < block_size; eq++)
{
@ -2291,7 +2291,7 @@ StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives)
for (int var = block_nb_recursives; var < block_size; var++)
{
int varr = getBlockVariableID(block, var);
expr_t d1 = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), 0), recursive_variables);
expr_t d1 = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(SymbolType::endogenous, varr), 0), recursive_variables);
if (d1 == Zero)
continue;
first_chain_rule_derivatives[{ eqr, { varr, 0 } }] = d1;
@ -2336,10 +2336,10 @@ StaticModel::collect_block_first_order_derivatives()
endo_max_leadlag_block[block_eq] = { 0, 0 };
derivative_t tmp_derivative;
lag_var_t lag_var;
if (getTypeByDerivID(first_derivative.first.second) == eEndogenous && block_eq == block_var)
if (getTypeByDerivID(first_derivative.first.second) == SymbolType::endogenous && block_eq == block_var)
{
tmp_derivative = derivative_endo[block_eq];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eEndogenous, var), lag) }];
tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(SymbolType::endogenous, var), lag) }];
derivative_endo[block_eq] = tmp_derivative;
}
}

View File

@ -32,9 +32,9 @@ SteadyStateModel::addDefinition(int symb_id, expr_t expr)
{
AddVariable(symb_id); // Create the variable node to be used in write method
assert(symbol_table.getType(symb_id) == eEndogenous
|| symbol_table.getType(symb_id) == eModFileLocalVariable
|| symbol_table.getType(symb_id) == eParameter);
assert(symbol_table.getType(symb_id) == SymbolType::endogenous
|| symbol_table.getType(symb_id) == SymbolType::modFileLocalVariable
|| symbol_table.getType(symb_id) == SymbolType::parameter);
// Add the variable
vector<int> v;
@ -48,9 +48,9 @@ SteadyStateModel::addMultipleDefinitions(const vector<int> &symb_ids, expr_t exp
for (int symb_id : symb_ids)
{
AddVariable(symb_id); // Create the variable nodes to be used in write method
assert(symbol_table.getType(symb_id) == eEndogenous
|| symbol_table.getType(symb_id) == eModFileLocalVariable
|| symbol_table.getType(symb_id) == eParameter);
assert(symbol_table.getType(symb_id) == SymbolType::endogenous
|| symbol_table.getType(symb_id) == SymbolType::modFileLocalVariable
|| symbol_table.getType(symb_id) == SymbolType::parameter);
}
def_table.emplace_back(symb_ids, expr);
}
@ -79,8 +79,8 @@ SteadyStateModel::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
{
set<int> used_symbols;
const expr_t &expr = i.second;
expr->collectVariables(eEndogenous, used_symbols);
expr->collectVariables(eModFileLocalVariable, used_symbols);
expr->collectVariables(SymbolType::endogenous, used_symbols);
expr->collectVariables(SymbolType::modFileLocalVariable, used_symbols);
for (int used_symbol : used_symbols)
if (find(so_far_defined.begin(), so_far_defined.end(), used_symbol)
== so_far_defined.end())

View File

@ -112,19 +112,19 @@ SymbolTable::freeze() noexcept(false)
int tsi;
switch (getType(i))
{
case eEndogenous:
case SymbolType::endogenous:
tsi = endo_ids.size();
endo_ids.push_back(i);
break;
case eExogenous:
case SymbolType::exogenous:
tsi = exo_ids.size();
exo_ids.push_back(i);
break;
case eExogenousDet:
case SymbolType::exogenousDet:
tsi = exo_det_ids.size();
exo_det_ids.push_back(i);
break;
case eParameter:
case SymbolType::parameter:
tsi = param_ids.size();
param_ids.push_back(i);
break;
@ -166,22 +166,22 @@ SymbolTable::getID(SymbolType type, int tsid) const noexcept(false)
switch (type)
{
case eEndogenous:
case SymbolType::endogenous:
if (tsid < 0 || tsid >= (int) endo_ids.size())
throw UnknownTypeSpecificIDException(tsid, type);
else
return endo_ids[tsid];
case eExogenous:
case SymbolType::exogenous:
if (tsid < 0 || tsid >= (int) exo_ids.size())
throw UnknownTypeSpecificIDException(tsid, type);
else
return exo_ids[tsid];
case eExogenousDet:
case SymbolType::exogenousDet:
if (tsid < 0 || tsid >= (int) exo_det_ids.size())
throw UnknownTypeSpecificIDException(tsid, type);
else
return exo_det_ids[tsid];
case eParameter:
case SymbolType::parameter:
if (tsid < 0 || tsid >= (int) param_ids.size())
throw UnknownTypeSpecificIDException(tsid, type);
else
@ -222,7 +222,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
output << "M_.exo_names(" << id+1 << ") = {'" << getName(exo_ids[id]) << "'};" << endl
<< "M_.exo_names_tex(" << id+1 << ") = {'" << getTeXName(exo_ids[id]) << "'};" << endl
<< "M_.exo_names_long(" << id+1 << ") = {'" << getLongName(exo_ids[id]) << "'};" << endl;
map<string, map<int, string>> partitions = getPartitionsForType(eExogenous);
map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::exogenous);
for (map<string, map<int, string>>::const_iterator it = partitions.begin();
it != partitions.end(); it++)
if (it->first != "long_name")
@ -251,7 +251,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
<< "M_.exo_det_names_tex(" << id+1 << ") = {'" << getTeXName(exo_det_ids[id]) << "'};" << endl
<< "M_.exo_det_names_long(" << id+1 << ") = {'" << getLongName(exo_det_ids[id]) << "'};" << endl;
output << "M_.exo_det_partitions = struct();" << endl;
map<string, map<int, string>> partitions = getPartitionsForType(eExogenousDet);
map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::exogenousDet);
for (map<string, map<int, string>>::const_iterator it = partitions.begin();
it != partitions.end(); it++)
if (it->first != "long_name")
@ -280,7 +280,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
<< "M_.endo_names_tex(" << id+1 << ") = {'" << getTeXName(endo_ids[id]) << "'};" << endl
<< "M_.endo_names_long(" << id+1 << ") = {'" << getLongName(endo_ids[id]) << "'};" << endl;
output << "M_.endo_partitions = struct();" << endl;
map<string, map<int, string>> partitions = getPartitionsForType(eEndogenous);
map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::endogenous);
for (map<string, map<int, string>>::const_iterator it = partitions.begin();
it != partitions.end(); it++)
if (it->first != "long_name")
@ -313,7 +313,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
output << "options_.dsge_var = 1;" << endl;
}
output << "M_.param_partitions = struct();" << endl;
map<string, map<int, string>> partitions = getPartitionsForType(eParameter);
map<string, map<int, string>> partitions = getPartitionsForType(SymbolType::parameter);
for (map<string, map<int, string>>::const_iterator it = partitions.begin();
it != partitions.end(); it++)
if (it->first != "long_name")
@ -627,7 +627,7 @@ SymbolTable::addLeadAuxiliaryVarInternal(bool endo, int index, expr_t expr_arg)
int symb_id;
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -653,7 +653,7 @@ SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_le
int symb_id;
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -701,7 +701,7 @@ SymbolTable::addExpectationAuxiliaryVar(int information_set, int index, expr_t e
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -724,7 +724,7 @@ SymbolTable::addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -747,7 +747,7 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, i
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -775,7 +775,7 @@ SymbolTable::addUnaryOpAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id
varname << "AUX_UOP_" << index;
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -797,7 +797,7 @@ SymbolTable::addVarModelEndoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag,
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -819,7 +819,7 @@ SymbolTable::addMultiplierAuxiliaryVar(int index) noexcept(false)
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -840,7 +840,7 @@ SymbolTable::addDiffForwardAuxiliaryVar(int orig_symb_id, expr_t expr_arg) noexc
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
symb_id = addSymbol(varname.str(), SymbolType::endogenous);
}
catch (AlreadyDeclaredException &e)
{
@ -896,7 +896,7 @@ SymbolTable::markPredetermined(int symb_id) noexcept(false)
if (frozen)
throw FrozenException();
assert(getType(symb_id) == eEndogenous);
assert(getType(symb_id) == SymbolType::endogenous);
predetermined_variables.insert(symb_id);
}
@ -918,7 +918,7 @@ void
SymbolTable::addObservedVariable(int symb_id) noexcept(false)
{
validateSymbID(symb_id);
assert(getType(symb_id) == eEndogenous);
assert(getType(symb_id) == SymbolType::endogenous);
varobs.push_back(symb_id);
}
@ -946,7 +946,7 @@ void
SymbolTable::addObservedExogenousVariable(int symb_id) noexcept(false)
{
validateSymbID(symb_id);
assert(getType(symb_id) != eEndogenous);
assert(getType(symb_id) != SymbolType::endogenous);
varexobs.push_back(symb_id);
}
@ -975,7 +975,7 @@ SymbolTable::getTrendVarIds() const
{
vector <int> trendVars;
for (const auto & it : symbol_table)
if (getType(it.second) == eTrend || getType(it.second) == eLogTrend)
if (getType(it.second) == SymbolType::trend || getType(it.second) == SymbolType::logTrend)
trendVars.push_back(it.second);
return trendVars;
}
@ -985,7 +985,7 @@ SymbolTable::getExogenous() const
{
set <int> exogs;
for (const auto & it : symbol_table)
if (getType(it.second) == eExogenous)
if (getType(it.second) == SymbolType::exogenous)
exogs.insert(it.second);
return exogs;
}
@ -995,7 +995,7 @@ SymbolTable::getObservedExogenous() const
{
set <int> oexogs;
for (const auto & it : symbol_table)
if (getType(it.second) == eExogenous)
if (getType(it.second) == SymbolType::exogenous)
if (isObservedExogenousVariable(it.second))
oexogs.insert(it.second);
return oexogs;
@ -1006,7 +1006,7 @@ SymbolTable::getEndogenous() const
{
set <int> endogs;
for (const auto & it : symbol_table)
if (getType(it.second) == eEndogenous)
if (getType(it.second) == SymbolType::endogenous)
endogs.insert(it.second);
return endogs;
}
@ -1034,7 +1034,7 @@ SymbolTable::getOrigEndogenous() const
{
set <int> origendogs;
for (const auto & it : symbol_table)
if (getType(it.second) == eEndogenous && !isAuxiliaryVariable(it.second))
if (getType(it.second) == SymbolType::endogenous && !isAuxiliaryVariable(it.second))
origendogs.insert(it.second);
return origendogs;
}