Commit Graph

102 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
Sébastien Villemot c5f9ae89e7
Implement new “occbin” option to “model” block
For the time being, the preprocessor will refuse that this option be used with
any command other than estimation.

By the way, remove occbin_likelihood and occbin_smoother options to estimation.

Ref. dynare#569
2021-05-31 10:00:59 +02:00
normann 22fbfb0fba Allows to write M_.NNZDerivatives_objective in the driver.m file
Writes the number of non-zero derivatives of the planner objective function NNZDerivatives_objective in the driver.m file. Useful for the k-order approximations of welfare.
2021-04-22 15:26:25 +02:00
Sébastien Villemot 7468b4d8d7
Remove more stuff related to unfinished decomposition in linear and nonlinear blocks
Ref. #39, dynare!1626
2021-01-25 18:13:35 +01:00
Sébastien Villemot af9bd8f109
Remove the unfinished decomposition in linear and nonlinear blocks
Also remove the det_cond_forecast interface, that was related to it.

Ref. dynare!1626
Closes: #39
2021-01-25 18:03:37 +01: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 ad5e196d30
Block decomposition now compatible with 'use_dll' option 2020-06-23 15:13:04 +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 a6d9ba6e55
Rename EquationType::evaluate_s to evaluateRenormalized, for clarity 2020-05-20 11:49:32 +02:00
Sébastien Villemot c579a45b08
Remove helper now unused because of 1d838e96ff 2020-05-20 11:35:44 +02:00
Sébastien Villemot 4b28f1fe9c
Bytecode: remove unused data structure 2020-05-20 10:31:31 +02:00
Sébastien Villemot 2944484442
Bytecode: rename output methods for better consistency 2020-05-19 17:45:33 +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 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 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 7f57821401
Now compute blocks[].first_equation from ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock
Also include various cosmetic changes.
2020-04-29 18:48:42 +02:00
Sébastien Villemot 4948adf2cd
Block decomposition: remove unused data structure 2020-04-29 17:47:48 +02:00
Sébastien Villemot f39c687d85
Block decomposition: store mapping between endos/eqs and their block
Previously this computation was done at several places.
2020-04-29 17:42:46 +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 118ceab85b
Block decomposition: reorganize data structures storing block information 2020-04-21 18:25:33 +02:00
Sébastien Villemot 8eafd9ab4f
Block decomposition: various refactorings 2020-04-17 19:23:52 +02:00
Sébastien Villemot a741799f90
Block decomposition: factorize various helper functions
Should have been done in 76c2e87c3b.
2020-04-17 16:04:19 +02:00
Sébastien Villemot 7327fb9f17
Block decomposition: give more explicit names to ModelTree::{inv_,}{equation,variable}_reordered 2020-04-17 15:09:22 +02:00
Sébastien Villemot 4e819f09b2
Block decomposition: various refactorings 2020-04-15 17:56:28 +02:00
Sébastien Villemot 4d30f17e0b
Block decomposition: move collectFirstOrderDerivativesEndogenous in ModelTree
By the way, use camel case for the function name.
2020-03-30 14:51:53 +02:00
Sébastien Villemot 9263a02a9b
Skip constant equations replacement only when there is an “mcp” tag
Since bef537d40a, constant equations were not
simplified as soon as they had a tag attached.

But this is too wide a restriction. In particular, this breaks the trend
component models which have a target that is set to a constant.

So we now only skip the replacement in the case where there is an “mcp” tag.

Ref. dynare#1697
2020-03-27 18:17:04 +01:00
Sébastien Villemot 50776a766a
Remove the unsignedness of many integer variables and function arguments
This was only adding unneeded complexity, for no clear reason (we’re very far
from reaching 2³¹ equations, and if we wanted to support models that large, it
would be better to use long integers to avoid being limited to 2³²).
2020-03-24 18:28:03 +01:00
Sébastien Villemot 78ff24ea14
Block decomposition: misc style and doc improvements 2020-03-24 16:57:45 +01:00
Sébastien Villemot 5d6e6338f4
Block decomposition: remove unused codepaths in computation of normalization 2020-03-20 18:49:31 +01:00
Sébastien Villemot 097bdfde03
Misc simplifications and cosmetics 2020-03-20 18:42:59 +01:00
Sébastien Villemot ce1cbb3e52
Block decomposition: turn EquationType into an enum class 2020-03-20 18:00:56 +01:00
Sébastien Villemot 8b4d046f9f
Block decomposition: turn BlockSimulationType into an enum class 2020-03-20 17:31:14 +01:00
Sébastien Villemot f1061e8df1
Block decomposition: turn BlockType into an enum class 2020-03-20 16:38:43 +01:00
Sébastien Villemot fcef9cf8b9
Block decomposition: further streamlining of function prototypes 2020-03-20 15:23:23 +01:00
Sébastien Villemot bd6eee93df
Block decomposition: refactor the prototypes of various functions
— return output arguments on the left-hand side
— do not pass class members as input/output arguments

By the way, fix a (benign) vector allocation bug in
{Static,Dynamic}Model::computeChainRuleJacobian().
2020-03-19 17:47:12 +01:00
Sébastien Villemot 76c2e87c3b
Block decomposition: factorize data structures between StaticModel and DynamicModel 2020-03-17 18:58:34 +01:00
Houtan Bastani 7371558321
rework equation tags
Create new EquationTags class to simplify use of equation tags throughout the code and avoid repeated code

issue #38
2020-02-21 17:49:38 +01:00
Sébastien Villemot bef537d40a
Do not simplify constant equations which have a tag attached
In particular, in the case of an 'mcp' tag, this could lead to a convergence
failure.

Ref. dynare#1697
2020-01-27 16:09:05 +01:00
Sébastien Villemot 23a08a3662
Ensure that dynamic model files contains all the derivatives that have been computed
Previously, there could be a discrepancy if the order mandated by
“identification” was less that the one mandated by “stoch_simul”.

Ref. #40
2020-01-20 17:22:32 +01:00