Sébastien Villemot
f349e22f4c
Macro processor: fix error message when @#include is used with nonexistent file
2022-12-14 15:22:20 +01:00
Sébastien Villemot
50a2737e41
Macro processor: fix tracking of line numbers after @#define, @#include and @#includepath directives
...
Closes : #108
2022-12-14 15:22:07 +01:00
Sébastien Villemot
8734bc5ca6
Allow LOG_* auxiliary variables in various commands
...
Closes : #107
2022-12-14 12:42:55 +01:00
Sébastien Villemot
a234176d3c
Julia: do not rewrite derivatives w.r.t. parameters files when unmodified
...
Closes : #105
2022-12-14 12:35:50 +01:00
Sébastien Villemot
a5eac0260a
JSON: fix output of date options
...
They were not enclosed within quotes.
Ref. dynare#1875
2022-12-14 12:16:04 +01:00
Sébastien Villemot
2758f46c83
Fix indexing in M_.endo_trends
...
It would use 0-based indexing, instead of 1-based.
Ref. dynare#1648
Closes : #109
2022-12-14 12:05:12 +01:00
Sébastien Villemot
8cb3437d2d
Minor simplification in static block decomposition driver output
2022-12-12 14:57:50 +01:00
Sébastien Villemot
4aa1ff1f73
Sparse representation: fix bug in output of indices in driver and JSON files
...
Jacobian column numbers were incorrect (it would return internal derivation
IDs).
Ref. dynare#1859
2022-12-12 14:57:49 +01:00
Sébastien Villemot
4f7794a8f9
Sparse representation: compatibility fix with MATLAB < R2020a
...
For those older MATLABs, the “sparse” function does not accept vectors of
integer data type as indices.
Ref. dynare#1875
2022-12-08 14:35:23 +01:00
Sébastien Villemot
83bfc792af
Sparse representation: fix bug in output of indices in driver and JSON files
...
It would previously forget to write the indices for the highest derivation
order (e.g. if order=3, then it would only write sparce indices up to 2nd
order).
Ref. dynare#1859
2022-12-07 16:10:03 +01:00
Johannes Pfeifer
9b015a6a10
Add new mh_init_scale_factor-option
2022-12-01 15:23:37 +01:00
Sébastien Villemot
c48248fc0d
Implement time-recursive block decomposition tuned for purely backward/forward/static models
...
Such a decomposition has to be simulated with periods as the outer loop and
blocks as the inner loop.
It is enabled by default for purely backward/forward/static models, as long as
the “block” option is not given. In that case, “mfs” is also set to 3 by
default (until that value becomes the global default).
M_.time_recursive_block_decomposition is set to “true” when that decomposition
has been performed, “false” otherwise for the traditional decomposition (the
latter has to be simulated with blocks as the outer loop and periods as the
inner loop).
2022-11-30 14:43:44 +01:00
Sébastien Villemot
bb3475d548
Remove call to setup_solvers.m
...
It is no longer used in the new implementation of solve_algo={12,14}.
However, the M_.lhs field that was created by setup_solvers.m is used from
other places, so reimplement it at the preprocessor level.
2022-11-30 14:43:44 +01:00
Sébastien Villemot
ff296023a9
Block decomposition: ModelTree::block_decomposed field was not properly set on copy/move
2022-11-29 15:27:12 +01:00
Sébastien Villemot
53add0b2fe
Block decomposition: when falling back to symbolic normalization, use contemporaneous symbolic Jacobian
...
Previously, it would use a symbolic Jacobian where leads and lags were also
taken into account.
2022-11-28 13:40:49 +01:00
Johannes Pfeifer
56c62197d0
DynareBison.yy: add nobs and heteroskedastic_filter options to calib_smoother
2022-11-23 13:46:53 +01:00
Sébastien Villemot
e01c748c7e
Julia: fix prototype of function computing dynamic derivatives w.r.t. parameters
2022-11-22 11:19:58 +01:00
MichelJuillard
cf4e2194b7
Julia: remove module for derivatives w.r.t. parameters
2022-11-22 10:18:11 +00:00
Sébastien Villemot
2e171e28de
New files for helping a user to debug their model
...
The files are created under <basename>/+debug/dynamic_resid.m and
<basename>/+debug/static_resid.m.
Their purpose is to evaluate separately the LHS and RHS of each equation.
2022-11-16 11:18:09 +01:00
Sébastien Villemot
4807a6c880
use_dll: fix race condition with compilation of power_deriv.{c,h}
2022-11-14 13:45:15 +01:00
Sébastien Villemot
23b0c12d8e
Performance improvement of chain rule derivation, using caching
...
Useful for mfs > 0 on large models.
2022-11-08 12:34:05 +01:00
Sébastien Villemot
dbc2851606
Merge branch 'max_check_ahead_periods' of git.dynare.org:JohannesPfeifer/preprocessor
...
Ref. !69
2022-11-07 16:32:10 +01:00
Johannes Pfeifer
ed95a2ca2d
OccBin: add interface for max_check_ahead_periods option
...
Related to 2f23604824
2022-11-04 23:11:59 +01:00
Sébastien Villemot
1430ab9cc2
Implement new sparse model representation in C
...
Ref. dynare#1859
2022-11-04 14:23:29 +01:00
Sébastien Villemot
836351565d
Fix segfault of notmpterms option with block decomposition
...
By the way, ensure that temporary terms associated to external functions are
not removed, since they are not optional.
2022-11-04 14:23:29 +01:00
Sébastien Villemot
4ab3e937ea
Implement new sparse model representation in MATLAB/Octave
...
Ref. dynare#1859
2022-11-04 14:23:29 +01:00
Sébastien Villemot
2a8e26310d
Block decomposition: fix computation of recursive variables with mfs>0
...
Within a block, if mfs>0, the recursive variables would not appear in recursive
order. This could lead to wrong results in case of dependency relationships
between recursive variables.
2022-11-04 14:23:29 +01:00
Sébastien Villemot
47290087f6
Provisions for new sparse representation of block-decomposed dynamic/static files
...
The stochastic mode in currently unsupported.
This commit adds new fields in M_.
This is a preliminary step for dynare#1859.
2022-11-04 14:23:29 +01:00
Sébastien Villemot
1ed72f6da2
Write block decomposition information in M_ independently of “block” option
...
This is now possible since the block decomposition is always computed. Of
course, the information is not printed if the decomposition failed.
2022-11-04 14:23:29 +01:00
Sébastien Villemot
00fd9dadb6
Julia: no longer write the main dynamic/static files in legacy representation
2022-11-02 15:51:26 +01:00
Sébastien Villemot
6aca84bfbb
Julia: move all generated files to the <basename>/model/julia/ subdirectory
2022-11-02 15:49:57 +01:00
MichelJuillard
6af8a57f9f
replace Julia modules by simple functions
2022-11-02 15:49:56 +01:00
Sébastien Villemot
762243c705
Julia: drop get_power_deriv function from module
...
The function is now provided separately by Dynare.jl.
2022-11-02 15:49:56 +01:00
Sébastien Villemot
4ae6df494d
JSON: add dynamic_tmp_nbr and static_tmp_nbr
...
As a consequence, remove the “tmp_nbr” variable from the Julia modules, since
it is now redundant.
2022-11-02 15:49:56 +01:00
Sébastien Villemot
723fc4139b
Implement new sparse model representation in Julia
...
Ref. dynare#1859
2022-11-02 15:49:56 +01:00
Sébastien Villemot
0278c8577c
Provisions for new sparse representation of dynamic/static files
...
The new representation is only supported for MATLAB/Octave, C and Julia output
for the time being. Bytecode and JSON are unsupported.
This commit adds new fields in M_.
This is a preliminary step for dynare#1859.
2022-11-02 15:49:56 +01:00
Sébastien Villemot
30853e7360
Block decomposition: improve debugging information for normalization
...
– print the information only for the final matching (and not the intermediary
ones that may have failed);
– print the equation name next to its number.
2022-11-02 15:49:56 +01:00
Sébastien Villemot
627dd92c64
Block decomposition: bugfix with temporary terms when mfs=3
...
In an “evaluate” block, the LHS of a renormalized equation (such as “log(x)=…”)
could be associated to a temporary term that would then be incorrectly
computed: that temporary term would be evaluated *before* (and not after) the
evaluation of the associated variable (“x” in the example).
2022-10-26 17:33:26 +02:00
Johannes Pfeifer
d5cf07fadd
Occbin: implement simul_reset_check_ahead_period-option
...
Related to dynare@3765ef77 (dynare!2094)
2022-10-24 10:30:45 +02:00
Sébastien Villemot
219c8d2a47
Do not error out in stochastic mode if mfs > 0 but “block” option not passed
...
In that case, the block-DR routines will not be called.
2022-10-18 17:39:14 +02:00
Sébastien Villemot
5a6e276750
Fix comment
2022-10-18 17:39:14 +02:00
Sébastien Villemot
79c8fe61b1
Fix typo
2022-10-18 17:39:14 +02:00
Sébastien Villemot
a31ef6069c
Correctly handle diff operator in equation renormalization
...
Should have no impact though, since diff nodes are already substituted out at
that point. But it’s better to implement it properly, in case we change the
substitution rules later.
By the way, make the computeSubExprContainingVariable method protected.
2022-10-18 17:39:14 +02:00
Sébastien Villemot
9f96db89ba
use_dll: ensure proper cleanup of thread workers threads in case of early exit (e.g. upon failure)
2022-10-17 14:03:27 +02:00
Sébastien Villemot
781e10c24b
Error out if “use_dll” is specified in Julia mode
2022-10-14 15:40:09 +02:00
Sébastien Villemot
fd9902e87b
use_dll: rewrite the parallel compilation engine with a fixed number of threads
...
The previous system would spawn as many threads as there are object files to be
compiled (which could lead to hundreds of threads for large block-decomposed
models). This could pose a memory usage problem (even when not just waiting,
threads require memory for their own stack).
2022-10-14 15:33:52 +02:00
Sébastien Villemot
e801f1a862
Fix typo
...
[skip ci]
2022-10-11 18:15:11 +02:00
Sébastien Villemot
39051aeb30
Make the hack for MATLAB+Windows directory lock work with any recursive directory structure
...
This simplifes the treatment of the new sparse representation, which creates
several subdirectories in the “+” package folder.
2022-10-11 17:26:47 +02:00
Sébastien Villemot
93054cf692
Various filesystem refactorings
...
– DataTree::packageDir() now takes a std::string_view, returns a
std::filesystem::path, and no longer creates that directory
– DataTree::writeToFileIfModified() now takes a std::filesystem::path as
argument
– Do not call DataTree::writeToFileIfModified() for generating MATLAB/Octave
files, since it does not work (the directory inside which the file is written
has been deleted by the preprocessor just before)
– Consistently use DataTree::packageDir() everywhere (for compatibility with
planner_objective)
2022-10-11 16:28:17 +02:00
Sébastien Villemot
198ff70bce
Simplify strsplit() using std::string_view
...
By the way:
– improve the semantics by having a consistent treatment of empty substring
components (previously, only the last one was ignored)
– move it to DataTree to make it more accessible from elsewhere (even though
ideally it should be in a “utilities” namespace).
2022-10-11 16:23:11 +02:00
Sébastien Villemot
2fb9aa2a60
Minor simplification using argument dependent lookup (ADL)
2022-10-11 11:31:18 +02:00
Sébastien Villemot
5b400b69f0
Use std::filesystem::path::string() when writing paths to std::cout/std::cerr
...
Otherwise they will be quoted, which is not desirable, especially under
Windows (backslashes will be duplicated).
2022-10-11 11:31:15 +02:00
Sébastien Villemot
e0b2583ff9
Streamline informative messages
2022-10-07 18:04:18 +02:00
Sébastien Villemot
3dd40c6c42
use_dll: split generated C file into smaller files that will be compiled in parallel
...
By the way, factorize the code between the dynamic and static versions.
Ref. #41
2022-10-07 18:04:18 +02:00
Sébastien Villemot
dd66459e5f
use_dll: parallelize compilation of multiple object files within single MEX file
...
In particular, it implements dependency tracking in the thread scheduler, so
that multiple MEX files can share object files.
Ref. #41
2022-10-07 18:04:17 +02:00
Sébastien Villemot
5cf4729ab0
use_dll: dynamically limit the number of concurrently running GCC processes to the number of available logical processors
...
Ref. #41
2022-10-07 18:04:17 +02:00
Sébastien Villemot
49a530a775
use_dll: allow more flexible output directory in interface of ModelTree::compileMEX()
2022-10-07 18:04:17 +02:00
Sébastien Villemot
d9bda244d4
use_dll: refactor MEX compilation so that it happens inside “write” methods
2022-10-07 18:04:17 +02:00
Sébastien Villemot
08a86b67cb
Drop logic for selecting whether to compute derivatives w.r.t. exogenous
...
We now always compute those derivatives, so no need for an alternate codepath.
2022-10-07 18:04:17 +02:00
Sébastien Villemot
8cac64c1cb
use_dll: fix bug where operator abs() within a .mod file would return an incorrect result
...
It would compute the *integer* part of the absolute value (calling “abs”
instead of “fabs” from the C source).
2022-10-07 18:04:00 +02:00
Sébastien Villemot
5c33051990
Use std::string_view in a few places where it makes sense
2022-10-04 16:47:16 +02:00
Sébastien Villemot
4c58451d83
Factorize computing pass for block decomposition
...
Also add “block_decomposed” data member for tracking whether the block
decomposition has been successful.
2022-10-04 16:00:30 +02:00
Sébastien Villemot
6e69eea3cf
Minor tightening of access specifiers
2022-10-04 16:00:30 +02:00
Sébastien Villemot
f6053df754
use_dll: compile MEX files in parallel
...
Currently two threads are used (one for the dynamic MEX, one for the static
MEX). When the sparse representation is implemented, four threads will be used.
Closes : #41
2022-10-04 16:00:30 +02:00
Sébastien Villemot
36fcbf6cfe
Functions that write C files now return the paths to the generated files
...
This avoids computing those paths two times (the second time when compiling them).
2022-10-04 16:00:30 +02:00
Sébastien Villemot
895a866bb3
Optimization: use move semantics in more places
2022-10-04 16:00:30 +02:00
Sébastien Villemot
6ed033f202
Bugfix: “relative_irf” option passed to “irf_calibration” was also passed to next command
2022-10-04 16:00:30 +02:00
Sébastien Villemot
3d9ac26aa6
Remove all instances of the “map.find(key)->second” pattern
...
This is unsafe since the find() method can return a past-the-end iterator,
which should be tested for.
Replace most instances by calls to the std::map::at() method (which throws if
the key is unknown), and which is incidentally more readable.
2022-09-27 12:56:16 +02:00
Sébastien Villemot
18037fd29a
Drop code for supporting temporary terms corresponding to model-local variables
...
Since model-local variables are now substituted out of the model at an early
stage (see cfb41d291c
), such temporary terms are
no longer generated.
2022-09-26 17:34:20 +02:00
Sébastien Villemot
64157d9083
Fix bug in ModelTree::writeParamsDerivativesFileHelper()
...
Elements of params_derivatives could be accessed without them being defined,
thus causing illegal memory read.
Ensure that these elements always exist. By the way, use std::map::at() instead
of std::map::find() to trigger an exception instead of an illegal memory read
in that case.
2022-09-26 17:17:47 +02:00
Sébastien Villemot
b403cef871
Put driver output of static block decomposition in a separate function
...
For symmetry with the dynamic case, and for avoiding a call to “return” in the
middle of StaticModel::writeDriverOutput().
2022-09-21 18:48:35 +02:00
Sébastien Villemot
5b12354dc3
Minor performance improvement in copy constructors/assignments of ModelTree and DynamicModel
2022-09-21 17:37:02 +02:00
Sébastien Villemot
98d4f922ca
Cosmetics
2022-09-20 15:29:19 +02:00
Sébastien Villemot
7f1b4fcc20
Refactor OptionsList class
...
In particular, use a std::variant to store the values of options. This ensures
that a given option name can have only one value (previously, for a given
option name, it was possible to store several values as long as they were of
different types).
2022-09-20 11:56:43 +02:00
Sébastien Villemot
e4449f1c4a
Add comment for special token name for “domain” keyword
2022-09-20 11:56:43 +02:00
Sébastien Villemot
8dcdcf1fd4
Fix check of “domain” option of new estimation prior syntax
2022-09-20 11:56:42 +02:00
Sébastien Villemot
3f674c1af9
Fix bug with “graph_format” option of “identification” and “dynare_sensitivity”
...
The local value of option was not copied to the top-level “options_” structure,
as it is done for “nograph” and “nodisplay”.
2022-09-20 11:56:42 +02:00
Sébastien Villemot
1088cc4242
Improve informative messages about derivatives and block decomposition
...
When computing the derivatives or block decomposition of the planner objective,
the epilogue or the original Ramsey model, the preprocessor would talk about
dynamic/static model, which was confusing. It now uses the right terminology.
2022-09-14 17:51:36 +02:00
Sébastien Villemot
d67f569035
Always compute block decomposition, even if “block” option was not passed
...
If block decomposition fails, error out if “block” option was passed, but not
otherwise.
This commit does not modify the generated files.
This is a preliminary step for dynare#1859.
2022-09-13 16:16:00 +02:00
Sébastien Villemot
1aead92cd5
Fix bug in block derivatives w.r.t. exogenous deterministic
2022-09-12 17:38:47 +02:00
Sébastien Villemot
0b5e686c8c
Turn ramsey_FOC_equations_dynamic_model into a local variable instead of a data member
2022-09-09 17:13:21 +02:00
Sébastien Villemot
2fdc8b682e
Merge branch 'BGP_space' into 'master'
...
Add missing whitespace in output of BGP warning
See merge request Dynare/preprocessor!65
2022-09-06 10:11:51 +00:00
Sébastien Villemot
482ec5fb67
macOS: bump to GCC 12 (for compilation and for use_dll)
2022-09-06 11:53:40 +02:00
Johannes Pfeifer
da5b36704d
Add missing whitespace in output of BGP warning
2022-08-03 10:52:08 +02:00
Sébastien Villemot
fc4c9a73c9
Fix comment
...
[skip ci]
2022-07-27 16:50:08 +02:00
Sébastien Villemot
c3cb7ca534
Bytecode: simplify type for storing list of instructions
...
Incidentally, make BytecodeInstruction an immutable struct, to facilitate
access to opcode in such a list.
2022-07-26 18:26:37 +02:00
Sébastien Villemot
613e0da782
Bytecode: add some comments to FNUMEXPR_
...
[skip ci]
2022-07-26 14:52:10 +02:00
Sébastien Villemot
21cecee599
Add “fsolve_options” option to “steady” command
...
Ref. dynare#1856
2022-07-22 13:43:41 +02:00
Sébastien Villemot
ad40f1365c
Block decomposition: code factorization
2022-07-21 18:20:35 +02:00
Sébastien Villemot
d4c453c422
Block decomposition: (likely) performance improvement in static file in relation to temp terms
...
Compute temporary terms for derivatives of “evaluate” mode, even though those
derivatives are not computed. This is because the temporary terms may be useful
for subsequent blocks.
By the way, add an explanatory comment for the equivalent code in dynamic file.
2022-07-21 17:31:48 +02:00
Sébastien Villemot
a97a41f6c0
Bugfix with temporary terms in block+bytecode
...
There were actually two distinct bugs, leading to incorrect results in some
corner cases:
– in the “evaluate” mode of the bytecode MEX, the temporary terms of the
derivatives “evaluate” blocks were not evaluated at runtime; but these
temporary terms may be needed for residuals of subsequent blocks;
– when the bytecode MEX was only computing residuals of the model (and not 1st
order derivatives), the temporary terms of the derivatives were not evaluated
at runtime; but these temporary terms may be needed for residuals of subsequent
blocks.
2022-07-21 17:22:08 +02:00
Sébastien Villemot
1401c85d6a
Bytecode: drop FCUML instruction
...
It’s redundant with FBINARY{BinaryOpcode::plus}.
2022-07-20 16:02:24 +02:00
Sébastien Villemot
a58109d094
Bytecode: refactor methods for writing .cod and .bin files in the block decomposition case
2022-07-20 16:02:24 +02:00
Sébastien Villemot
d598810329
Bytecode: minor simplification using syntax of sizeof operator without parentheses
2022-07-20 14:48:30 +02:00
Sébastien Villemot
50d5b916e2
Remove constructor and accessors for AuxVarInfo
...
Rather make all data members public and const, and use aggregate-initialization.
2022-07-20 14:48:30 +02:00
Sébastien Villemot
f0629555a5
Remove useless constructors (aggregate initialization is enough for those)
...
By the way, turn those classes into structs since all their members are public.
2022-07-20 14:48:28 +02:00
Sébastien Villemot
83a94aca57
Replace most uses of std::string::compare() by operator==(), for clarity
2022-07-20 11:18:20 +02:00
Sébastien Villemot
c0bfc99946
Minor simplification using std::vector::emplace_back()
2022-07-20 11:18:07 +02:00
Sébastien Villemot
435e56369c
Compatibility fixes with GCC 12
2022-07-16 12:46:16 +02:00
Sébastien Villemot
35dc7fcd81
Bytecode: fix treatment of temporary terms (in non-block mode)
...
The “temporary_terms_union.insert(it)” statement introduced in the previous
commit was in the wrong block.
By the way, replace the “switch” by an “if constexpr”.
2022-07-14 09:17:11 +02:00
Sébastien Villemot
ae150d2b1f
Bytecode: refactor routines for creating .cod file in non-block mode
2022-07-13 18:51:01 +02:00
Sébastien Villemot
89debf429a
Factorize code for writing JSON output
2022-07-12 18:04:05 +02:00
Sébastien Villemot
6da24fc763
Fix bug in JSON output for dynamic derivatives w.r.t. parameters
...
Variable and parameter indices were wrong (offset by 1).
2022-07-12 17:45:00 +02:00
Sébastien Villemot
9e6c01f132
Streamline some function names
2022-07-12 17:04:41 +02:00
Sébastien Villemot
a541d23055
Minor simplification
2022-07-12 16:39:17 +02:00
Sébastien Villemot
157c67e04b
New helpers to simplify common operations with derivation IDs
2022-07-12 16:30:45 +02:00
Sébastien Villemot
2013056a2c
Fix bug in JSON output for derivatives w.r.t. parameters
...
Confusion between a symbol ID and a derivation ID, which could lead to invalid
output or crash.
2022-07-12 16:23:44 +02:00
Sébastien Villemot
440173f2bc
Further simplification made possible by 75e453c5fe53ce9ce82e564577db073b41a0459a
2022-07-12 16:23:40 +02:00
Sébastien Villemot
7fd78606ae
Fix bug in MATLAB/Octave output introduced in 3e1f9dbb82
2022-07-12 16:23:32 +02:00
Sébastien Villemot
1d71386f01
Further templating of helpers for writing output files
...
So that more stuff is computed at compile-time (using constexpr features).
2022-07-12 16:23:28 +02:00
Sébastien Villemot
4370b76ce4
Remove unused function
2022-07-12 16:18:19 +02:00
Sébastien Villemot
9c3eeb7c8d
Refactor code for writing derivatives w.r.t. parameters
2022-07-12 16:18:16 +02:00
Sébastien Villemot
8da663a110
Further factorization in methods for writing static and dynamic files
2022-07-12 16:05:15 +02:00
MichelJuillard
3e1f9dbb82
use @inbounds blocks instead of @inbounds for each line
2022-07-12 13:07:33 +02:00
MichelJuillard
a4556896db
Julia functions Float64 -> <: Real
2022-07-12 11:15:51 +02:00
Sébastien Villemot
5174c3b52c
Minor simplification
2022-07-11 22:30:50 +02:00
Sébastien Villemot
f38c8278ae
Refactor methods for writing static and dynamic files
...
– factorize common code between the static and the dynamic version
– reorganise language-specific code into dedicated functions
– use a function template in the main helper to do some computations
at compile-time (using constexpr features)
2022-07-11 22:29:28 +02:00
Sébastien Villemot
c8b046ec86
Simplification using non-default std::ofstream constructor
2022-07-11 22:17:36 +02:00
Sébastien Villemot
92047f547e
Minor simplification
2022-07-11 14:05:29 +02:00
Sébastien Villemot
9b34fe856f
Add missing “break” for consistency
2022-07-08 16:10:23 +02:00
Sébastien Villemot
4b30342dc2
Bytecode: various simplifications
...
Also improve the naming of the enum class used for identifying the type of
external function call.
2022-07-08 16:02:49 +02:00
Sébastien Villemot
a7dc96516b
Minor cleanup
2022-07-08 15:13:21 +02:00
Sébastien Villemot
69354e0aec
More C++20 modernization
2022-07-08 14:52:21 +02:00
Sébastien Villemot
4867120757
Remove unused function
2022-07-08 14:44:01 +02:00
Sébastien Villemot
6d2d73a5d7
Bytecode: refactor output methods around an enum class similar to ExprNodeOutputType
...
By the way, add assertions to ensure that assignment LHS output type is only
used on VariableNode(s) and AbstractExternalFunctionNode(s).
2022-07-06 16:46:40 +02:00
Sébastien Villemot
93ef4c6feb
Small simplification
2022-07-05 17:08:29 +02:00
Sébastien Villemot
3d21821d0c
JSON output: remove duplicate “rhs” field when RHS of equation is non-zero constant
2022-07-05 17:08:29 +02:00
Sébastien Villemot
c27342cfeb
Fix interaction of temporary terms with steady_state operator
...
When the same complex expression appears outside and inside a steady_state()
operator, the same temporary term would be used for both cases, which was
obviously wrong.
The fix consists in never substituting temporary terms for expressions inside
the steady_state operator().
Incidentally, this implies that external functions can no longer be used inside
steady_state operators (since their computed values are stored inside temporary
terms).
2022-07-05 17:08:27 +02:00
Sébastien Villemot
db0d9290b5
Bytecode: remove hack for exogenous deterministic index
...
The support in the bytecode MEX was broken anyways.
2022-07-05 14:10:34 +02:00
Sébastien Villemot
c27354ace0
Bytecode: change name of 2nd argument of ExprNode::writeBytecodeOutput(), for clarity
2022-07-04 17:10:44 +02:00
Johannes Pfeifer
99337ee32e
dyn_forecast: remove unused output argument
2022-07-01 14:31:42 +02:00
Sébastien Villemot
c3fc5b1dd7
Enable -Wunused-parameter
...
As a consequence, add many [[maybe_unused]] attributes for legitimate
cases (mainly in virtual functions).
2022-06-24 17:11:48 +02:00
Sébastien Villemot
a6b5d40d4b
Pac{Expectation,TargetNonstationary}Node::writeOutput(): error out for non-LaTeX, as for VarExpectationNode
2022-06-24 17:11:48 +02:00
Sébastien Villemot
297f86a90e
NumConstNode::write{Bytecode,Json}Output(): check for temporary terms, as is done for MATLAB output
2022-06-24 17:11:48 +02:00
Sébastien Villemot
17f72d6162
Remove empty checkPass() methods
2022-06-24 17:11:48 +02:00
Sébastien Villemot
3b99ac5df0
Remove unused parameters to various methods
2022-06-24 17:11:38 +02:00
Sébastien Villemot
e0c9a287c5
Remove unused StaticModel::copyHelper()
2022-06-24 15:28:42 +02:00
Sébastien Villemot
b390390a98
Remove unnecessary inline specifiers
...
A function defined entirely inside a class/struct/union definition is
implicitly an inline function.
2022-06-24 15:09:08 +02:00
Sébastien Villemot
b307097f85
Mark some functions as constexpr
...
This probably brings no benefit since those functions are currently not used at
compile time, but it’s nice…
2022-06-24 14:52:39 +02:00
Sébastien Villemot
7e01d01d80
VariableNode::writeBytecodeOutput(): check for temporary terms, as done for other types of output
2022-06-24 13:10:23 +02:00
Sébastien Villemot
9bd2973034
Refactor bytecode output around a new BytecodeWriter class and operator<< overloads
2022-06-24 13:10:04 +02:00
Sébastien Villemot
13dc0a1144
Use operator""s to replace some calls to std::string constructor
...
By the way, remove other unnecessary calls to that constructor.
2022-06-22 12:47:11 +02:00
Sébastien Villemot
83693e4427
Bytecode: stop using unsigned integers where signed ones avoid unnecessary casts
2022-06-20 17:49:31 +02:00
Sébastien Villemot
5cd5676c8e
Bytecode: directly use several enums inside instruction classes
2022-06-20 15:19:08 +02:00
Sébastien Villemot
4662a42c9a
Bytecode: in FNUMEXPR, store lag as int rather than int8_t
...
Otherwise lags are truncated at ±128.
2022-06-20 15:19:08 +02:00
Sébastien Villemot
b1c8e24e01
Bytecode: store instruction opcode (Tags enum) directly inside instruction classes
...
This makes the code simpler. Incidentally, since Tags are no longer stored as
uint8_t, this makes the .cod files larger, but there is no clear performance impact.
2022-06-20 15:18:23 +02:00
Sébastien Villemot
09cb33d867
Bytecode: no longer bypass normal alignment rules in instructions representation
...
This change provides a (limited) performance gain, at the expense of
a (moderate) increase in .cod files.
2022-06-20 10:28:30 +02:00
Sébastien Villemot
2ea6a5244e
Bytecode: remove unused expression types and associated constructors
2022-06-17 16:31:47 +02:00
Sébastien Villemot
3613dbbe01
Bytecode: remove unused instruction class constructors
2022-06-17 16:10:17 +02:00
Sébastien Villemot
aa4783fd86
Bytecode: move all instruction classes into a single class hierarchy
...
Class BytecodeInstruction is the root.
2022-06-17 15:33:54 +02:00
Sébastien Villemot
1383d2f344
Remove useless inline specifier
...
Functions entirely defined inside classes are automatically marked inline.
By the way, fix indentation in relation to the explicit specifier.
2022-06-17 14:29:12 +02:00
Sébastien Villemot
82751d21fe
Remove useless debugging code
2022-06-17 12:46:32 +02:00
Sébastien Villemot
b3b8ed63e1
Bytecode: remove unused opcodes
2022-06-17 12:46:24 +02:00
Sébastien Villemot
4cfba74f57
Bytecode: streamline description of opcodes
...
An “FLD…” opcode loads onto the stack, an “FST…” opcode stores from the stack.
Also remove useless numerical values (which may change).
2022-06-17 12:26:43 +02:00
Sébastien Villemot
5a0c6ad206
Build system update following header split
2022-06-16 20:41:53 +02:00
Sébastien Villemot
a85730313c
Split CodeInterpreter.hh into two headers
...
– a generic one: CommonEnums.hh
– and a bytecode-specific one: Bytecode.hh
By the way, rename global constant “near_zero” into “power_deriv_near_zero”,
for clarity.
2022-06-16 17:53:23 +02:00
Sébastien Villemot
41b1e89756
Macro-processor: when a variable is defined without a value, set it to “true”
...
Previously it was set to 1.
Also do the same change for variable defined on the command-line, for
consistency.
Closes : #43
2022-06-16 16:50:38 +02:00
Sébastien Villemot
2a68f5a3af
Use “follower” instead of “slave” in internal class and variable names
2022-06-15 15:39:20 +02:00
Sébastien Villemot
248dac4bc7
Rename “parallel_slave_open_mode” option to “parallel_follower_open_mode”
...
But still accept the old name for backward compatibility.
Closes : #86
2022-06-15 15:35:54 +02:00
Sébastien Villemot
9b04c5436e
Block decomposition: fix crash when a variable appears in an equation but has zero symbolic derivative
2022-06-13 16:32:58 +02:00
Sébastien Villemot
5d1264e2b9
Optimization: use a move_iterator
2022-06-13 15:06:58 +02:00
Sébastien Villemot
ee8ee7c27f
Optimization: use move semantics in a few more places
2022-06-13 14:27:19 +02:00
Sébastien Villemot
8541179a56
Correctly clean up options list after a “pac_model” statement
2022-06-13 14:27:19 +02:00
Sébastien Villemot
a5feb52f2f
Merge branch 'AppleSiliconPkg' of git.dynare.org:wmutschl/preprocessor
...
Ref. !61
2022-06-08 15:27:28 +02:00
Willi Mutschler
fe8aaf44fd
🍎 provisions for Apple Silicon package
2022-06-08 15:11:02 +02:00
Sébastien Villemot
49277dbbf2
StaticModel::getDerivID() now throws an exception when arg is not endo or parameter
...
Previously it would return -1, which is bad practice.
2022-06-08 14:54:09 +02:00
Sébastien Villemot
e3bc2d1b9b
Minor simplification
2022-06-08 14:37:59 +02:00
Sébastien Villemot
46b2c73565
C++17 modernization: more uses of std::optional
2022-06-08 12:34:25 +02:00
Sébastien Villemot
c94dfb848c
C++20 modernization: use initialization within range-based for loop
...
In particular, use this feature in many loops which feature a special treatment
for the first iteration, using a boolean variable (replacing iterator
manipulation). By the way, also use std::exchange() to simultaneously test the
value of this variable and update it.
2022-06-07 14:35:59 +02:00
Sébastien Villemot
9ace2dc413
C++17 modernization: take advantage of class template argument deduction
2022-06-07 14:35:26 +02:00
Sébastien Villemot
0b5c88109f
Various simplifications
2022-06-07 14:34:30 +02:00
Sébastien Villemot
8b5e33b87a
Avoid name clash between function parameter and class member
2022-06-03 20:38:07 +02:00
Sébastien Villemot
cecf14f29d
Improve comment
2022-06-03 20:30:40 +02:00
Sébastien Villemot
4da901d05f
Fix comment
2022-06-03 20:30:40 +02:00
Sébastien Villemot
d859f59a10
Epilogue: improve error message
2022-06-03 20:30:40 +02:00
Sébastien Villemot
edf75e48a3
Merge branch 'tolx_steady' into 'master'
...
Add tolx-option for steady
See merge request Dynare/preprocessor!60
2022-05-23 10:07:09 +00:00
Sébastien Villemot
cec47cc78c
Implement bytecode compilation of 2nd deriv of external functions
2022-05-20 12:35:38 +02:00
Sébastien Villemot
d1a3b227fd
Fix bug in bytecode compilation of 1st deriv of external functions
2022-05-20 12:35:23 +02:00
Sébastien Villemot
03dc9837d0
Comment improvement
2022-05-20 12:27:22 +02:00
Sébastien Villemot
171cd65566
Fix bytecode compilation of external function nodes
2022-05-20 11:43:02 +02:00
Johannes Pfeifer
1dbf9c8041
Add tolx-option for steady
2022-05-19 22:43:41 +02:00
Sébastien Villemot
591b5e5f9e
Always create bytecode output
...
And, symmetrically, when the “bytecode” option is requested by the user, always
create the .m static/dynamic files.
The “bytecode” option therefore no longer modifies the preprocessor output.
2022-05-19 14:49:46 +02:00
Sébastien Villemot
af88f50d44
Forbid multiple identical clauses in “occbin_constraints” block
...
Closes : #97
2022-05-19 14:36:15 +02:00
Sébastien Villemot
0284b249f5
Remove unused “bytecode” argument in {Static,Dynamic}Model::computingPass()
2022-05-19 14:10:22 +02:00
Sébastien Villemot
25a32b1a32
Cosmetics
2022-05-19 12:27:44 +02:00
Sébastien Villemot
17ba60e587
Mark copy constructor and assignment of ModelTree as protected
...
This limits the risk of slicing.
The same is not possible for DataTree, since that base class is directly used
in some places.
2022-05-19 12:27:39 +02:00
Sébastien Villemot
2483639f4d
Fix bug introduced in 3516894a71
related to new estimation syntax
2022-05-18 19:27:00 +02:00
Sébastien Villemot
3516894a71
JSON output: fix handling of vector value options
...
The vectors were previously stored as strings internally, which would not
necessarily contain the commas which are required in JSON (but not in
MATLAB/Octave). The fix consists in internally storing those options as
std::vector.
Closes : #96
2022-05-18 17:44:36 +02:00
Sébastien Villemot
5b50c10229
Simplify OptionsList::writeJsonOutput()
2022-05-18 16:33:49 +02:00
Sébastien Villemot
29c683c6ad
JSON output: add missing comma for paired numerical options
2022-05-18 16:33:49 +02:00
Sébastien Villemot
d64682f346
JSON output: fix possible spurious commas in vector of int or string options
2022-05-18 16:33:49 +02:00
Sébastien Villemot
2795207802
No longer delete move constructor/assignment operator
...
We follow the advice given by Josuttis in his book about move semantics.
Deleting those member fuctions can be a bug if we want to allow copy semantics,
because overload resolution will no longer fallback to the copy
constructor/assignment operator when given an rvalue.
In particular, this explain why it was not possible to delete the move
assignment operator of the StaticModel class.
2022-05-18 16:33:48 +02:00
Sébastien Villemot
c6007aa780
C++17 modernization: use [[fallthrough]] attribute
...
This disables warnings when -Wimplicit-fallthrough is used (enabled by -Wextra).
2022-05-18 16:33:48 +02:00
Sébastien Villemot
701db61e09
JSON output: fix several bugs related to switch/case fallthrough
2022-05-18 16:33:42 +02:00
Sébastien Villemot
ae97c4eb29
Factorization in OptionsList class
2022-05-17 18:08:10 +02:00
Sébastien Villemot
3e94250582
C++17 modernization: use std::optional in ExprNode::getPacOptimizingShareAndExprNodes()
2022-05-16 19:10:16 +02:00
Sébastien Villemot
0eb11d3323
C++17 modernization: use std::optional in expression matching functions
2022-05-16 19:10:16 +02:00
Sébastien Villemot
3496d77eb4
C++17 modernization: use std::optional to store orig diff vars in VAR and TCM
...
By the way, remove the unused TrendComponentModelTable::getOrigDiffVar() method.
2022-05-16 19:10:16 +02:00
Sébastien Villemot
34aa1d3bb4
Fix comment
2022-05-16 19:10:16 +02:00
Sébastien Villemot
06d05e9a8d
C++17 modernization: use std::optional for SymbolTable::getEquationNumberForMultiplier()
2022-05-16 19:10:16 +02:00
Sébastien Villemot
fa7a926143
C++17 modernization: use std::optional for the storage of orig_symb_id and orig_lead_lag in SymbolTable
...
For the diff and unaryOp auxvar types, these value may be set or unset
depending on the complexity of the expression represented by the auxvar.
2022-05-16 19:10:15 +02:00
Sébastien Villemot
8fd1505ca2
C++17 modernization: use std::optional for “periods” option of “plot_conditional_forecast”
...
Incidentally, in the JSON output, no longer assign a value to the “periods”
field if not passed by the user (previously the value -1 was output in the JSON
file).
2022-05-16 19:10:15 +02:00
Sébastien Villemot
fc037a4352
Simplify printing of booleans using std::boolalpha
2022-05-16 19:10:15 +02:00
Sébastien Villemot
92d3b8166a
C++17 modernization: use std::optional for equation line numbers
2022-05-16 19:10:15 +02:00
Sébastien Villemot
0b51294994
C++17 modernization: use std::optional for trend variables in TCM
2022-05-16 19:10:15 +02:00
Sébastien Villemot
fb3b1c301f
endval(learnt_in=…) block: fix treatment of unused endogenous variables
2022-05-06 12:56:24 +02:00
Sébastien Villemot
46a85644d8
C++20 modernization: update comment about workaround for clang
2022-05-04 17:37:58 +02:00
Sébastien Villemot
7bd449d6c3
C++20 modernization: use new std::erase_if function
2022-05-04 17:37:58 +02:00
Sébastien Villemot
b42ee40b55
C++20 modernization: use contains() method on containers
2022-05-04 17:37:57 +02:00
Sébastien Villemot
ef02b79486
Various minor simplifications
2022-05-04 17:36:59 +02:00
Sébastien Villemot
e0c3cb72b7
No longer link against libstdc++fs
...
That requirement was dropped in GCC 9.
2022-05-04 17:11:44 +02:00
Sébastien Villemot
3a820fffa2
New += and *= syntaxes in “endval(learnt_in=…)” blocks
...
Incidentally, forbid exogenous deterministic variables in “endval” blocks.
2022-05-03 16:52:04 +02:00
Sébastien Villemot
8c07fb5e43
Compatibility fix for GCC 12
...
Ref. dynare#1852
2022-05-02 17:03:42 +02:00
Sébastien Villemot
32761173e0
Add solve_algo, markowitz, maxit and tolf options to pfwee_setup
2022-04-29 15:53:26 +02:00
Sébastien Villemot
6509bc7d36
Allow “learnt_in=1” for “shocks” and “endval”
...
In that case, the option has no effect.
2022-04-29 11:17:11 +02:00
Sébastien Villemot
76a16a69a8
New “add” and “multiply” keywords in “shocks(learnt_in=…)” block
2022-04-26 15:21:45 +02:00
Sébastien Villemot
dbe14ecfd4
Add checks on the value of the “learnt_in” option of “shocks” and “endval”
2022-04-26 11:45:22 +02:00
Sébastien Villemot
e47ea565b9
Use booleans for “exo_det” and “multiplicative” fields of M_.det_shocks
2022-04-26 11:32:07 +02:00
Sébastien Villemot
8e3590ee71
Reject exogenous deterministic variables in a few places where they were erroneously accepted
...
– heteroskedastic_shocks block
– generate_irfs command
– new estimation syntax
2022-04-21 17:59:04 +02:00
Sébastien Villemot
516f0bf41f
Fix bug in new estimation syntax introduced in 7280c92642
2022-04-21 17:38:41 +02:00
Sébastien Villemot
b5a4df1608
New shocks(learnt_in=…) and endval(learnt_in=…) blocks
...
For use with perfect_foresight_with_expectation_errors_setup.
2022-04-21 17:07:33 +02:00
Sébastien Villemot
54ca5d9cc0
Improve messages during model normalization
...
– Indicate whether we are trying to normalize the static or dynamic model
– If failed to normalize the static model, suggest to use the “no_static”
option
– Remove a superfluous error message
2022-04-19 17:11:13 +02:00
Sébastien Villemot
894f5cda46
Macro-processor: more robust handling of empty files
...
The support for empty files at the macro-processor level, as implemented in
1291320053
, was relying on
basic_streambuf::in_avail(), which does not seem to behave consistently across
platforms, and which may not be the right tool for the job.
Rather use the Bison grammar to support empty files.
Closes : #93
2022-04-19 16:40:18 +02:00
Sébastien Villemot
8064bdc7d0
Use Unicode copyright symbol (in UTF-8 encoding)
...
This file was apparently a left-over from a previous conversion.
[skip ci]
2022-04-13 13:24:33 +02:00
Sébastien Villemot
acaabd59da
New option “constant_simulation_length” to “perfect_foresight_with_simulation_errors_solver” command
2022-04-12 15:26:04 +02:00
Sébastien Villemot
0a3782df8c
Fix error in grammar for options of “perfect_foresight_with_expectations_errors_solver”
2022-04-12 15:26:04 +02:00
Sébastien Villemot
a431682697
Fix check for the presence of ramsey_{model,policy} when ramsey_constraints is used
...
The existing check would incorrectly fail if ramsey_constraints appeared before
ramsey_{model,policy}.
Also, the check would not terminate the processing in case of error.
Closes : #91
2022-04-11 12:28:38 +02:00
Sébastien Villemot
621134b8d8
Julia: more adaptation of DynamicSetAuxiliarySeries.jl for TimeDataFrame objects
...
– also use vectorized versions for .+ and .-
– add a space before vectorized operators to avoid syntactical ambiguity
This commits complements bfdcc546ec
.
2022-04-08 15:06:29 +02:00
Sébastien Villemot
bfdcc546ec
Julia: adapt DynamicSetAuxiliarySeries.jl for TimeDataFrame objects
2022-04-01 17:34:37 +02:00
Sébastien Villemot
71edfd05e4
Add new “log” option to “var” statement
...
When an endogenous is declared with “var(log)”, say “y”:
– creates an auxiliary named “LOG_y”
– replaces “y(±l)” everywhere by “exp(LOG_y(±l))”
– adds a new auxiliary equation “y=exp(LOG_y)”
– adds a new definition “LOG_y=log(y)” in set_auxiliary_variables.m and
dynamic_set_auxiliary_series.m files
This option also works in conjunction with “deflator=…”, such as “var(log,
deflator=…)” (the “log” must appear befor “deflator”). There are no provisions
for combining “log” with “log_deflator”, because that would not make much sense
from an economic point of view (amounts to taking the log two times).
Ref. dynare#349
2022-03-30 17:46:07 +02:00
Sébastien Villemot
ee14027e1b
Remove duplicate functions for setting current parser data tree to dynamic model
2022-03-30 17:27:08 +02:00
Sébastien Villemot
40398425ae
Refactor some symbol declaration helpers so that they return the symbol ID
...
This avoids useless calls to SymbolTable::getID().
2022-03-29 16:44:04 +02:00
Sébastien Villemot
46cc47266b
Refactor parsing of symbol lists
...
For symbol lists (such as those given to “var” or “stoch_simul”), return a
semantic value at the Bison level, rather than building the list through a
temporary object in ParsingDriver. This allows various simplifications, and
leads to a more functional code.
By the way, homogeneize the naming of the various flavours of symbol lists in
the Bison file (with TeX names, partitioning, or with a wildcard).
2022-03-29 14:59:34 +02:00
Sébastien Villemot
7fff8b3406
Fix detection of nonlinearity of blocks of type “Solve backward/forward simple”
...
They were always marked as linear.
2022-03-15 16:47:03 +01:00
Sébastien Villemot
9db21a231c
Handle “resid” command at the preprocessor level and add “non_zero” option
2022-03-01 14:23:18 +01:00
Sébastien Villemot
11a81e3047
Add a couple of missing “explicit” keywords on single-argument constructors
2022-03-01 12:15:03 +01:00
Sébastien Villemot
17c5e1935d
Fix error message when “ramsey_policy” follows a “ramsey_model” statement
...
By the way, also fix error message when there are several “ramsey_model” or
“ramsey_policy” statements.
Closes : #90
2022-02-21 16:45:56 +01:00
Sébastien Villemot
b78ac1d31f
Bytecode: fix temporary terms for dynamic derivatives in “evaluate” mode
...
The temporary terms for dynamic derivatives were only computed in the
“simulate” mode.
2022-02-18 12:38:06 +01:00
Sébastien Villemot
cb78300e95
Transform predetermined variables before simplifying equations
...
Equation simplification takes leads/lags into account, so those need to be
correct upon entry of the procedure.
2022-02-17 18:27:08 +01:00
Sébastien Villemot
c03f4a559a
Fix JSON output when there are multiple “var_expectation_model” statements
...
Ref. Madysson/estimation-codes#19
2022-02-15 20:58:36 +01:00
Sébastien Villemot
7df6781982
Add interface for “static” and “incidence” options of “model_info”
2022-02-09 12:26:00 +01:00
Sébastien Villemot
adab6c7f93
Comment improvement + cosmetics
2022-01-28 17:24:48 +01:00
Sébastien Villemot
01bea3f5e7
TCM: remove useless 3rd dimension of A0 and A0star (supposedly for lags)
2022-01-28 16:38:50 +01:00
Sébastien Villemot
1e77f7c5a7
SymbolTable::getOrigSymbIdForAuxVar() now also works on unaryOp and diffForward auxvars
...
This is a more natural semantics.
Incidentally, this fixes a bug in the variable mapping (M_.mapping) where some
endogenous, appearing in a log() in a VAR or TCM, would not be mentioned (e.g.
in the var-expectations/7/example1.mod test, and many others).
2022-01-28 16:30:11 +01:00
Sébastien Villemot
28f89261ab
Minor simplification of SymbolTable::addDiffAuxiliaryVar()
...
For symmetry with SymbolTable::addUnaryOpAuxiliaryVar().
2022-01-28 16:01:44 +01:00
Sébastien Villemot
a93e264c2c
Harmonize “diffForward” auxvar with “diff” auxvar by giving it an orig_lead_lag as well
...
By the way:
– Fix and improve the explanation of the purpose of the orig_symb_id and
orig_lead_lag fields for auxvars
– Factorize the code that prints those fields in MATLAB and JSON output
2022-01-28 15:53:41 +01:00
Sébastien Villemot
289b4773d7
Fix matching of diff leads/lags in TCM and PAC models
...
The logic was flawed in several ways. In particular, the test files
pac/trend-component-{3,10,11}/example1.mod would return A0 and A0star matrices
where the (2,2) element was incorrectly zero.
2022-01-28 15:53:41 +01:00
Sébastien Villemot
b709da7f17
Fix SymbolTable’s getOrigSymbIdForAuxVar() and getUltimateOrigSymbID() so that they never return -1
...
The case of a diff aux var corresponding to a complex expression was not
correctly handled, and could lead to a value -1 being returned by these
methods.
2022-01-28 15:53:39 +01:00
Sébastien Villemot
2c84d500d9
Add GDB pretty-printer for ExprNode class hierarchy
2022-01-26 15:40:40 +01:00
Sébastien Villemot
ff0e094d6f
Macroprocessor: MinGW bug for filesystem::path→string implicit conversion is still present in Debian 11
2022-01-25 12:57:12 +01:00