Commit Graph

144 Commits (74ef3457b4805099ee9885b34173a0d0fd6aca61)

Author SHA1 Message Date
Sébastien Villemot 74ef3457b4
Use secure URL for link to GNU licenses 2021-06-09 17:21:00 +02:00
MichelJuillard 9773bafc5b Julia: write definition of get_power_deriv inside generated static/dynamic files 2021-04-26 10:52:18 +00:00
Sébastien Villemot dca294de3a
Julia: refactor the auxiliary variable/series files
— rename the files with camel case
— encapsulate the functions with modules
— change the signature of function <MODFILE>_dynamic_set_series!, by removing
  the output argument and appending the exclamation mark, since this function
  modifies one of its arguments, and for symmetry with the static version

Ref. DynareJulia/Dynare.jl#1
2021-04-23 17:57:33 +02:00
Sébastien Villemot 4354d8a578
Julia: do not overwrite steady state / auxiliary variables/series files if contents has not changed
Ref. DynareJulia/Dynare.jl#1
2021-04-23 17:56:54 +02:00
Sébastien Villemot 4cfc7a563b
Julia: do not overwrite Static/Dynamic files if contents has not changed
Ref. DynareJulia/Dynare.jl#1
2021-04-22 18:03:47 +02:00
Sébastien Villemot 81b1d02748
Julia: fix typo in StatsFuns package name
Ref. DynareJulia/Dynare.jl#1
2021-04-22 15:48:25 +02:00
Sébastien Villemot 1f17528383
Julia: update dependencies of Static/Dynamic modules
Ref. DynareJulia/Dynare.jl#1
2021-04-19 17:02:46 +02:00
MichelJuillard c2009e2012
fix set_auxiliary_variables.jl 2021-04-01 17:05:13 +02:00
Sébastien Villemot 89e2daf7c7
C++17 modernization: convert the remaining enums to enum classes 2021-02-01 12:05:06 +01:00
Stéphane Adjemian (Charybdis) b8f7b5846b
Fixed flags for temporaries (julia output). 2020-10-21 16:37:13 +02:00
Sébastien Villemot 4560639eb4
Block decomposition: fix evaluation of recursive variables in solved blocks
Ref. dynare#1726
2020-10-06 18:30:34 +02:00
Sébastien Villemot 5979885714
Block decomposition, chain rule derivation: code improvement 2020-10-02 18:31:55 +02:00
Sébastien Villemot d347a92f14
Drop ExprNode::containsExogenous()
Replace it by calls to ExprNode::collectVariables() at the single place where
it was used.
2020-09-29 18:41:31 +02:00
Sébastien Villemot de65e74c8f
use_dll: add the “restrict” C99 keyword to all pointers to double in computation functions
This greatly facilitates the job of the compiler during the optimization pass,
since we promise that the various pointers do not overlap each other. It may
now be possible to reenable some of the optimization flags that were disabled
without sacrificing compilation time, but this needs more investigation.

For the gory details, see:
https://en.cppreference.com/w/c/language/restrict
https://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
2020-09-03 18:09:06 +02:00
Sébastien Villemot c4351166a9
use_dll: remove nb_row_x from static file, it is useless 2020-06-23 18:19:27 +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 7641c2f7ee
Cosmetics 2020-06-22 11:33:16 +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 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 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 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 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 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 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 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 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 061245e50d
Block decomposition: simplify routines that write static model in MATLAB form
By the way, this probably fixes a bug in the presence of external
functions (so-called TEF terms were not properly repeated in each per-block
static file).

Also remove debugging output in the M-file.
2020-05-05 18:59:28 +02:00
Sébastien Villemot a8c2defe26
Block decomposition: compute simulation types into separate function; prologue and epilogue are no longer class members
By the way, remove the BlockType stuff which was purely informative (and it’s
not worth carrying over prologue and epilogue information just for that).
2020-04-30 12:48:16 +02:00
Sébastien Villemot 26fc71ffa7
Block decomposition: store max lead/lag of all variables in the “blocks” structure
By the way, regroup all code that computes the dynamic structure of a block
into a single function.
2020-04-30 12:03:14 +02:00
Sébastien Villemot 4948adf2cd
Block decomposition: remove unused data structure 2020-04-29 17:47:48 +02:00
Sébastien Villemot 39407083be
Block decomposition: ensure that the cutoff option only impacts normalization
Previously, the cutoff option would also impact the block decomposition itself,
since it would had an influence on the incidence matrix used for computing the
blocks and their derivatives.

The problem is that, in the general case, it’s quite possible that an element
of the numerical Jacobian be zero at the evaluation point, while being quite
different from zero along the simulation path. A typical example is an
expression of the type x*y, where y is an endogenous and x is an exogenous not
present in the initval block (and hence initialized to zero).
2020-04-29 12:41:39 +02:00
Sébastien Villemot 470cb5fcb0
Block decomposition: remove mostly unused structure ModelTree::derivative_endo
It has been superseded by ModelTree::blocks_derivatives.

By the way, fix the initial number of non-zero elements in sparse Jacobian.

Also avoid computing suboptimal temporary terms.
2020-04-28 14:12:29 +02:00
Sébastien Villemot 2e136cae56
Block decomposition: simplify computation of block derivatives
— use a std::map for storing block derivatives
— remove redundant ModelTree::first_chain_rule_derivatives structure
— remove unused codepaths in StaticModel
— DynamicModel: simplify code that determines the type of derivatives in a
  block. We now use a slightly different categorization.
— by the way, fix the max lead/lag information for blocks that are obtained via
  merging. A workaround was previously implemented in
  DynamicModel::get_Derivative(), but it is no longer needed with this fix.
2020-04-28 12:26:51 +02:00
Sébastien Villemot 5ee45f5bd4
Block decomposition: remove helpers that are no longer needed since data structure are cleaner
Add a new helper for getting the number of recursive variables in a block.
2020-04-23 16:31:57 +02:00
Sébastien Villemot 2154227990
Block decomposition, bugfix: M_.block_structure_stat.block().mfs was wrong 2020-04-23 16:03:38 +02:00