Commit Graph

140 Commits (74ef3457b4805099ee9885b34173a0d0fd6aca61)

Author SHA1 Message Date
Sébastien Villemot 74ef3457b4
Use secure URL for link to GNU licenses 2021-06-09 17:21:00 +02:00
Sébastien Villemot c5f9ae89e7
Implement new “occbin” option to “model” block
For the time being, the preprocessor will refuse that this option be used with
any command other than estimation.

By the way, remove occbin_likelihood and occbin_smoother options to estimation.

Ref. dynare#569
2021-05-31 10:00:59 +02:00
Sébastien Villemot c2d47fb48e
Julia: remove driver file
The Julia code now uses the JSON output for retrieving the information that
previously was in the driver file.
2021-04-19 17:02:41 +02:00
Sébastien Villemot af9bd8f109
Remove the unfinished decomposition in linear and nonlinear blocks
Also remove the det_cond_forecast interface, that was related to it.

Ref. dynare!1626
Closes: #39
2021-01-25 18:03:37 +01:00
Sébastien Villemot cfb41d291c
Substitute out model-local variables early in the model transform pass
Incidentally, this makes it possible to use model-local variables with either
the “block” or “bytecode” option. (Ref: dynare#1243)
2020-11-10 18:07:57 +01:00
Sébastien Villemot 1e419a48e4
Remove unused function 2020-11-10 18:02:06 +01:00
Sébastien Villemot d2cbe2a19e
PAC model: fixes to M_.pac.MODEL.ar (information about autoregressive part)
– Fix order of items in this structure. Previously, items were ordered
  according to the declaration order of parameters. Now, items are order
  according to lag order (first lag appears first)
– Gracefully handle the case where there is no autoregressive part
  (Closes: #52)
2020-10-16 16:31:51 +02:00
Sébastien Villemot feee0ffa12
PAC model: better error message when pac_expectation refers to a non-existent pac_model
Closes: #53
2020-09-10 14:24:20 +02:00
Sébastien Villemot 3b3589b958
PAC model: rewrite the algorithm for detecting the target, to make it more robust
Closes: #54
2020-07-23 17:19:16 +02:00
Sébastien Villemot ad5e196d30
Block decomposition now compatible with 'use_dll' option 2020-06-23 15:13:04 +02:00
Sébastien Villemot 479c2c029f
Block decomposition: move core of the routine for writing per-block files in separate function
This is a preparatory step to allow use_dll with block decomposition.
2020-06-22 14:18:21 +02:00
Sébastien Villemot c6a17913b4
Rename {Static,Dynamic}Model::writeOutput() to ::writeDriverOutput() for clarity 2020-05-20 11:44:40 +02:00
Sébastien Villemot becc433d56
Rename byte_code to bytecode for consistency with user option name 2020-05-20 11:39:59 +02:00
Sébastien Villemot 96657b4974
Block decomposition: refactor code that writes the block structure to the driver file 2020-05-20 11:35:14 +02:00
Sébastien Villemot 2944484442
Bytecode: rename output methods for better consistency 2020-05-19 17:45:33 +02:00
Sébastien Villemot 1d838e96ff
Block decomposition: simplify routines for writing output dynamic/static M files 2020-05-19 17:33:58 +02:00
Sébastien Villemot a2bea00fee
Block decomposition: another fix related to temporary terms refactoring
Temporary terms need to be computed per equation (as was done previously), and
not simply per block.

It’s necessary to track temporary terms per equation, because some equations
are evaluated instead of solved, and an equation E1 may depend on the value of
an endogenous Y computed by a previously evaluated equation E2; in this case,
if some temporary term TT of equation E2 contains Y, then TT needs to be
computed after E1, but before E2.
2020-05-13 16:58:19 +02:00
Sébastien Villemot 2e6bc7ecaa
Bytecode: fix handling of temporary terms
They were broken by 49036f166d
2020-05-13 12:53:47 +02:00
Sébastien Villemot 49036f166d
Block decomposition: refactor code for computing temporary terms
In particular, in dynamic models, temporary terms are now computed for
derivatives w.r.t. exogenous, and also w.r.t. endogenous variables that do not
belong to the block.
2020-05-12 18:39:13 +02:00
Sébastien Villemot 9f361e9e37
Block decomposition: simplify code for ordering dynamic Jacobian columns 2020-05-06 14:21:24 +02:00
Sébastien Villemot 38ccd5e0cf
Block decomposition: remove unneeded code for bytecode 2020-05-05 17:15:08 +02:00
Sébastien Villemot 4f453320d1
Block decomposition: remove unneeded code for exogenous 2020-05-05 16:17:22 +02:00
Sébastien Villemot cb61ee8506
Block decomposition: make structures storing derivatives w.r.t. other endo/exo symmetric with those for endos belonging to the block 2020-04-30 18:24:24 +02:00
Sébastien Villemot 4948adf2cd
Block decomposition: remove unused data structure 2020-04-29 17:47:48 +02:00
Sébastien Villemot 2e136cae56
Block decomposition: simplify computation of block derivatives
— use a std::map for storing block derivatives
— remove redundant ModelTree::first_chain_rule_derivatives structure
— remove unused codepaths in StaticModel
— DynamicModel: simplify code that determines the type of derivatives in a
  block. We now use a slightly different categorization.
— by the way, fix the max lead/lag information for blocks that are obtained via
  merging. A workaround was previously implemented in
  DynamicModel::get_Derivative(), but it is no longer needed with this fix.
2020-04-28 12:26:51 +02:00
Sébastien Villemot a741799f90
Block decomposition: factorize various helper functions
Should have been done in 76c2e87c3b.
2020-04-17 16:04:19 +02:00
Sébastien Villemot 7327fb9f17
Block decomposition: give more explicit names to ModelTree::{inv_,}{equation,variable}_reordered 2020-04-17 15:09:22 +02:00
Sébastien Villemot 4d30f17e0b
Block decomposition: move collectFirstOrderDerivativesEndogenous in ModelTree
By the way, use camel case for the function name.
2020-03-30 14:51:53 +02:00
Sébastien Villemot 50776a766a
Remove the unsignedness of many integer variables and function arguments
This was only adding unneeded complexity, for no clear reason (we’re very far
from reaching 2³¹ equations, and if we wanted to support models that large, it
would be better to use long integers to avoid being limited to 2³²).
2020-03-24 18:28:03 +01:00
Sébastien Villemot 92c3cbdfa1
Remove unused classes 2020-03-24 17:04:53 +01:00
Sébastien Villemot ce1cbb3e52
Block decomposition: turn EquationType into an enum class 2020-03-20 18:00:56 +01:00
Sébastien Villemot bd6eee93df
Block decomposition: refactor the prototypes of various functions
— return output arguments on the left-hand side
— do not pass class members as input/output arguments

By the way, fix a (benign) vector allocation bug in
{Static,Dynamic}Model::computeChainRuleJacobian().
2020-03-19 17:47:12 +01:00
Sébastien Villemot 76c2e87c3b
Block decomposition: factorize data structures between StaticModel and DynamicModel 2020-03-17 18:58:34 +01:00
Houtan Bastani 7371558321
rework equation tags
Create new EquationTags class to simplify use of equation tags throughout the code and avoid repeated code

issue #38
2020-02-21 17:49:38 +01:00
Sébastien Villemot 23a08a3662
Ensure that dynamic model files contains all the derivatives that have been computed
Previously, there could be a discrepancy if the order mandated by
“identification” was less that the one mandated by “stoch_simul”.

Ref. #40
2020-01-20 17:22:32 +01:00
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 3694fc40b3
detrend epilogue equations 2019-12-11 14:45:47 +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
Sébastien Villemot 5a5817b4fe
Improvements to the test for balanced growth path
— 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
2019-11-14 17:55:17 +01:00
Dóra Kocsis 7a78593df4 introduce variableMapping, default equation name tags in M_ and JSON output 2019-10-30 16:30:51 +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
Sébastien Villemot 2a127b1f23
VAR/TCM models: use lag-equivalence relationship to compute maximum lags
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.
2019-10-22 16:04:24 +02:00
Sébastien Villemot 8a83e08e79
Fix bug with diff or unary ops that have same static representation
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
2019-10-22 15:01:06 +02:00
Houtan Bastani 6191c69d74
move to hash algorithm defined since C++11 for calculating checksums. dynare#1661 2019-10-07 17:43:16 +02:00
Houtan Bastani 92ad5aad2c
Revert "add info about max endo/exo lag by variable. closes dynare#1596"
This reverts commit 7827d2e04d.
2019-09-24 14:03:38 +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
Houtan Bastani 7827d2e04d
add info about max endo/exo lag by variable. closes dynare#1596 2019-09-09 14:29:22 +02:00