Commit Graph

1019 Commits (62f608eb805822dbc166d579a54dda9ec2e2288a)

Author SHA1 Message Date
Sébastien Villemot c7d2ea0a62
Bytecode: remove meaningless initializations 2023-02-24 15:29:52 -05:00
Sébastien Villemot 325e6487d4
Bytecode: move computation routines out of the Evaluate class 2023-02-24 15:18:43 -05:00
Sébastien Villemot 17df930eb9
Bytecode: remove unused function 2023-02-24 15:01:35 -05:00
Sébastien Villemot 0e1678c13a
Bytecode: no longer have instruction pointer as a member variable of Evaluate class 2023-02-24 14:30:15 -05:00
Sébastien Villemot 13b3208cdb
Bytecode: move all logic for navigating through the .cod file into the Evaluate class 2023-02-23 17:37:08 -05:00
Sébastien Villemot aaab993ccf
Bytecode: merge CodeLoad class into Evaluate 2023-02-23 11:21:22 -05:00
Sébastien Villemot 895ce96c61
Bytecode: fix memory management for FBEGINBLOCK and FCALL tags
FCALL was not properly deallocated, hence leading to a memory leak.
Also simplify the handling of FBEGINBLOCK through a std::unique_ptr.
2023-02-21 16:58:45 -05:00
Sébastien Villemot 1ad6b29936
Bytecode: misc minor simplifications 2023-02-21 16:31:08 -05:00
Sébastien Villemot 24b2976ac2
Bytecode: move CodeLoad class out of the preprocessor 2023-02-21 16:02:21 -05:00
Sébastien Villemot 05ba2970be
Bytecode: diminish the number of data members in Evaluate class 2023-02-17 13:46:41 -05:00
Sébastien Villemot c3e1480a52
C++17 modernization: use std::extent_v to get raw arrays size
This can prevent mistakes when the array is modified.
2023-01-24 13:43:02 +01:00
Sébastien Villemot 7922fc011e
perfect_foresight_problem MEX: move to the sparse representation
Ref. #1859
2023-01-24 13:43:00 +01:00
Sébastien Villemot 4ecc78a931
Preprocessor: drop unused per-block max lead/lag fields 2023-01-17 14:43:56 +01:00
Sébastien Villemot 0c5c96e724
Bytecode w/ block decomposition: no longer output derivatives w.r.t. exogenous and endogenous outside the block 2023-01-17 14:24:02 +01:00
Sébastien Villemot 8f1a4cb363
Drop block-decomposed first-order perturbation solution and kalman filter 2023-01-13 16:57:49 +01:00
Sébastien Villemot f84753025d
Bytecode: the block and non-block versions now coexist in parallel
As a consequence, a new “block_decomposed” option of the bytecode MEX has been
introduced to explicitly select the block-decomposed version.

Note that we do not always use the “block_decomposed” option even when the
“block” option has been passed to the user, in situations where the block
decomposition brings nothing (e.g. when evaluating the residuals of the whole
model).
2023-01-09 15:20:46 +01:00
Sébastien Villemot a8f5bdd525
Build system: no longer need to pass -pthread or -mthreads for C++11 threads as of GCC 10 2023-01-05 17:58:42 +01:00
Sébastien Villemot 9c4dd1b1d0
Remove irrelevant comment
[skip ci]
2023-01-04 15:00:27 +01:00
Sébastien Villemot d574705b4a
Design and performance improvement to solve_algo={12,14}
Use the new time-recursive block decomposition computed by the preprocessor
for:
- the simulation of backward models with “simul_backward”
- the perfect foresight simulation of purely backward/forward/static models

Also note that in this case, the preprocessor now defaults to “mfs=3” (i.e. it
minimizes the set of feedback variables and tries to renormalize equations).

This replaces the previous algorithm based on Dulmage-Mendelsohn (dmperm), plus
an ad hoc identification of some equations that can be evaluated (those with a
LHS equal to a variable, the log of a variable, or the diff-log of a variable).

By the way, the block_trust_region MEX has been modified so that it accepts a
boolean argument to decide whether it performs a Dulmage-Mendelsohn
decomposition (if not, then it performs a simple trust region on the whole
nonlinear system).

This provides a significant performance improvement (of almost an order of
magnitude for solve_algo=14 on a 700 equations model).
2022-11-30 14:47:57 +01:00
Sébastien Villemot 10fdc42516
block_trust_region MEX: add support for sparse Jacobian
If the function to be solved returns a sparse Jacobian, simply convert it to a
dense representation.
2022-11-30 14:47:57 +01:00
NormannR a245fbb390 Implements a Fortran update of the states variance-covariance matrix for the Kalman filter 2022-11-14 16:24:46 +00:00
Johannes Pfeifer fe0606ae06 logarithmic_reduction.m: use positive penalty add-on 2022-10-11 16:13:03 +02:00
NormannR afb044c23e Fix cycle reduction:
(i) making the norms consistent between cycle_reduction and its test;
(ii) remove hard errors in cycle_reduction Fortran and Matlab routines
2022-10-11 12:11:30 +02:00
NormannR 855887b249 Implements a logarithmic reduction Fortran routine and the associated test 2022-10-11 12:11:06 +02:00
Normann Rion d17204cc84 Implements a cycle reduction Fortran routine and the associated test.
The Fortran routine replaces the former Matlab code in matlab/cycle_reduction.m
2022-10-03 14:38:12 +02:00
NormannR c6d5c48ff7 Local state-space iteration at order 3: multi-thread 3rd-order version with and without pruning 2022-08-30 14:06:19 +02:00
Sébastien Villemot 24d7f569f1
Bytecode MEX: fix compilation under GCC ⩾ 11
Problem introduced in previous commit.
2022-07-29 14:30:45 +02:00
Sébastien Villemot e22ca82ab6
Bytecode MEX: drop the ErrorMsg class and integrate most of its members inside the Evaluate class 2022-07-29 13:04:31 +02:00
Sébastien Villemot 034a981daa
Bytecode MEX: streamline error handling 2022-07-29 13:04:29 +02:00
Sébastien Villemot 4ec6c0dab4
Bytecode MEX: streamline preprocessor guards in includes 2022-07-29 12:40:33 +02:00
Sébastien Villemot 0076644bda
Bytecode MEX: fix bug with PowerDeriv printing introduced in ff85fc6489 2022-07-28 17:13:23 +02:00
Sébastien Villemot 7c4dc1abce
Bytecode MEX: in error messages, revert back to default floating point format
A move to fixed format was erroneously made in
4893f0e82c and
ff85fc6489, where stream formatting of floating
points has been replaced by the use of std::to_string().
2022-07-28 17:10:12 +02:00
Sébastien Villemot 6e1635658f
Bytecode MEX: split out code for dealing with variable names into a dedicated BasicSymbolTable class 2022-07-28 16:56:40 +02:00
Sébastien Villemot 5df3fde95e
Bytecode MEX: streamline function for adding tildes below FP error 2022-07-28 15:48:21 +02:00
Sébastien Villemot ff85fc6489
Bytecode MEX: refactor the routines that display expressions in human-readable form
In particular, minimize the number of parentheses written, using the same
algorithm as in the preprocessor.
2022-07-27 18:06:08 +02:00
Sébastien Villemot 1b13bb2e6e
Bytecode MEX: simplify type for storing list of instructions 2022-07-26 18:27:23 +02:00
Sébastien Villemot 9d84048710
Bytecode MEX: fix bug introduced in 8c01912a50
Use an iterator wrapped inside std::optional instead of a possibly-singular
iterator, because the latter has undefined behaviour.

By the way, pass arguments by const reference.
2022-07-26 16:35:06 +02:00
Sébastien Villemot dc224e71ed
Bytecode MEX: fix error messages for derivatives w.r.t. exogenous / exogenous deterministic
The wrong type was used for querying symbol names.
2022-07-26 16:35:06 +02:00
Sébastien Villemot 8c01912a50
Bytecode MEX: simplify printing of numerical errors in expression
In particular, no longer rely on a duplicate implementation of the evaluator to
locate where the NaN or Inf is produced. Rather directly pass the pointer to
the faulty operator.
2022-07-25 18:07:18 +02:00
Sébastien Villemot a8351130f1
Bytecode MEX: bugfix in error message printing
Class Evaluate had data members with the same name as members of
ErrorMsg (which it derives from). In practice, this means that the data members
from ErrorMsg could be unitialized when displaying error messages.
2022-07-25 15:07:52 +02:00
Sébastien Villemot 16eabbbc4e
block_trust_region MEX: improve treatment of non-square blocks in Dulmage-Mendelsohn decomposition
– before erroring out, check whether the residuals for the block are already
  zero (in which case, move to next block)
– improve error message that is printed otherwise

Note that trying to solve under-determined blocks (as in dynare_solve.m) would
require too many changes in the existing code, so let’s leave it out.

Closes: #1851
2022-07-22 12:43:38 +02:00
Sébastien Villemot feb10b75e6
Bytecode MEX: minor fix to debug mode 2022-07-20 16:19:49 +02:00
Sébastien Villemot e87d643084
Preprocessor: various refactorings, mainly bytecode-related 2022-07-20 16:18:02 +02:00
Sébastien Villemot f454d1ae21
Bytecode MEX: build with -Wmaybe-unitialized 2022-07-20 15:10:40 +02:00
Sébastien Villemot b29dde227d
Preprocessor: various refactorings (mainly bytecode) 2022-07-08 16:05:33 +02:00
Sébastien Villemot b3cff2d34d
Bytecode: remove incomplete/buggy support for exogenous deterministic 2022-07-05 13:02:17 +02:00
Sébastien Villemot 888a87312d
Enable -Wunused-parameter for C++ MEX
Except for libdynare++, since Dynare++ is not ready (and is probably not worth
fixing by adding [[maybe_unused]] tags).
2022-07-05 12:12:53 +02:00
Sébastien Villemot 8be6f55bf6
Bytecode MEX: remove unused function parameters 2022-07-05 12:12:08 +02:00
Sébastien Villemot b05ef5dd7f
Bytecode MEX: remove unused function 2022-07-05 12:11:32 +02:00
Sébastien Villemot 218bb1a15f
k_order_welfare MEX: check number of arguments 2022-07-05 11:55:40 +02:00