Commit Graph

299 Commits (5b80a4db590a68cba59529f6b46e101ad355b04e)

Author SHA1 Message Date
Sébastien Villemot 5b80a4db59
Unary ops substitution: bugfix, actually restrict the substitution to the chosen equations
By default, the preprocessor is supposed to only do the “unary ops”
transformation in the equations of VAR/PAC/trend component models.

However, the implementation was slightly different so far. It would detect
candidates to this transformation in the chosen equations, but it would then
perform the substitution in *all* equations.

This could lead for crashes, for example if the chosen equation contains
log(X(-1)), but another (non-chosen) equation has log(X(-2)). Then this latter
expression, even though it belongs to the same lag-equivalence class, is not
properly handled, causing a segfault.

Also do a few related cosmetic changes.
2020-07-08 15:13:14 +02:00
Sébastien Villemot 59bda04d8b
Block decomposition + use_dll: fix bug in timing of exogenous variables 2020-06-25 15:19:49 +02:00
Sébastien Villemot db8c5439f7
use_dll: higher order derivatives are now returned as sparse matrices by static/dynamic files
Previously they were returned as 3-column matrices. But this was inconsistent
with the M-file mode.
2020-06-23 17:50:50 +02:00
Sébastien Villemot 95bdfcee8c
use_dll: better safeguards on the number of input/output argument to static/dynamic MEX files 2020-06-23 16:30:21 +02:00
Sébastien Villemot fd13c03401
use_dll: use fmax() and fmin() from C99 to compute max and min operators 2020-06-23 15:59:35 +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 f098329c74
Block decomposition: static and dynamic files are now pure wrappers around the per-block files 2020-06-19 18:45:42 +02:00
Sébastien Villemot f4d2ce70da
Block decomposition: move logic for Jacobians in stochastic mode outside the dynamic file 2020-06-19 17:44:05 +02:00
Sébastien Villemot 92aff91066
Block decomposition: in per-block files, construct sparse Jacobians more efficiently
Use 3-column format before calling sparse().

Ensure that the 3-column matrix is constructed in column-major order: data
locality will greatly improve performance once we implement use_dll.
2020-06-19 16:42:32 +02:00
Sébastien Villemot 93c18d514b
Block decomposition: in per-block dynamic files, fix nonzero elements for deterministic Jacobians 2020-06-19 15:26:19 +02:00
Sébastien Villemot 8ec43b1fb2
Block decomposition: small simplification in per-block dynamic files 2020-06-19 12:39:54 +02:00
Sébastien Villemot 79763911b2
Block decomposition: in the dynamic file, y and T are now vectors as in non-block mode 2020-06-17 16:49:12 +02:00
Sébastien Villemot 91d5be3b8c
Block decomposition: fix value of M_.block_structure.dyn_tmp_nbr 2020-06-17 16:04:49 +02:00
Sébastien Villemot 257b399a94
Block decomposition: in dynamic files, rename “jacobian_eval” to “stochastic_mode”
This is much more explicit.
2020-06-16 15:54:51 +02:00
Sébastien Villemot 379be6ccef
Block decomposition: for “solve two-boundaries” blocks, move the iteration loop outside the dynamic file 2020-06-16 15:34:45 +02:00
Sébastien Villemot 85b900363d
Block decomposition: for “solve two boundaries” block, no longer compute “b” (-residuals+g1*y) in the dynamic function 2020-06-16 13:49:23 +02:00
Sébastien Villemot 8496979375
Block decomposition: remove useless “y” output for static/dynamic files of solved blocks 2020-06-16 10:38:16 +02:00
Sébastien Villemot ad583adcd4
Block decomposition: for evaluate blocks, move the iteration loop outside the dynamic file 2020-06-15 18:13:17 +02:00
Sébastien Villemot f022c0e16e
Block decomposition: remove duplicate “periods” arg. to dynamic file of complete two-boundaries blocks 2020-06-15 16:54:11 +02:00
Sébastien Villemot b402e35683
In the driver file, provide mapping between model local variables and indices in the temporary terms vector
The structures are M_.model_local_variables_{dynamic,static}_tt_idxs.

Ref. dynare#1722
2020-06-05 17:12:15 +02:00
Sébastien Villemot 90b9b6a1e4
JSON output: write model local variables in parsed model (modfile.json)
Ref. dynare#1723
2020-06-05 16:10:38 +02:00
Sébastien Villemot 050f1cdd74
Block decomposition: remove unused 2nd and 3rd derivatives in output of dynamic functions 2020-06-03 16:59:04 +02:00
Sébastien Villemot f0c8a14551
Block decomposition: no longer compute deterministic simulation from dynamic.m file 2020-06-02 17:42:00 +02:00
Sébastien Villemot 2caad3ee84
Block decomposition: simplify DynamicModel::writeDynamicBlockMFile() 2020-05-29 16:48:38 +02:00
Sébastien Villemot 7b11898689
use_dll: merge the two generated C source files into a single one
Also, do various other cosmetic/simplification changes.
2020-05-29 16:12:01 +02:00
Sébastien Villemot 3ca1914e03
Block decomposition: fix simulation of blocks of type "evaluate backward" (without bytecode)
Ref. dynare#1727
2020-05-26 17:00:21 +02:00
Sébastien Villemot faa6666abe
Block decomposition: no longer use global variables for temporary terms in the dynamic M-file
Rather use a single vector as in non-block mode.

By the way, change the order of output arguments in static functions, to be
closer to the dynamic ones.
2020-05-26 16:21:11 +02:00
Sébastien Villemot 04b7d4386d
Block decomposition: no longer use global variables for temporary terms in the static M-file
Rather use a single vector as in non-block mode.
2020-05-25 18:35:36 +02:00
Sébastien Villemot a5abbae46a
use_dll: remove workaround for char16_t type
Should no longer be needed now that the minimal MATLAB version is R2014a.
2020-05-25 16:06:17 +02:00
Sébastien Villemot 7b1a77ca47
Block decomposition: use logical values for some inputs to solve_{one_boundary,two_boundaries} 2020-05-25 15:12:43 +02:00
Sébastien Villemot a6d9ba6e55
Rename EquationType::evaluate_s to evaluateRenormalized, for clarity 2020-05-20 11:49:32 +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 c9388da649
Bytecode: still another fix for temporary terms 2020-05-13 15:16:38 +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 928aa977b6
Block decomposition: replace expr_t by BinaryOpNode * in a couple of places 2020-05-07 15:24:35 +02:00
Sébastien Villemot c699d57308
Block decomposition: no longer compute static Jacobian, it’s not used
Also remove a message about elements below the cutoff that was no longer
correct (elements below the cutoff have no impact on the incidence matrix
outside of normalization).
2020-05-06 18:11:11 +02:00
Sébastien Villemot a1b37288f9
Block decomposition: do not write unnecessary zeros in dynamic Jacobian
Also do cosmetic change in the corresponding code for static Jacobian.
2020-05-06 14:22:04 +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 5f22f00436
PAC models: handle PAC data in DynamicModel copy constructor and assignment operator 2020-05-05 16:34:51 +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 b1a739c56a
DynamicModel: add missing members in copy constructor/assignment operator 2020-04-30 14:57:50 +02:00