Sébastien Villemot
0ddcf81ac0
Fix typo
2023-01-25 16:50:56 +01:00
Sébastien Villemot
1c813a1cf9
Run detrending engine if trend variables are present, even if unused in a var(deflator=…) statement
...
Closes : #113
2023-01-24 14:14:40 +01:00
Sébastien Villemot
74e5bbf537
Drop dynamic_g1_nz.m generated file
...
No longer needed since perfect_foresight_problem MEX has moved to the sparse
representation.
2023-01-23 16:20:12 +01:00
Sébastien Villemot
4f9241442c
Fix size of dynamic derivatives (legacy representation) when there are unused exogenous and “nostrict” option is given
2023-01-19 11:00:32 +01:00
Sébastien Villemot
c47d91c20b
Block decomposition: another fix for sparse indices of static Jacobian when mfs > 0
2023-01-19 10:03:37 +01:00
Sébastien Villemot
7db02b23e9
Block decomposition: fix sparse indices of static Jacobian when mfs > 0
2023-01-17 19:04:21 +01:00
Sébastien Villemot
9013a5cb1b
No longer create +<basename>/+block/ folder (now empty)
2023-01-17 18:42:40 +01:00
Sébastien Villemot
f45a99fc68
Correctly propagate “mfs” and “cutoff” to the static model
...
Those two settings were previously always at their default value for the static
model, independently of what the user would set in the .mod file.
2023-01-17 16:38:03 +01:00
Sébastien Villemot
fe503d3eab
Remove confusing comment
2023-01-17 16:37:24 +01:00
Sébastien Villemot
4bba274f39
Block decomposition: drop unused max lead/lag fields
...
Note that DynamicModel::determineBlockDerivativesType(), it’s legitimate to
replace max_{lead,lag} by max_endo_{lead,lag}, because for exogenous
lag=lead=0, and we no longer compute derivatives w.r.t. to endogenous that do
not belong to the block (so-called “other” endogenous).
2023-01-17 14:42:29 +01:00
Sébastien Villemot
2e09df90e7
Bytecode w/ block decomposition: no longer output derivatives w.r.t. exogenous and endogenous outside the block
2023-01-17 14:23:40 +01:00
Sébastien Villemot
1e377f061a
Block decomposition: drop unused structure fields
2023-01-17 14:18:41 +01:00
Sébastien Villemot
bbdbd0807b
Sparse representation: Octave compatibility fix
...
Octave does not support “private” subdir inside plus folders (“+namespace”).
See https://savannah.gnu.org/bugs/?45444
2023-01-16 17:12:10 +01:00
Sébastien Villemot
8ebd9a9496
Drop the “Sigma_e” statement
2023-01-16 15:08:23 +01:00
Sébastien Villemot
a7b0a324c9
Drop the “periods” statement
2023-01-16 15:02:50 +01:00
Sébastien Villemot
93b9ed6957
Drop the legacy representation of the block-decomposed model
...
As a consequence, and as a temporary measure, always output the
non-block-decomposed legacy representation.
Also drop the block kalman filter output, and drop now useless variables in
M_.block_structure.
2023-01-13 16:57:06 +01:00
Sébastien Villemot
35ac73fad8
Sparse representation: fix various bugs in the non-block MATLAB/Octave output
2023-01-10 15:58:45 +01:00
Sébastien Villemot
e18ecc3fa5
ModFile::remove_directory_with_matlab_lock(): minor performance improvement
...
Use std::filesystem::file_status and cached directory entries information to
avoid extra filesystem operations.
2023-01-10 11:49:39 +01:00
Sébastien Villemot
bae04fa899
ModelTree::findGccOnMacOS() now returns a std::filesystem::path
2023-01-10 11:48:33 +01:00
Sébastien Villemot
a4f299c0b7
Bytecode: change interface of function called from bytecode MEX
2023-01-09 14:09:09 +01:00
Sébastien Villemot
ec3ce156b4
Bytecode: always produce block and non-block versions
...
The block decomposed version is now under <BASENAME>/bytecode/block/.
2023-01-09 13:35:49 +01:00
Stéphane Adjemian (Guts)
4348f4d57f
Provisions for conditional likelihhod estimation.
2023-01-06 12:17:02 +01:00
Sébastien Villemot
0bc1539f45
Drop clang workaround
2023-01-05 18:11:33 +01:00
Sébastien Villemot
cf493ef6a6
Add two missing checks for file opening failures
2023-01-05 17:21:30 +01:00
Sébastien Villemot
253fbbe7d6
Use std::filesystem::path in more places
2023-01-05 17:21:28 +01:00
Sébastien Villemot
d36eb82b7c
Macro processor: removed unused “basename” variable
2023-01-05 15:49:36 +01:00
Sébastien Villemot
1f3ff760e1
EquationTags: drop useless method
2023-01-04 19:27:01 +01:00
Sébastien Villemot
3927862d23
EquationTags: misc implementation improvements
2023-01-04 17:15:51 +01:00
Sébastien Villemot
9658d82cc6
EquationTags::getEqnByTag() now returns an optional<int> instead of throwing
2023-01-04 16:45:12 +01:00
Sébastien Villemot
e2c72a1b75
Drop ModelTree::getEquationTags(), and replace it by calls to better interfaces
2023-01-04 16:20:50 +01:00
Sébastien Villemot
bdb5d37dec
EquationTags::getTagValueByEqnAndKey() now return an optional<string>
...
By the way, optimize the implementation.
2023-01-04 16:03:49 +01:00
Sébastien Villemot
422cbf5736
EquationTags: remove unused function
2023-01-04 16:03:45 +01:00
Sébastien Villemot
df3a153356
Simplify residuals output (MATLAB/Octave and C) by dropping lhs/rhs temporary variables
2023-01-04 14:49:07 +01:00
Sébastien Villemot
9f5ea9467d
Merge branch 'dynamic_model_info' into 'master'
...
Add dynamic option to model_info
See merge request Dynare/preprocessor!74
2023-01-04 09:57:18 +00:00
Johannes Pfeifer
2fd0681151
Add block_dynamic option to model_info
...
Also renames the old static option
2023-01-03 16:06:25 +01:00
Sébastien Villemot
21fcfa7758
use_dll: fixes to parallel compilation
...
— No longer call std::exit() from threads when compilation fails, that function
is marked as not thread-safe under GNU/Linux; and it leads to deadlocks under
Windows. Rather store the list of failed objects, and exit with a message and
an error code from the main thread when that list is not empty at the end of
preprocessing.
– Fix the condition used for waiting until all compilation threads finish;
checking that the queue is empty is not enough, since a compilation may be
ongoing. So also track objects whose compilation is ongoing.
2022-12-20 16:52:47 +01:00
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