introduce command line options: `exclude_eqs` and `include_eqs`
Allows for the inclusion/exclusion of a set of equations, specified either on the command line or in a text file.
If the equation has a single endogenous variable on the LHS, then the equation is moved. If not, if the equation has an endogenous
tag then that variable is removed along with this equation. If not, then an error is thrown.
As a command line argument, exclude_eqs
can take the form (same syntax for include_eqs
):
-
exclude_eqs=eq1 to remove all equations declared as
[name=eq1]` -
exclude_eqs=[eq 1, eq 2]
to remove all equations declared as[name=eq 1]
or[name=eq 2]
-
exclude_eqs=[tagname=X]
to remove all equations declared as[tagname=X]
-
exclude_eqs=[tagname=(X, Y)]
to remove all equations declared as[tagname=X]
or[tagname=Y]
When declared in a file, the file should be of the form:
eq 1
eq 2
to remove all equations declared as [name=eq 1]
or [name=eq 2]
.
It should be of the form:
tagname=
X
Y
to remove all equations declared as [tagname=X]
or [tagname=Y]
.
Merge request reports
Activity
changed milestone to %4.6
1963 for (size_t i = 0; i < equations.size(); i++) 1964 if (tag_eqns.find(i) == tag_eqns.end()) 1965 eqns.insert(i); 1966 1967 // remove from equations, equations_lineno, equation_tags, equation_tags_xref 1968 vector<BinaryOpNode *> new_eqns; 1969 vector<int> new_equations_lineno; 1970 map<int, int> old_eqn_num_2_new; 1971 for (size_t i = 0; i < equations.size(); i++) 1972 if (eqns.find(i) != eqns.end()) 1973 { 1974 set<pair<int, int>> result; 1975 equations[i]->arg1->collectDynamicVariables(SymbolType::endogenous, result); 1976 if (result.size() == 1) 1977 excluded_vars.push_back(result.begin()->first); 1978 else changed this line in version 2 of the diff
1988 if (!endog_found) 1989 { 1990 cerr << "ERROR: Equation " << i 1991 << " has been excluded but does not have a single variable on LHS or `endogenous` tag" << endl; 1992 exit(EXIT_FAILURE); 1993 } 1994 } 1995 } 1996 else 1997 { 1998 new_eqns.emplace_back(equations[i]); 1999 old_eqn_num_2_new[i] = new_eqns.size() - 1; 2000 new_equations_lineno.emplace_back(equations_lineno[i]); 2001 } 2002 int n_excl = equations.size() - new_eqns.size(); 2003 I think you should check that a given variable is not excluded two times. Said otherwise, you can either check that
excluded_vars
is composed of distinct elements, or you can convert it to astd::set
and check that it has sizen_excl
(but it's more difficult to give a meaningful error message in the latter case, because you can't easily determine which endogenous is repeated).
added 6 commits
-
c4bd6d71...1ec3923a - 5 commits from branch
Dynare:master
- 64437229 - introduce command line options: `exclude_eqs` and `include_eqs`
-
c4bd6d71...1ec3923a - 5 commits from branch
added 1 commit
- 0ff7a9d2 - introduce command line options: `exclude_eqs` and `include_eqs`
mentioned in commit 8be9efa4