Since commit 9c9e8f816f, it’s the information
from the original model which was in this field, which is not what is expected.
By the way, do not output this field (and the related M_.hessian_eq_zero) when
the Hessian is not computed by the preprocessor (i.e. in practice for perfect
foresight), since they would otherwise contain incorrect information.
Ref. dynare#1681
Auxiliary equations appearing in set_auxiliary_variables.m and
dynamic_set_auxiliary_series.m need to appear in recursive ordering, since
those files are used for sequential evaluation.
Previously, the recursive ordering was guaranteed by a set of ad hoc rules and
workarounds, but that would not cover certain edge cases.
With this commit, the recursive ordering is systematically computed, using a
topological sort on the directed acyclic graph whose vertices are auxiliary
equations and whose edges are dependency relationships.
Closes: #22
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]`.
— Raise the default tolerance for cross-derivatives to 1e-6, to reduce the
number of false positives
— New option “balanced_growth_test_tol” to the “model” block for changing that
tolerance
— Turn back test failures into errors. Since there is now an option for
controlling the tolerance, the user always has the possibility of making the
test pass.
Closes: dynare#1389
In many cases, they can be replaced by the curly braces syntax.
Otherwise, we can now use the pair() and tuple() constructors, without the need
to specify template parameters, thanks to class template argument
deduction (new in C++17).
This is made possible by the getLagEquivalenceClass() method introduced in the
previous commit.
Previously, the static version of the LHS expressions was used.
As a consequence, drop ModFile::diff_static_model, now useless.
Previously, for testing whether two diff() expressions or two unary ops were
the lead/lag of each other, the preprocessor would test whether they have the
same static representation. This is ok for simple expressions (e.g.
diff(x(-1))), but not for more complex ones (e.g. diff(x-y) and diff(x(-1)-y)
should not be given the same auxiliary variable).
This commit fixes this by properly constructing the equivalence relationship
and choosing a representative within each equivalence class. See the comments
above lag_equivalence_table_t in ExprNode.hh for more details.
Closes#27
Furthermore, modifications to model local variables were not taken into account.
To fix, take checksum of model local variables, temporary terms, and equations
Also, use existing functions to print these to a stringstream instead of repeating print functionality in this function
Backward incompatible change: the temporary terms for 3rd order are now stored
in "temporary_terms_third_derivative" (without the final "s"; same for external
functions), for consistency with the name of the slot for the derivatives
themselves ("third_derivative").
Ref dynare#217
Does not work for Julia mode, neither with block and bytecode.
Note: in DLL mode, the number of temporary terms in no longer given in the
‘ntt’ symbol; it must be computed using ‘M_.dynamic_tmp_nbr’.
Ref dynare#217
The idea is to make use of the dynamic_set_auxiliary_dseries.m file to generate
the initial conditions for all auxiliary variables, including the diffs.
Also remove the check done by the preprocessor for the lags in histval, since
it does not work correctly with the diff operator.
The engine is now more robust and should reject any expression that does not
conform to the expected form. It is also able to deal with more cases, such as
terms appearing with a minus sign, or variables in the middle of a
three-factors product.
BTW, use a std::tuple for storing the result of the matching inside
PacExpectationNode, and change the order of components within the
structure (variable first, scalar last).
The preprocessor now writes all the symmetric elements in the "hp"
matrix (derivatives of the hessian w.r.t. parameters), for consistency with all
other derivatives output.
Previously it was only writing one of the two symmetric elements, when indices
of endogenous were different.
Also, no longer compute two times symmetric elements in derivation w.r.t.
parameters at order 2, for consistency with derivation w.r.t. endogenous.
It is therefore now necessary to duplicate them in the output to keep behavior
unchanged.
When creating the sparse matrix (in MATLAB or C mode), since storage is in
column-major order, output the first column, then the second, then the third.
This gives a significant performance boost in use_dll mode (at both compilation
and runtime), because it facilitates memory accesses and expression reusage.
New options "mexext" and "matlabroot" are introduced, so that the preprocessor
knows where to find MATLAB and which architecture to compile for.
Only recent gcc is now supported. A set of optimization flags is used so that
compilation goes reasonably fast on large models.
Consequently, options "msvc", "mingw" and "cygwin" have been removed.
In particular, it is necessary to turn back DataTree::AddVariable() into a
non-virtual method, because it is called from DataTree's constructor. Enforcing
the absence of leads/lags is now done using a new boolean DataTree::is_static.
Take advantage of the new copy constructor for handling
PlannerObjectiveStatement more elegantly.
Unfortunately it is not possible to implement *move* constructor / assigment
operators, because the reference ExprNode::datatree is not mutable.
This facilitates switching variable types on the fly. In particular, this
allows removing the hack in DynamicModel::updateAfterVariableChange() that way
basically recreating all the nodes after the type change.
This mimicks the structure of M-functions (though the logic for filling the
temporary terms vector is a bit different).
This change implied a modification in the way we compute the checksum in case
of block decomposition (the temporary terms for the C output are not correctly
computed in that case).
Given a previously declared var_model, the var_expectation_model statement is
used to declare a way of forming expectations with this VAR (possibly using a
finite or infinite discounted sum). The var_expectation operator now takes a
single argument, the name of the var_expectation_model.
For the moment, this only works when the var_model is using equations
explicitly declared in the model block.
aux_equations only contain the definition of auxiliary variables, and
may diverge from those in the main model (equations), if other model
transformations applied subsequently. This is not a problem, since
aux_equations is only used for regenerating the values of auxiliaries
given the others.
For example, such a divergence appears when there is an expectation
operator in a ramsey model, see
tests/optimal_policy/nk_ramsey_expectation.mod */
This table serves no useful purpose. It is better to append auxiliary equations
at the time they are created, to avoid messing with the recursive ordering.
Ensure that all diff operators appear once with their argument at current
period (i.e. maxLag=0).
If it is not the case, generate the corresponding expressions.
This is necessary to avoid lags of more than one in the auxiliary
equation, which would then be modified by subsequent transformations
(removing lags > 1), which in turn would break the recursive ordering
of auxiliary equations.
See McModelTeam/McModelProject/issues/95 for an example.
In the absence of this option, if a var_model statement(s) is present, then aux vars/eqs are created for the same types of unary operators but only for equations specified in the var_model statement
In the absence of both this option and var_model statements, no unary op auxiliary variables are created
diffs continue to be substituted everywhere; for the moment auxiliary variables are created for diffs of expressions. A forthcoming change will allow auxiliary variables created for diffs of expressions to be linked with their lagged expressions as is currently the case for diffs of variables
More precisely, remove those variants where temporary_terms can be specified
without temporary_terms_idxs, in order to make clear that the latter is
expected. For situations where the tt_idxs are not needed (C, block MATLAB), an
empty map has to be explicitly given.
The version with no temporary_terms_idxs argument needs not be virtual, since
it is the same implementation in all derived classes. Rather move it at the
level of the base ExprNode class.
In the presence of MLVs, the temporary terms indexing was corrupted. The code
was using the implicit assumption that the ExprNodeLess ordering was giving the
same ordering as the temporary terms indexes ordering. But MLVs can be higher
in ExprNodeLess ordering than some other temporary terms, while they have the
lowest temporary terms index, hence the bug.
Fix this by no longer relying on the ExprNodeLess ordering, and rather use a
full map<ExprNode *, int> for ModelTree::temporary_terms_idxs. By the way,
simplify the code by removing a few useless data structures (e.g.
ModelTree::temporary_terms_idxs_*).