Sébastien Villemot
9f361e9e37
Block decomposition: simplify code for ordering dynamic Jacobian columns
2020-05-06 14:21:24 +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
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
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
1886746581
VariableDependencyGraph::reorderRecursiveVariables now returns indices from vertex_index
...
This is for consistency with other graph algorithms. Previously it would return
an index from vertex_index1.
See also 1d92adacf4
(which this commit basically
reverts).
Also do some cosmetic changes in calling graph code.
2020-04-29 18:46:15 +02:00
Sébastien Villemot
24db5e6033
Minor simplifications in graph algorithms
2020-04-29 18:12:22 +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
2c69f1f31e
Cosmetic changes to ModelTree::determineLinearBlocks()
2020-04-28 12:35:18 +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
5bd41f8599
Improve comments
2020-04-24 19:06:30 +02:00
Sébastien Villemot
45b260cf20
VariableNode::getChainRuleDerivative: do not cache values in ExprNode::derivatives
...
This field is used for standard derivatives. Using it also for chain rule
derivatives can only lead to wrong results.
2020-04-24 19:06:30 +02:00
Sébastien Villemot
29f28be772
Further simplify ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock()
2020-04-24 11:36:05 +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
Sébastien Villemot
e48e761b94
Block decomposition: various minor cleanups
2020-04-23 14:41:18 +02:00
Houtan Bastani
8b6e42559d
fix typo
...
[skip ci]
2020-04-21 13:08:27 -04: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
1d92adacf4
Block decomposition: fix bug with mfs > 0 introduced in 5431451db3
2020-04-17 18:19:07 +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
5431451db3
Block decomposition: refactor algorithms on the variable dependency graph
...
In particular, move them into a separate class rather than a namespace.
2020-04-10 12:55:07 +02:00
Stéphane Adjemian (Charybdis)
c38f9aa7c3
Cosmetic change.
2020-04-06 09:29:57 +02:00
Stéphane Adjemian (Charybdis)
27a8b3b70e
Added preprocessor option: notime.
...
Do not print the total computing time at the end of the driver.
2020-04-03 11:00:48 +02:00
Sébastien Villemot
daa8d01686
Complete rewrite of the equation normalization symbolic engine
2020-04-02 19:19:57 +02:00
Sébastien Villemot
e88c05e3b8
Change prototype of DataTree::AddEqual()
...
This permits some simplifications.
2020-04-02 19:19:57 +02:00
Sébastien Villemot
fb72472ee0
Block decomposition: fix several bugs in computation of renormalized equations
...
This would only hit for mfs=2 or mfs=3.
2020-03-30 18:39:25 +02:00
Sébastien Villemot
1949a355a7
Block decomposition: simplifications to ModelTree::equationTypeDetermination
2020-03-30 17:06:48 +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
ad48697abe
Block decomposition without bytecode: fix call to solve_one_boundary
...
Ref. dynare#1717
2020-03-30 12:44:01 +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
92c3cbdfa1
Remove unused classes
2020-03-24 17:04:53 +01:00
Sébastien Villemot
78ff24ea14
Block decomposition: misc style and doc improvements
2020-03-24 16:57:45 +01:00
Sébastien Villemot
a2caa8b4a8
Block decomposition: in symbolic normalization, no longer insert a null pointer in dynamic Jacobian
...
Rather use DataTree::Zero, since we use numerical zero for static and
contemporanous Jacobians.
2020-03-24 15:28:22 +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