Verified Commit b88e0de5 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Remove useless accessor methods for data members that are const in ExprNode classes

Those const data members are simply made public.
parent cac65b07
Pipeline #397 passed with stage
in 1 minute and 21 seconds
......@@ -4936,7 +4936,7 @@ VarExpectationModelStatement::writeOutput(ostream &output, const string &basenam
<< mstruct << ".variable_id = " << symbol_table.getTypeSpecificID(variable)+1 << ";" << endl;
auto disc_var = dynamic_cast<const VariableNode *>(discount);
if (disc_var)
output << mstruct << ".discount_index = " << symbol_table.getTypeSpecificID(disc_var->get_symb_id()) + 1 << ';' << endl;
output << mstruct << ".discount_index = " << symbol_table.getTypeSpecificID(disc_var->symb_id) + 1 << ';' << endl;
else
{
output << mstruct << ".discount_value = ";
......
......@@ -174,13 +174,13 @@ DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
{
// Simplify x+(-y) in x-y
auto uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
if (uarg2 != nullptr && uarg2->get_op_code() == UnaryOpcode::uminus)
return AddMinus(iArg1, uarg2->get_arg());
if (uarg2 != nullptr && uarg2->op_code == UnaryOpcode::uminus)
return AddMinus(iArg1, uarg2->arg);
// Simplify (-x)+y in y-x
auto uarg1 = dynamic_cast<UnaryOpNode *>(iArg1);
if (uarg1 != nullptr && uarg1->get_op_code() == UnaryOpcode::uminus)
return AddMinus(iArg2, uarg1->get_arg());
if (uarg1 != nullptr && uarg1->op_code == UnaryOpcode::uminus)
return AddMinus(iArg2, uarg1->arg);
// To treat commutativity of "+"
// Nodes iArg1 and iArg2 are sorted by index
......@@ -219,8 +219,8 @@ DataTree::AddUMinus(expr_t iArg1)
{
// Simplify -(-x) in x
auto *uarg = dynamic_cast<UnaryOpNode *>(iArg1);
if (uarg != nullptr && uarg->get_op_code() == UnaryOpcode::uminus)
return uarg->get_arg();
if (uarg != nullptr && uarg->op_code == UnaryOpcode::uminus)
return uarg->arg;
return AddUnaryOp(UnaryOpcode::uminus, iArg1);
}
......
......@@ -649,8 +649,8 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
EquationType equ_type = getBlockEquationType(block, i);
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();
lhs = eq_node->arg1;
rhs = eq_node->arg2;
tmp_output.str("");
lhs->writeOutput(tmp_output, local_output_type, local_temporary_terms, {});
switch (simulation_type)
......@@ -677,8 +677,8 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
output << endl << " ";
tmp_output.str("");
eq_node = (BinaryOpNode *) getBlockEquationRenormalizedExpr(block, i);
lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2();
lhs = eq_node->arg1;
rhs = eq_node->arg2;
lhs->writeOutput(output, local_output_type, local_temporary_terms, {});
output << " = ";
rhs->writeOutput(output, local_output_type, local_temporary_terms, {});
......@@ -1415,16 +1415,16 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
if (equ_type == E_EVALUATE)
{
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2();
lhs = eq_node->arg1;
rhs = eq_node->arg2;
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
lhs->compile(code_file, instruction_number, true, temporary_terms, map_idx, true, false);
}
else if (equ_type == E_EVALUATE_S)
{
eq_node = (BinaryOpNode *) getBlockEquationRenormalizedExpr(block, i);
lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2();
lhs = eq_node->arg1;
rhs = eq_node->arg2;
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
lhs->compile(code_file, instruction_number, true, temporary_terms, map_idx, true, false);
}
......@@ -1445,8 +1445,8 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i));
fnumexpr.write(code_file, instruction_number);
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2();
lhs = eq_node->arg1;
rhs = eq_node->arg2;
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
......@@ -3681,7 +3681,7 @@ DynamicModel::updateVarAndTrendModel() const
for (auto eqn : it.second)
{
set<pair<int, int>> rhs_set;
equations[eqn]->get_arg2()->collectDynamicVariables(SymbolType::endogenous, rhs_set);
equations[eqn]->arg2->collectDynamicVariables(SymbolType::endogenous, rhs_set);
rhs.push_back(rhs_set);
if (i == 1)
......@@ -3695,7 +3695,7 @@ DynamicModel::updateVarAndTrendModel() const
catch (...)
{
}
int trend_var_symb_id = equations[eqn]->get_arg2()->findTargetVariable(lhs_symb_id);
int trend_var_symb_id = equations[eqn]->arg2->findTargetVariable(lhs_symb_id);
if (trend_var_symb_id >= 0)
{
if (symbol_table.isAuxiliaryVariable(trend_var_symb_id))
......@@ -3764,9 +3764,9 @@ DynamicModel::fillVarModelTable() const
exit(EXIT_FAILURE);
}
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);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::endogenous, lhs_set);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::exogenous, lhs_tmp_set);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::parameter, lhs_tmp_set);
if (lhs_set.size() != 1 || !lhs_tmp_set.empty())
{
......@@ -3788,10 +3788,10 @@ DynamicModel::fillVarModelTable() const
lhs.push_back(itlhs->first);
lhs_set.clear();
set<expr_t> lhs_expr_t_set;
equations[eqn]->get_arg1()->collectVARLHSVariable(lhs_expr_t_set);
equations[eqn]->arg1->collectVARLHSVariable(lhs_expr_t_set);
lhs_expr_t.push_back(*(lhs_expr_t_set.begin()));
equations[eqn]->get_arg2()->collectDynamicVariables(SymbolType::endogenous, rhs_set);
equations[eqn]->arg2->collectDynamicVariables(SymbolType::endogenous, rhs_set);
for (const auto & itrhs : rhs_set)
if (itrhs.second > 0)
{
......@@ -3830,7 +3830,7 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const
for (auto eqn : it.second)
{
// ensure no leads in equations
if (equations[eqn]->get_arg2()->VarMinLag() <= 0)
if (equations[eqn]->arg2->VarMinLag() <= 0)
{
cerr << "ERROR in VAR model Equation (#" << eqn << "). "
<< "Leaded exogenous variables "
......@@ -3840,14 +3840,14 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const
}
// save lhs variables
equations[eqn]->get_arg1()->collectVARLHSVariable(lhs);
equations[eqn]->arg1->collectVARLHSVariable(lhs);
equations[eqn]->get_arg1()->countDiffs() > 0 ?
equations[eqn]->arg1->countDiffs() > 0 ?
diff_vec.push_back(true) : diff_vec.push_back(false);
if (diff_vec.back())
{
set<pair<int, int>> diff_set;
equations[eqn]->get_arg1()->collectDynamicVariables(SymbolType::endogenous, diff_set);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::endogenous, diff_set);
if (diff_set.size() != 1)
{
......@@ -3874,7 +3874,7 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const
vector<int> max_lag;
for (auto eqn : it.second)
max_lag.push_back(equations[eqn]->get_arg2()->VarMaxLag(static_model, lhs_static));
max_lag.push_back(equations[eqn]->arg2->VarMaxLag(static_model, lhs_static));
lags[it.first] = max_lag;
diff[it.first] = diff_vec;
orig_diff_var[it.first] = orig_diff_var_vec;
......@@ -3896,7 +3896,7 @@ DynamicModel::fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, exp
vector<int> lhs = is_trend_component_model ?
trend_component_model_table.getLhs(it.first) : var_model_table.getLhs(it.first);
for (auto eqn : it.second)
equations[eqn]->get_arg2()->fillAutoregressiveRow(i++, lhs, AR);
equations[eqn]->arg2->fillAutoregressiveRow(i++, lhs, AR);
ARr[it.first] = AR;
}
}
......@@ -3957,9 +3957,9 @@ DynamicModel::fillTrendComponentModelTable() const
exit(EXIT_FAILURE);
}
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);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::endogenous, lhs_set);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::exogenous, lhs_tmp_set);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::parameter, lhs_tmp_set);
if (lhs_set.size() != 1 || !lhs_tmp_set.empty())
{
......@@ -3981,10 +3981,10 @@ DynamicModel::fillTrendComponentModelTable() const
lhs.push_back(itlhs->first);
lhs_set.clear();
set<expr_t> lhs_expr_t_set;
equations[eqn]->get_arg1()->collectVARLHSVariable(lhs_expr_t_set);
equations[eqn]->arg1->collectVARLHSVariable(lhs_expr_t_set);
lhs_expr_t.push_back(*(lhs_expr_t_set.begin()));
equations[eqn]->get_arg2()->collectDynamicVariables(SymbolType::endogenous, rhs_set);
equations[eqn]->arg2->collectDynamicVariables(SymbolType::endogenous, rhs_set);
for (const auto & itrhs : rhs_set)
if (itrhs.second > 0)
{
......@@ -4026,7 +4026,7 @@ DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, exp
i = 0;
for (auto eqn : it.second)
if (find(nontrend_eqnums.begin(), nontrend_eqnums.end(), eqn) != nontrend_eqnums.end())
equations[eqn]->get_arg2()->fillErrorCorrectionRow(i++, parsed_undiff_nontrend_lhs, trend_lhs, EC);
equations[eqn]->arg2->fillErrorCorrectionRow(i++, parsed_undiff_nontrend_lhs, trend_lhs, EC);
ECr[it.first] = EC;
}
}
......@@ -4044,7 +4044,7 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel(StaticModel &static_mode
for (auto eqn : it.second)
{
// ensure no leads in equations
if (equations[eqn]->get_arg2()->VarMinLag() <= 0)
if (equations[eqn]->arg2->VarMinLag() <= 0)
{
cerr << "ERROR in trend component model Equation (#" << eqn << "). "
<< "Leaded exogenous variables "
......@@ -4054,14 +4054,14 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel(StaticModel &static_mode
}
// save lhs variables
equations[eqn]->get_arg1()->collectVARLHSVariable(lhs);
equations[eqn]->arg1->collectVARLHSVariable(lhs);
equations[eqn]->get_arg1()->countDiffs() > 0 ?
equations[eqn]->arg1->countDiffs() > 0 ?
diff_vec.push_back(true) : diff_vec.push_back(false);
if (diff_vec.back())
{
set<pair<int, int>> diff_set;
equations[eqn]->get_arg1()->collectDynamicVariables(SymbolType::endogenous, diff_set);
equations[eqn]->arg1->collectDynamicVariables(SymbolType::endogenous, diff_set);
if (diff_set.size() != 1)
{
......@@ -4088,7 +4088,7 @@ DynamicModel::fillTrendComponentModelTableFromOrigModel(StaticModel &static_mode
vector<int> max_lag;
for (auto eqn : it.second)
max_lag.push_back(equations[eqn]->get_arg2()->VarMaxLag(static_model, lhs_static));
max_lag.push_back(equations[eqn]->arg2->VarMaxLag(static_model, lhs_static));
lags[it.first] = max_lag;
diff[it.first] = diff_vec;
orig_diff_var[it.first] = orig_diff_var_vec;
......@@ -4224,12 +4224,12 @@ DynamicModel::getUndiffLHSForPac(const string &aux_model_name,
if (printerr)
{ // we have undiffed something like diff(x), hence x is not in diff_subst_table
lhs_expr_t.at(i) = node;
lhs.at(i) = dynamic_cast<VariableNode *>(node)->get_symb_id();
lhs.at(i) = dynamic_cast<VariableNode *>(node)->symb_id;
}
else
{
lhs_expr_t.at(i) = const_cast<expr_t>(it1->first);
lhs.at(i) = const_cast<VariableNode *>(it1->second)->get_symb_id();
lhs.at(i) = const_cast<VariableNode *>(it1->second)->symb_id;
}
}
return lhs;
......@@ -4262,11 +4262,11 @@ DynamicModel::walkPacParameters()
{
}
equation->get_arg2()->getPacOptimizingShareAndExprNodes(optim_share,
equation->arg2->getPacOptimizingShareAndExprNodes(optim_share,
optim_part,
non_optim_part);
if (optim_part == nullptr)
equation->get_arg2()->getPacOptimizingPart(lhs_orig_symb_id, ec_params_and_vars, ar_params_and_vars);
equation->arg2->getPacOptimizingPart(lhs_orig_symb_id, ec_params_and_vars, ar_params_and_vars);
else
{
optim_share_index = *(optim_share.begin());
......@@ -4288,7 +4288,7 @@ DynamicModel::getPacMaxLag(const string &pac_model_name) const
if (equation->containsPacExpectation(pac_model_name))
{
set<pair<int, int>> endogs;
equation->get_arg1()->collectDynamicVariables(SymbolType::endogenous, endogs);
equation->arg1->collectDynamicVariables(SymbolType::endogenous, endogs);
if (endogs.size() != 1)
{
cerr << "The LHS of the PAC equation may only be comprised of one endogenous variable"
......@@ -5296,8 +5296,8 @@ DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context
|| 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(),
equations[eq]->get_arg2());
expr_t homogeneq = AddMinus(equations[eq]->arg1,
equations[eq]->arg2);
// Do not run the test if the term inside the log is zero
if (fabs(homogeneq->eval(eval_context)) > zero_band)
......@@ -6007,13 +6007,13 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const
// First, auxiliary variables
for (auto aux_equation : aux_equations)
{
assert(aux_equation->get_op_code() == BinaryOpcode::equal);
auto *auxvar = dynamic_cast<VariableNode *>(aux_equation->get_arg1());
assert(aux_equation->op_code == BinaryOpcode::equal);
auto *auxvar = dynamic_cast<VariableNode *>(aux_equation->arg1);
assert(auxvar != nullptr);
try
{
double val = aux_equation->get_arg2()->eval(eval_context);
eval_context[auxvar->get_symb_id()] = val;
double val = aux_equation->arg2->eval(eval_context);
eval_context[auxvar->symb_id] = val;
}
catch (ExprNode::EvalException &e)
{
......@@ -6060,7 +6060,7 @@ void
DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string>> &eq_tags)
{
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
assert(beq != nullptr && beq->op_code == BinaryOpcode::equal);
vector<pair<string, string>> soe_eq_tags;
for (const auto & eq_tag : eq_tags)
......@@ -6107,8 +6107,8 @@ DynamicModel::isChecksumMatching(const string &basename, bool block) const
for (int eq = 0; eq < (int) equations.size(); eq++)
{
BinaryOpNode *eq_node = equations[eq];
expr_t lhs = eq_node->get_arg1();
expr_t rhs = eq_node->get_arg2();
expr_t lhs = eq_node->arg1;
expr_t rhs = eq_node->arg2;
// Test if the right hand side of the equation is empty.
double vrhs = 1.0;
......
......@@ -1863,22 +1863,22 @@ VariableNode::replaceTrendVar() const
expr_t
VariableNode::detrend(int symb_id, bool log_trend, expr_t trend) const
{
if (get_symb_id() != symb_id)
if (this->symb_id != symb_id)
return const_cast<VariableNode *>(this);
if (log_trend)
{
if (get_lag() == 0)
if (lag == 0)
return datatree.AddPlus(const_cast<VariableNode *>(this), trend);
else
return datatree.AddPlus(const_cast<VariableNode *>(this), trend->decreaseLeadsLags(-1*get_lag()));
return datatree.AddPlus(const_cast<VariableNode *>(this), trend->decreaseLeadsLags(-lag));
}
else
{
if (get_lag() == 0)
if (lag == 0)
return datatree.AddTimes(const_cast<VariableNode *>(this), trend);
else
return datatree.AddTimes(const_cast<VariableNode *>(this), trend->decreaseLeadsLags(-1*get_lag()));
return datatree.AddTimes(const_cast<VariableNode *>(this), trend->decreaseLeadsLags(-lag));
}
}
......@@ -1891,7 +1891,7 @@ VariableNode::countDiffs() const
expr_t
VariableNode::removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const
{
if ((get_type() != SymbolType::trend && get_type() != SymbolType::logTrend) || get_lag() == 0)
if ((get_type() != SymbolType::trend && get_type() != SymbolType::logTrend) || lag == 0)
return const_cast<VariableNode *>(this);
map<int, expr_t>::const_iterator it = trend_symbols_map.find(symb_id);
......@@ -1899,18 +1899,18 @@ VariableNode::removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const
bool log_trend = get_type() == SymbolType::logTrend;
expr_t trend = it->second;
if (get_lag() > 0)
if (lag > 0)
{
expr_t growthFactorSequence = trend->decreaseLeadsLags(-1);
if (log_trend)
{
for (int i = 1; i < get_lag(); i++)
for (int i = 1; i < lag; i++)
growthFactorSequence = datatree.AddPlus(growthFactorSequence, trend->decreaseLeadsLags(-1*(i+1)));
return datatree.AddPlus(noTrendLeadLagNode, growthFactorSequence);
}
else
{
for (int i = 1; i < get_lag(); i++)
for (int i = 1; i < lag; i++)
growthFactorSequence = datatree.AddTimes(growthFactorSequence, trend->decreaseLeadsLags(-1*(i+1)));
return datatree.AddTimes(noTrendLeadLagNode, growthFactorSequence);
}
......@@ -1920,13 +1920,13 @@ VariableNode::removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const
expr_t growthFactorSequence = trend;
if (log_trend)
{
for (int i = 1; i < abs(get_lag()); i++)
for (int i = 1; i < abs(lag); i++)
growthFactorSequence = datatree.AddPlus(growthFactorSequence, trend->decreaseLeadsLags(i));
return datatree.AddMinus(noTrendLeadLagNode, growthFactorSequence);
}
else
{
for (int i = 1; i < abs(get_lag()); i++)
for (int i = 1; i < abs(lag); i++)
growthFactorSequence = datatree.AddTimes(growthFactorSequence, trend->decreaseLeadsLags(i));
return datatree.AddDivide(noTrendLeadLagNode, growthFactorSequence);
}
......@@ -3411,12 +3411,12 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table,
rit != it->second.rend(); rit++)
{
expr_t argsubst = dynamic_cast<UnaryOpNode *>(rit->second)->
get_arg()->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
arg->substituteDiff(static_datatree, diff_table, subst_table, neweqs);
auto *vn = dynamic_cast<VariableNode *>(argsubst);
if (rit == it->second.rbegin())
{
if (vn != nullptr)
symb_id = datatree.symbol_table.addDiffAuxiliaryVar(argsubst->idx, argsubst, vn->get_symb_id(), vn->get_lag());
symb_id = datatree.symbol_table.addDiffAuxiliaryVar(argsubst->idx, argsubst, vn->symb_id, vn->lag);
else
symb_id = datatree.symbol_table.addDiffAuxiliaryVar(argsubst->idx, argsubst);
......@@ -3437,10 +3437,10 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table,
{
if (i == last_arg_max_lag)
symb_id = datatree.symbol_table.addDiffLagAuxiliaryVar(argsubst->idx, argsubst,
last_aux_var->get_symb_id(), last_aux_var->get_lag());
last_aux_var->symb_id, last_aux_var->lag);
else
symb_id = datatree.symbol_table.addDiffLagAuxiliaryVar(new_aux_var->idx, new_aux_var,
last_aux_var->get_symb_id(), last_aux_var->get_lag());
last_aux_var->symb_id, last_aux_var->lag);
new_aux_var = datatree.AddVariable(symb_id, 0);
neweqs.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(new_aux_var,
......@@ -3545,7 +3545,7 @@ UnaryOpNode::substituteUnaryOpNodes(DataTree &static_datatree, diff_table_t &nod
symb_id = datatree.symbol_table.addUnaryOpAuxiliaryVar(this->idx, dynamic_cast<UnaryOpNode *>(rit->second), unary_op);
else
symb_id = datatree.symbol_table.addUnaryOpAuxiliaryVar(this->idx, dynamic_cast<UnaryOpNode *>(rit->second), unary_op,
vn->get_symb_id(), vn->get_lag());
vn->symb_id, vn->lag);
aux_var = datatree.AddVariable(symb_id, 0);
neweqs.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(aux_var,
dynamic_cast<UnaryOpNode *>(rit->second))));
......@@ -5450,10 +5450,10 @@ BinaryOpNode::findTargetVariableHelper(const expr_t arg1, const expr_t arg2,
if (endogs.size() == 2)
{
auto *testarg2 = dynamic_cast<BinaryOpNode *>(arg2);
if (testarg2 != nullptr && testarg2->get_op_code() == BinaryOpcode::minus)
if (testarg2 != nullptr && testarg2->op_code == BinaryOpcode::minus)
{
auto *test_arg1 = dynamic_cast<VariableNode *>(testarg2->get_arg1());
auto *test_arg2 = dynamic_cast<VariableNode *>(testarg2->get_arg2());
auto *test_arg1 = dynamic_cast<VariableNode *>(testarg2->arg1);
auto *test_arg2 = dynamic_cast<VariableNode *>(testarg2->arg2);
if (test_arg1 != nullptr && test_arg2 != nullptr )
if (findTargetVariableHelper1(lhs_symb_id, endogs.begin()->first))
return endogs.rbegin()->first;
......@@ -5495,10 +5495,10 @@ BinaryOpNode::getPacOptimizingPartHelper(const expr_t arg1, const expr_t arg2,
else if (endogs.size() >= 2)
{
auto *testarg2 = dynamic_cast<BinaryOpNode *>(arg2);
if (testarg2 != nullptr && testarg2->get_op_code() == BinaryOpcode::minus)
if (testarg2 != nullptr && testarg2->op_code == BinaryOpcode::minus)
{
auto *test_arg1 = dynamic_cast<VariableNode *>(testarg2->get_arg1());
auto *test_arg2 = dynamic_cast<VariableNode *>(testarg2->get_arg2());
auto *test_arg1 = dynamic_cast<VariableNode *>(testarg2->arg1);
auto *test_arg2 = dynamic_cast<VariableNode *>(testarg2->arg2);
if (test_arg1 != nullptr && test_arg2 != nullptr)
{
vector<int> endog_ids;
......@@ -5712,7 +5712,7 @@ BinaryOpNode::fillErrorCorrectionRowHelper(expr_t arg1, expr_t arg2,
BinaryOpNode *multiplicandr = dynamic_cast<BinaryOpNode *>(arg2);
if (multiplicandr == nullptr
|| multiplicandr->get_op_code() != BinaryOpcode::minus)
|| multiplicandr->op_code != BinaryOpcode::minus)
return;
arg2->collectDynamicVariables(SymbolType::endogenous, endogs);
......
......@@ -638,19 +638,15 @@ struct ExprNodeLess
/*! The constant is necessarily non-negative (this is enforced at the NumericalConstants class level) */
class NumConstNode : public ExprNode
{
private:
public:
//! Id from numerical constants table
const int id;
private:
expr_t computeDerivative(int deriv_id) override;
protected:
void matchVTCTPHelper(int &var_id, int &lag, int &param_id, double &constant, bool at_denominator) const override;
public:
NumConstNode(DataTree &datatree_arg, int idx_arg, int id_arg);
int
get_id() const
{
return id;
};
void prepareForDerivation() override;
void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms) const override;
void writeJsonAST(ostream &output) const override;
......@@ -721,11 +717,12 @@ public:
class VariableNode : public ExprNode
{
friend class UnaryOpNode;
private:
public:
//! Id from the symbol table
const int symb_id;
//! A positive value is a lead, a negative is a lag
const int lag;
private:
expr_t computeDerivative(int deriv_id) override;
protected:
void matchVTCTPHelper(int &var_id, int &lag, int &param_id, double &constant, bool at_denominator) const override;
......@@ -750,16 +747,6 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
SymbolType get_type() const;
int
get_symb_id() const
{
return symb_id;
};
int
get_lag() const
{
return lag;
};
pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t>>> &List_of_Op_RHS) const override;
expr_t getChainRuleDerivative(int deriv_id, const map<int, expr_t> &recursive_variables) override;
int maxEndoLead() const override;
......@@ -820,7 +807,7 @@ class UnaryOpNode : public ExprNode
{
protected:
void matchVTCTPHelper(int &var_id, int &lag, int &param_id, double &constant, bool at_denominator) const override;
private:
public:
const expr_t arg;
//! Stores the information set. Only used for expectation operator
const int expectation_information_set;
......@@ -829,6 +816,7 @@ private:
const UnaryOpcode op_code;
const string adl_param_name;
const vector<int> adl_lags;
private:
expr_t computeDerivative(int deriv_id) override;
int cost(int cost, bool is_matlab) const override;
int cost(const temporary_terms_t &temporary_terms, bool is_matlab) const override;
......@@ -869,18 +857,6 @@ public:
static double eval_opcode(UnaryOpcode op_code, double v) noexcept(false);
double eval(const eval_context_t &eval_context) const noexcept(false) override;
void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, const deriv_node_temp_terms_t &tef_terms) const override;
//! Returns operand
expr_t
get_arg() const
{
return (arg);
};
//! Returns op code
UnaryOpcode
get_op_code() const
{
return (op_code);
};
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t>>> &List_of_Op_RHS) const override;
......@@ -947,17 +923,18 @@ class BinaryOpNode : public ExprNode
{
protected:
void matchVTCTPHelper(int &var_id, int &lag, int &param_id, double &constant, bool at_denominator) const override;
private:
public:
const expr_t arg1, arg2;
const BinaryOpcode op_code;
const int powerDerivOrder;
const string adlparam;
private:
expr_t computeDerivative(int deriv_id) override;
int cost(int cost, bool is_matlab) const override;
int cost(const temporary_terms_t &temporary_terms, bool is_matlab) const override;
int cost(const map<NodeTreeReference, temporary_terms_t> &temp_terms_map, bool is_matlab) const override;
//! Returns the derivative of this node if darg1 and darg2 are the derivatives of the arguments
expr_t composeDerivatives(expr_t darg1, expr_t darg2);
const int powerDerivOrder;
const string adlparam;
public:
BinaryOpNode(DataTree &datatree_arg, int idx_arg, const expr_t arg1_arg,
BinaryOpcode op_code_arg, const expr_t arg2_arg, int powerDerivOrder);
......@@ -996,29 +973,6 @@ public:
double eval(const eval_context_t &eval_context) const noexcept(false) override;
void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, const deriv_node_temp_terms_t &tef_terms) const override;
expr_t Compute_RHS(expr_t arg1, expr_t arg2, int op, int op_type) const;
//! Returns first operand
expr_t
get_arg1() const
{
return (arg1);
};
//! Returns second operand
expr_t
get_arg2() const
{
return (arg2);
};
//! Returns op code
BinaryOpcode
get_op_code() const
{
return (op_code);
};
int
get_power_deriv_order() const
{
return powerDerivOrder;
}
void getPacOptimizingPartHelper(const expr_t arg1, const expr_t arg2,
int lhs_orig_symb_id,
pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars,
......@@ -1103,9 +1057,10 @@ public:
class TrinaryOpNode : public ExprNode
{
friend class ModelTree;
private:
public:
const expr_t arg1, arg2, arg3;