Drop ExprNode::containsExogenous()
Replace it by calls to ExprNode::collectVariables() at the single place where it was used.issue#70
parent
063207e71f
commit
d347a92f14
|
@ -691,12 +691,6 @@ NumConstNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
NumConstNode::containsExogenous() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
expr_t
|
||||
NumConstNode::replaceTrendVar() const
|
||||
{
|
||||
|
@ -1860,15 +1854,6 @@ VariableNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
VariableNode::containsExogenous() const
|
||||
{
|
||||
if (get_type() == SymbolType::modelLocalVariable)
|
||||
return datatree.getLocalVariable(symb_id)->containsExogenous();
|
||||
|
||||
return get_type() == SymbolType::exogenous || get_type() == SymbolType::exogenousDet;
|
||||
}
|
||||
|
||||
expr_t
|
||||
VariableNode::replaceTrendVar() const
|
||||
{
|
||||
|
@ -3718,12 +3703,6 @@ UnaryOpNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return arg->containsPacExpectation(pac_model_name);
|
||||
}
|
||||
|
||||
bool
|
||||
UnaryOpNode::containsExogenous() const
|
||||
{
|
||||
return arg->containsExogenous();
|
||||
}
|
||||
|
||||
expr_t
|
||||
UnaryOpNode::replaceTrendVar() const
|
||||
{
|
||||
|
@ -5186,12 +5165,6 @@ BinaryOpNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return arg1->containsPacExpectation(pac_model_name) || arg2->containsPacExpectation(pac_model_name);
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryOpNode::containsExogenous() const
|
||||
{
|
||||
return arg1->containsExogenous() || arg2->containsExogenous();
|
||||
}
|
||||
|
||||
expr_t
|
||||
BinaryOpNode::replaceTrendVar() const
|
||||
{
|
||||
|
@ -6419,12 +6392,6 @@ TrinaryOpNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return (arg1->containsPacExpectation(pac_model_name) || arg2->containsPacExpectation(pac_model_name) || arg3->containsPacExpectation(pac_model_name));
|
||||
}
|
||||
|
||||
bool
|
||||
TrinaryOpNode::containsExogenous() const
|
||||
{
|
||||
return (arg1->containsExogenous() || arg2->containsExogenous() || arg3->containsExogenous());
|
||||
}
|
||||
|
||||
expr_t
|
||||
TrinaryOpNode::replaceTrendVar() const
|
||||
{
|
||||
|
@ -6917,15 +6884,6 @@ AbstractExternalFunctionNode::containsPacExpectation(const string &pac_model_nam
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractExternalFunctionNode::containsExogenous() const
|
||||
{
|
||||
for (auto argument : arguments)
|
||||
if (argument->containsExogenous())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
expr_t
|
||||
AbstractExternalFunctionNode::replaceTrendVar() const
|
||||
{
|
||||
|
@ -8390,13 +8348,6 @@ VarExpectationNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
VarExpectationNode::containsExogenous() const
|
||||
{
|
||||
cerr << "VarExpectationNode::containsExogenous not implemented." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bool
|
||||
VarExpectationNode::isNumConstNodeEqualTo(double value) const
|
||||
{
|
||||
|
@ -8779,12 +8730,6 @@ PacExpectationNode::containsPacExpectation(const string &pac_model_name) const
|
|||
return pac_model_name == model_name;
|
||||
}
|
||||
|
||||
bool
|
||||
PacExpectationNode::containsExogenous() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PacExpectationNode::isNumConstNodeEqualTo(double value) const
|
||||
{
|
||||
|
|
|
@ -567,9 +567,6 @@ public:
|
|||
*/
|
||||
virtual bool isNumConstNodeEqualTo(double value) const = 0;
|
||||
|
||||
//! Returns true if the expression contains one or several exogenous variable
|
||||
virtual bool containsExogenous() const = 0;
|
||||
|
||||
//! Returns the maximum number of nested diffs in the expression
|
||||
virtual int countDiffs() const = 0;
|
||||
|
||||
|
@ -779,7 +776,6 @@ public:
|
|||
expr_t decreaseLeadsLagsPredeterminedVariables() const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
|
||||
expr_t replaceTrendVar() const override;
|
||||
|
@ -853,7 +849,6 @@ public:
|
|||
expr_t decreaseLeadsLagsPredeterminedVariables() const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
|
||||
expr_t replaceTrendVar() const override;
|
||||
|
@ -958,7 +953,6 @@ public:
|
|||
expr_t decreaseLeadsLagsPredeterminedVariables() const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
|
||||
expr_t replaceTrendVar() const override;
|
||||
|
@ -1067,7 +1061,6 @@ public:
|
|||
expr_t decreaseLeadsLagsPredeterminedVariables() const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
|
||||
expr_t replaceTrendVar() const override;
|
||||
|
@ -1198,7 +1191,6 @@ public:
|
|||
expr_t decreaseLeadsLagsPredeterminedVariables() const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
|
||||
expr_t replaceTrendVar() const override;
|
||||
|
@ -1310,7 +1302,6 @@ public:
|
|||
expr_t decreaseLeadsLagsPredeterminedVariables() const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
|
||||
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;
|
||||
|
@ -1492,7 +1483,6 @@ public:
|
|||
const deriv_node_temp_terms_t &tef_terms) const override;
|
||||
void collectVARLHSVariable(set<expr_t> &result) const override;
|
||||
void collectDynamicVariables(SymbolType type_arg, set<pair<int, int>> &result) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
|
@ -1566,7 +1556,6 @@ public:
|
|||
const deriv_node_temp_terms_t &tef_terms) const override;
|
||||
void collectVARLHSVariable(set<expr_t> &result) const override;
|
||||
void collectDynamicVariables(SymbolType type_arg, set<pair<int, int>> &result) const override;
|
||||
bool containsExogenous() const override;
|
||||
int countDiffs() const override;
|
||||
bool isNumConstNodeEqualTo(double value) const override;
|
||||
expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const override;
|
||||
|
|
|
@ -1830,8 +1830,13 @@ bool
|
|||
StaticModel::exoPresentInEqs() const
|
||||
{
|
||||
for (auto equation : equations)
|
||||
if (equation->containsExogenous())
|
||||
return true;
|
||||
{
|
||||
set<int> result;
|
||||
equation->collectVariables(SymbolType::exogenous, result);
|
||||
equation->collectVariables(SymbolType::exogenousDet, result);
|
||||
if (!result.empty())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue