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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
5b12354dc3
Minor performance improvement in copy constructors/assignments of ModelTree and DynamicModel
2022-09-21 17:37:02 +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
Johannes Pfeifer
da5b36704d
Add missing whitespace in output of BGP warning
2022-08-03 10:52:08 +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
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
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