PAC: minor simplification in the matching of the growth expression
Simple variable nodes are already correctly matched by ExprNode::matchLinearCombinationOfVariables(). Also improve the related documentation.pac-components
parent
7dde09169e
commit
6a31ba4b62
|
@ -632,7 +632,9 @@ public:
|
||||||
parameter in a term, param_id == -1.
|
parameter in a term, param_id == -1.
|
||||||
Can throw a MatchFailureException.
|
Can throw a MatchFailureException.
|
||||||
if `variable_obligatory_in_each_term` is true, then every part of the linear combination must contain a variable;
|
if `variable_obligatory_in_each_term` is true, then every part of the linear combination must contain a variable;
|
||||||
otherwise, if `variable_obligatory_in_each_term`, then any linear combination of constant/variable/param is matched
|
otherwise, if `variable_obligatory_in_each_term` is false, then any linear
|
||||||
|
combination of constant/variable/param is matched (and variable_id == -1
|
||||||
|
for terms without a variable).
|
||||||
*/
|
*/
|
||||||
vector<tuple<int, int, int, double>> matchLinearCombinationOfVariables(bool variable_obligatory_in_each_term = true) const;
|
vector<tuple<int, int, int, double>> matchLinearCombinationOfVariables(bool variable_obligatory_in_each_term = true) const;
|
||||||
|
|
||||||
|
|
|
@ -830,15 +830,9 @@ PacModelTable::transformPass(ExprNode::subst_table_t &diff_subst_table,
|
||||||
}
|
}
|
||||||
catch (ExprNode::MatchFailureException &e)
|
catch (ExprNode::MatchFailureException &e)
|
||||||
{
|
{
|
||||||
auto gv = dynamic_cast<const VariableNode *>(growth[name]);
|
cerr << "ERROR: PAC growth must be a linear combination of variables" << endl;
|
||||||
if (gv)
|
|
||||||
growth_info[name].emplace_back(gv->symb_id, gv->lag, -1, 1);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cerr << "Pac growth must be a linear combination of variables" << endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Collect some information about PAC models
|
// Collect some information about PAC models
|
||||||
int max_lag;
|
int max_lag;
|
||||||
|
|
|
@ -199,6 +199,9 @@ private:
|
||||||
map<string, string> discount;
|
map<string, string> discount;
|
||||||
// The growth expressions belong to the main dynamic_model from the ModFile instance
|
// The growth expressions belong to the main dynamic_model from the ModFile instance
|
||||||
map<string, expr_t> growth, original_growth;
|
map<string, expr_t> growth, original_growth;
|
||||||
|
/* Information about the structure of growth expressions (which must be a
|
||||||
|
linear combination of variables).
|
||||||
|
Each tuple represents a term: (endo_id, lag, param_id, constant) */
|
||||||
map<string, vector<tuple<int, int, int, double>>> growth_info;
|
map<string, vector<tuple<int, int, int, double>>> growth_info;
|
||||||
|
|
||||||
/* Stores the name of the PAC equation associated to the model.
|
/* Stores the name of the PAC equation associated to the model.
|
||||||
|
|
Loading…
Reference in New Issue