Commit Graph

102 Commits (74ef3457b4805099ee9885b34173a0d0fd6aca61)

Author SHA1 Message Date
Sébastien Villemot 4e2538a2a2
Ensure original tags and line numbers are preserved with ramsey_model
In particular, introduce a method for clearing all equations, so that tags and
line numbers are also cleared.

Ref. dynare#1685
2020-01-06 18:26:35 +01:00
Sébastien Villemot e2d5a83592
Global reindentation 2019-12-20 16:59:30 +01:00
Sébastien Villemot 031c0cff5f
Various code simplifications and modernizations 2019-12-16 19:42:59 +01:00
Sébastien Villemot 2af26ee2c2
Ramsey: use information from transformed model for filling M_.nonzero_hessian_eqs
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
2019-12-13 18:02:35 +01:00
Houtan Bastani 02cb4cc973
add compiler statement
Allows the user to set the compiler, flags, and libs to be used with `use_dll`

Issue #35
2019-12-04 16:57:20 +01:00
Sébastien Villemot 23ff36a0dd
Systematically compute recursive ordering of auxiliary equations
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
2019-12-03 14:26:13 +01:00
Houtan Bastani e3a3979eba
remove unnecessary line included in 0ff7a9d 2019-11-26 16:37:01 +01:00
Houtan Bastani 0ff7a9d2ab
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]`.
2019-11-26 14:16:00 +01:00
Houtan Bastani fa9c9435ff
add xref for equation tags 2019-10-29 14:05:55 +01:00
Sébastien Villemot ecdca502aa
Modernization: stop using make_pair() and make_tuple()
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).
2019-10-24 10:49:13 +02:00
Houtan Bastani 8211edc4e8
fix typo 2019-10-10 15:31:03 +02:00
Sébastien Villemot 0c755460b1
Use std::filesystem instead of boost::filesystem
Note that there is no equivalent of boost::filesystem::unique_path(), so I
implemented ModFile::unique_path() which does something similar.
2019-09-11 14:47:48 +02:00
Sébastien Villemot 0988a1f755
Generated LaTeX files are now under <basename>/latex/ 2019-07-11 17:33:53 +02:00
Sébastien Villemot 176732ee2c
ModelTree: pass argument by const-reference rather than by value in some methods 2019-07-05 18:41:13 +02:00
Houtan Bastani 21fe0f4bdc
avoid cast warnings when compiling boost headers 2019-04-23 14:57:03 +02:00
Sébastien Villemot 43906691d3
JSON: simplification of method for writing temporary terms 2019-04-18 17:10:39 +02:00
Sébastien Villemot b73d554ad2
Use Unicode copyright symbol (in UTF-8 encoding) 2019-04-16 11:35:31 +02:00
Houtan Bastani 02ae0af3e5
change map type for readability 2019-01-29 17:43:17 +01:00
Houtan Bastani f5df7e7567
when an equation is of the form `X` = `constant`, replace all occurrences of `X` in other equations with `constant` 2019-01-28 15:32:12 +01:00
Sébastien Villemot 571b5d0816
Computation of temporary terms generalized to any derivation order 2018-11-30 12:22:13 +01:00
Sébastien Villemot d733f3fb5a
Various simplifications and modernizations of the block/bytecode part 2018-11-23 17:19:59 +01:00
Sébastien Villemot e3a3992c1c
Derivation engine w.r.t. parameters generalized to any order
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.
2018-11-22 17:13:55 +01:00
Sébastien Villemot 6fa115aedd
Derivation engine w.r.t. endogenous generalized to any order 2018-11-22 17:13:55 +01:00
Sébastien Villemot b524e19cde
Remove duplicate storage of temp terms for params derivs in ModelTree 2018-11-16 18:26:36 +01:00
Sébastien Villemot e9b5f239df
Properly deal with model local variables in params derivatives file
Closes #13
2018-11-16 18:26:11 +01:00
Sébastien Villemot 3d2125287a
Temporary terms: various simplifications and added comments 2018-11-16 17:11:06 +01:00
Sébastien Villemot e89dd9cb8b
Make storage of derivatives ready for k-order
This is the first step towards computing k-order derivatives.

Ref Dynare/dynare#217, #10
2018-11-15 17:48:46 +01:00
Sébastien Villemot 4a974bb428
The preprocessor now compiles the MEX when use_dll is specified
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.
2018-10-26 18:09:13 +02:00
Sébastien Villemot ac94ad906e Various fixes for silencing errors and warnings under Clang 6 2018-10-11 11:21:58 +02:00
Sébastien Villemot f2cf86b734 Add copy constructors / assignment operators for the DataTree class hierarchy
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.
2018-10-10 12:53:55 +02:00
Sébastien Villemot 7bb5382428 Always use brace-initializer in constructors
The syntax makes clearer the distinction between a function call and an
initialization. Also, it prevents bugs due to implicit type conversions.
2018-10-04 17:19:18 +02:00
Ferhat Mihoubi 139e3efa82 Adds a new model option "linear_decomposition" that creates a block composed of the non-linear equations o the model 2018-09-28 14:54:52 +02:00
Sébastien Villemot c6cb9aa1b8 Fix bug in option notmpterms with model local variables
Since model local variables are now treated as temporary terms, they must be
marked as such even when option notmpterms is present.
2018-09-25 15:57:56 +02:00
Houtan Bastani 85dbb649b7 move trend_component_table and var_model_table to DynamicModel as they are only used there 2018-09-14 17:04:06 +02:00
Houtan Bastani 539fddc9f6 introduce var model table 2018-08-22 12:15:02 +02:00
Houtan Bastani afe0e475b1 trend_component_model statement 2018-08-17 16:52:48 +02:00
Sébastien Villemot b9ee0bb204 aux_equations may diverge from those in the main model
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 */
2018-07-27 14:20:36 +02:00
Sébastien Villemot 762f25abe9 Remove useless separate list for diff auxiliary variables
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.
2018-07-26 17:41:58 +02:00
Sébastien Villemot b91ed6f78c Move the location of static and dynamic files on the filesystem
- M and MEX files are now under +${MODELNAME}/
- bytecode and C source now under ${MODELNAME}/model/
2018-06-27 15:30:25 +02:00
Sébastien Villemot 130004ef47 Simplify types for storing derivatives using std::tuple 2018-06-05 15:34:34 +02:00
Sébastien Villemot 608c43450c Replace most calls to make_pair by braced-initializer lists or emplace()/emplace_back() 2018-06-04 16:36:46 +02:00
Sébastien Villemot 7d9cd718fc Replace more typedefs by using
Those were not automatically replaced by clang-tidy, I don’t know why…
2018-06-04 15:03:31 +02:00
Sébastien Villemot 182c53273e Remove useless spaces in type qualifiers
In C++11, it is no longer necessary to put a space between two consecutive ">".
2018-06-04 15:03:31 +02:00
Sébastien Villemot f8cc3ae355 Port to C++11 using keyword
Performed using modernize-use-using from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html
2018-06-04 15:03:31 +02:00
Sébastien Villemot e73ebc7033 Port to C++11 noexcept keyword
Performed using modernize-use-noexcept from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-noexcept.html
2018-06-04 15:03:31 +02:00
Sébastien Villemot 3f874cfced Remove obsolete function 2018-05-28 16:39:28 +02:00
Sébastien Villemot ea3573180a Fix ordering of model local variables 2018-05-28 15:50:29 +02:00
Sébastien Villemot dd6799187c Fix derivs w.r.t. parameters with temporary terms array 2018-05-28 15:23:15 +02:00
Sébastien Villemot 164a6f303b Fix bug in temporary terms array in the presence of model local variables
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_*).
2018-05-24 19:35:21 +02:00
Houtan Bastani ec215e2a44 separate temporary terms: WIP 2018-03-28 16:41:48 +02:00
Houtan Bastani feb5b93eea create function to calculate aux vars as dseries 2018-03-02 17:50:35 +01:00
Houtan Bastani b504f160ca move files to src directory 2018-02-15 11:48:04 +01:00