Commit 63a5ffb7 authored by Sébastien Villemot's avatar Sébastien Villemot

Rename ExprNode::cloneDynamic into ExprNode::clone, for clarity

parent 24f1276b
Pipeline #205 passed with stage
in 1 minute and 51 seconds
......@@ -67,12 +67,12 @@ DataTree::DataTree(const DataTree &d) :
initConstants();
for (const auto & it : d.node_list)
it->cloneDynamic(*this);
it->clone(*this);
assert(node_list.size() == d.node_list.size());
for (const auto & it : d.local_variables_table)
local_variables_table[it.first] = it.second->cloneDynamic(*this);
local_variables_table[it.first] = it.second->clone(*this);
}
DataTree &
......@@ -100,14 +100,14 @@ DataTree::operator=(const DataTree &d)
initConstants();
for (const auto & it : d.node_list)
it->cloneDynamic(*this);
it->clone(*this);
assert(node_list.size() == d.node_list.size());
local_variables_vector = d.local_variables_vector;
for (const auto & it : d.local_variables_table)
local_variables_table[it.first] = it.second->cloneDynamic(*this);
local_variables_table[it.first] = it.second->clone(*this);
return *this;
}
......
......@@ -34,7 +34,7 @@
void
DynamicModel::copyHelper(const DynamicModel &m)
{
auto f = [this](const ExprNode *e) { return e->cloneDynamic(*this); };
auto f = [this](const ExprNode *e) { return e->clone(*this); };
for (const auto &it : m.static_only_equations)
static_only_equations.push_back(dynamic_cast<BinaryOpNode *>(f(it)));
......@@ -5028,7 +5028,7 @@ DynamicModel::replaceMyEquations(DynamicModel &dynamic_model) const
{
dynamic_model.equations.clear();
for (size_t i = 0; i < equations.size(); i++)
dynamic_model.addEquation(equations[i]->cloneDynamic(dynamic_model),
dynamic_model.addEquation(equations[i]->clone(dynamic_model),
equations_lineno[i]);
}
......@@ -5049,7 +5049,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const boo
// Add Planner Objective to equations to include in computeDerivIDs
assert(static_model.equations.size() == 1);
addEquation(static_model.equations[0]->cloneDynamic(*this), static_model.equations_lineno[0]);
addEquation(static_model.equations[0]->clone(*this), static_model.equations_lineno[0]);
// Get max endo lead and max endo lag
set<pair<int, int>> dynvars;
......
......@@ -433,9 +433,9 @@ NumConstNode::computeXrefs(EquationInfo &ei) const
}
expr_t
NumConstNode::cloneDynamic(DataTree &dynamic_datatree) const
NumConstNode::clone(DataTree &datatree) const
{
return dynamic_datatree.AddNonNegativeConstant(datatree.num_constants.get(id));
return datatree.AddNonNegativeConstant(datatree.num_constants.get(id));
}
int
......@@ -1417,9 +1417,9 @@ VariableNode::get_type() const
}
expr_t
VariableNode::cloneDynamic(DataTree &dynamic_datatree) const
VariableNode::clone(DataTree &datatree) const
{
return dynamic_datatree.AddVariable(symb_id, lag);
return datatree.AddVariable(symb_id, lag);
}
int
......@@ -3192,10 +3192,10 @@ UnaryOpNode::computeXrefs(EquationInfo &ei) const
}
expr_t
UnaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const
UnaryOpNode::clone(DataTree &datatree) const
{
expr_t substarg = arg->cloneDynamic(dynamic_datatree);
return buildSimilarUnaryOpNode(substarg, dynamic_datatree);
expr_t substarg = arg->clone(datatree);
return buildSimilarUnaryOpNode(substarg, datatree);
}
int
......@@ -5056,11 +5056,11 @@ BinaryOpNode::computeXrefs(EquationInfo &ei) const
}
expr_t
BinaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const
BinaryOpNode::clone(DataTree &datatree) const
{
expr_t substarg1 = arg1->cloneDynamic(dynamic_datatree);
expr_t substarg2 = arg2->cloneDynamic(dynamic_datatree);
return buildSimilarBinaryOpNode(substarg1, substarg2, dynamic_datatree);
expr_t substarg1 = arg1->clone(datatree);
expr_t substarg2 = arg2->clone(datatree);
return buildSimilarBinaryOpNode(substarg1, substarg2, datatree);
}
int
......@@ -6412,12 +6412,12 @@ TrinaryOpNode::computeXrefs(EquationInfo &ei) const
}
expr_t
TrinaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const
TrinaryOpNode::clone(DataTree &datatree) const
{
expr_t substarg1 = arg1->cloneDynamic(dynamic_datatree);
expr_t substarg2 = arg2->cloneDynamic(dynamic_datatree);
expr_t substarg3 = arg3->cloneDynamic(dynamic_datatree);
return buildSimilarTrinaryOpNode(substarg1, substarg2, substarg3, dynamic_datatree);
expr_t substarg1 = arg1->clone(datatree);
expr_t substarg2 = arg2->clone(datatree);
expr_t substarg3 = arg3->clone(datatree);
return buildSimilarTrinaryOpNode(substarg1, substarg2, substarg3, datatree);
}
int
......@@ -7749,12 +7749,12 @@ ExternalFunctionNode::computeXrefs(EquationInfo &ei) const
}
expr_t
ExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
ExternalFunctionNode::clone(DataTree &datatree) const
{
vector<expr_t> dynamic_arguments;
for (auto argument : arguments)
dynamic_arguments.push_back(argument->cloneDynamic(dynamic_datatree));
return dynamic_datatree.AddExternalFunction(symb_id, dynamic_arguments);
dynamic_arguments.push_back(argument->clone(datatree));
return datatree.AddExternalFunction(symb_id, dynamic_arguments);
}
expr_t
......@@ -8115,12 +8115,12 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo
}
expr_t
FirstDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
FirstDerivExternalFunctionNode::clone(DataTree &datatree) const
{
vector<expr_t> dynamic_arguments;
for (auto argument : arguments)
dynamic_arguments.push_back(argument->cloneDynamic(dynamic_datatree));
return dynamic_datatree.AddFirstDerivExternalFunction(symb_id, dynamic_arguments,
dynamic_arguments.push_back(argument->clone(datatree));
return datatree.AddFirstDerivExternalFunction(symb_id, dynamic_arguments,
inputIndex);
}
......@@ -8438,13 +8438,13 @@ SecondDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string>
}
expr_t
SecondDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
SecondDerivExternalFunctionNode::clone(DataTree &datatree) const
{
vector<expr_t> dynamic_arguments;
for (auto argument : arguments)
dynamic_arguments.push_back(argument->cloneDynamic(dynamic_datatree));
return dynamic_datatree.AddSecondDerivExternalFunction(symb_id, dynamic_arguments,
inputIndex1, inputIndex2);
dynamic_arguments.push_back(argument->clone(datatree));
return datatree.AddSecondDerivExternalFunction(symb_id, dynamic_arguments,
inputIndex1, inputIndex2);
}
expr_t
......@@ -8544,9 +8544,9 @@ VarExpectationNode::toStatic(DataTree &static_datatree) const
}
expr_t
VarExpectationNode::cloneDynamic(DataTree &dynamic_datatree) const
VarExpectationNode::clone(DataTree &datatree) const
{
return dynamic_datatree.AddVarExpectation(model_name);
return datatree.AddVarExpectation(model_name);
}
void
......@@ -9010,9 +9010,9 @@ PacExpectationNode::toStatic(DataTree &static_datatree) const
}
expr_t
PacExpectationNode::cloneDynamic(DataTree &dynamic_datatree) const
PacExpectationNode::clone(DataTree &datatree) const
{
return dynamic_datatree.AddPacExpectation(string(model_name));
return datatree.AddPacExpectation(string(model_name));
}
void
......
......@@ -539,7 +539,7 @@ class ExprNode
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table) = 0;
//! Add ExprNodes to the provided datatree
virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const = 0;
virtual expr_t clone(DataTree &datatree) const = 0;
//! Move a trend variable with lag/lead to time t by dividing/multiplying by its growth factor
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const = 0;
......@@ -665,7 +665,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -762,7 +762,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -888,7 +888,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -1036,7 +1036,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
//! Function to write out the oPowerNode in expr_t terms as opposed to writing out the function itself
expr_t unpackPowerDeriv() const;
......@@ -1157,7 +1157,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -1282,7 +1282,7 @@ public:
virtual void writePrhs(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 string &ending) const;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override = 0;
expr_t clone(DataTree &datatree) const override = 0;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -1340,7 +1340,7 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
};
class FirstDerivExternalFunctionNode : public AbstractExternalFunctionNode
......@@ -1383,7 +1383,7 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
};
class SecondDerivExternalFunctionNode : public AbstractExternalFunctionNode
......@@ -1428,7 +1428,7 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
};
class VarExpectationNode : public ExprNode
......@@ -1448,7 +1448,7 @@ public:
vector< vector<temporary_terms_t>> &v_temporary_terms,
int equation) const override;
expr_t toStatic(DataTree &static_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
int maxEndoLead() const override;
int maxExoLead() const override;
int maxEndoLag() const override;
......@@ -1547,7 +1547,7 @@ public:
vector< vector<temporary_terms_t>> &v_temporary_terms,
int equation) const override;
expr_t toStatic(DataTree &static_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
int maxEndoLead() const override;
int maxExoLead() const override;
int maxEndoLag() const override;
......
......@@ -36,7 +36,7 @@ SteadyStateModel::SteadyStateModel(const SteadyStateModel &m) :
static_model {m.static_model}
{
for (const auto &it : m.def_table)
def_table.push_back(make_pair(it.first, it.second->cloneDynamic(*this)));
def_table.push_back(make_pair(it.first, it.second->clone(*this)));
}
SteadyStateModel &
......@@ -48,7 +48,7 @@ SteadyStateModel::operator=(const SteadyStateModel &m)
def_table.clear();
for (const auto &it : m.def_table)
def_table.push_back(make_pair(it.first, it.second->cloneDynamic(*this)));
def_table.push_back(make_pair(it.first, it.second->clone(*this)));
return *this;
}
......@@ -300,7 +300,7 @@ Epilogue::Epilogue(const Epilogue &m) :
exogs {m.exogs}
{
for (const auto &it : m.def_table)
def_table.push_back(make_pair(it.first, it.second->cloneDynamic(*this)));
def_table.push_back(make_pair(it.first, it.second->clone(*this)));
}
Epilogue &
......@@ -313,7 +313,7 @@ Epilogue::operator=(const Epilogue &m)
def_table.clear();
for (const auto &it : m.def_table)
def_table.push_back(make_pair(it.first, it.second->cloneDynamic(*this)));
def_table.push_back(make_pair(it.first, it.second->clone(*this)));
return *this;
}
......
......@@ -35,7 +35,7 @@ using namespace MFS;
void
ModelTree::copyHelper(const ModelTree &m)
{
auto f = [this](expr_t e) { return e->cloneDynamic(*this); };
auto f = [this](expr_t e) { return e->clone(*this); };
// Equations
for (const auto & it : m.equations)
......
......@@ -32,7 +32,7 @@
void
StaticModel::copyHelper(const StaticModel &m)
{
auto f = [this](expr_t e) { return e->cloneDynamic(*this); };
auto f = [this](expr_t e) { return e->clone(*this); };
auto convert_vector_tt = [this,f](vector<temporary_terms_t> vtt)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment