Commit Graph

222 Commits (master)

Author SHA1 Message Date
Sébastien Villemot 22675728aa
No longer call std::move on trivially-copyable types
Automatically detected by clang-tidy with performance-move-const-arg check.

Do not make the modification for Tokenizer::location type, since we have no
guarantee that the type will remain trivially-copyable in the future.
2023-12-13 15:37:07 +01:00
Sébastien Villemot b2e9ec205e
No longer use reserved identifiers for include guards
Automatically detected using clang-tidy with bugprone-reserved-identifier
check.

By the way, homogeneize the define identifiers in relation to camel case
convention.
2023-12-01 15:39:01 +01:00
Sébastien Villemot d463607e90
Reformat C++ source code using clang-format 15 2023-11-30 15:58:32 +01:00
Sébastien Villemot 46aa6610ab
model_replace, model_remove: allow selecting an equation with several (conjunct) tags
NB: does not (yet) works with Occbin regime-specific equations.

Ref. dynare#1890
2023-11-15 12:05:06 +01:00
Sébastien Villemot 1ad7dd9672
Refactor parsing of equation tags in a more functional way
Incidentally, makes tag names case-insensitive in “model_replace” and
“model_remove”, which is consistent with tag declarations.
2023-11-14 15:55:30 +01:00
Sébastien Villemot 6ec7f580d5
New option “static_mfs” to “model” block (and “model_options” command)
Currently defaults to 0.
2023-10-16 11:50:26 -04:00
Sébastien Villemot 43fc59a2bc
The “mfs” option of the “model” block no longer affects the static model
This is a restoration of the behaviour that was present in 5.x.
2023-10-16 11:49:30 -04:00
Sébastien Villemot 1ef5feec15
Factorize methods for writing set auxiliary variables/series files 2023-03-28 16:37:05 +02:00
Sébastien Villemot 0169240f76
Ramsey: write derivatives of static model w.r.t. Lagrange multipliers in a new file
The computing of the Ramsey steady state relies on the fact that Lagrange
multipliers appear linearly in the system to be solved. Instead of directly
solving for the Lagrange multipliers along with the other variables,
dyn_ramsey_static.m reduces the size of the problem by always computing the
value of the multipliers that minimizes the residuals, given the other
variables (using a minimum norm solution, easy to compute because of the
linearity property). That function thus needs the derivatives of the optimality
FOCs with respect to the multipliers. The problem is that, when multipliers
appear in an auxiliary variable related to a lead/lag, then those derivatives
need to be retrieved by a chain rule derivation, which cannot be easily done
with the regular static file.

This commit implements the creation of a new file,
ramsey_multipliers_static_g1.{m,mex}, that provides exactly the needed
derivatives w.r.t. Lagrange multipliers through chain rule derivation.

Ref. dynare#633, dynare#1119, dynare#1133
2023-03-28 14:27:51 +02:00
Sébastien Villemot bff80c0eaf
use_dll: under Windows, append MinGW location to the PATH variable only once
Previously, the MinGW location was appended multiple times to the PATH
variable, which in some cases would make the variable too long and thus
dysfunctional.

The variable is now initialized once when the worker threads are created.

By the way, move the macOS+Octave environment variable initializations to the
same place, for consistency.
2023-03-20 18:27:33 +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 9013a5cb1b
No longer create +<basename>/+block/ folder (now empty) 2023-01-17 18:42:40 +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 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 e2c72a1b75
Drop ModelTree::getEquationTags(), and replace it by calls to better interfaces 2023-01-04 16:20:50 +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 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 1430ab9cc2
Implement new sparse model representation in C
Ref. dynare#1859
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 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
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 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 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 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 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 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 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 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 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 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 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 89debf429a
Factorize code for writing JSON output 2022-07-12 18:04:05 +02:00
Sébastien Villemot 9e6c01f132
Streamline some function names 2022-07-12 17:04:41 +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 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 9c3eeb7c8d
Refactor code for writing derivatives w.r.t. parameters 2022-07-12 16:18:16 +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 3b99ac5df0
Remove unused parameters to various methods 2022-06-24 17:11:38 +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 9bd2973034
Refactor bytecode output around a new BytecodeWriter class and operator<< overloads 2022-06-24 13:10:04 +02:00