Commit Graph

276 Commits (6adf1c26392d737dc31844aa3add0441e040f4a8)

Author SHA1 Message Date
Sébastien Villemot 1faeaf892e
Remove unused options_.terminal_condition 2023-04-14 16:35:43 +02:00
Sébastien Villemot 66b648157f
Purely backward models simulation: use the sparse representation of the dynamic file 2023-04-13 15:47:43 +02:00
Sébastien Villemot 34e82f9697
sim1_purely_forward: use the sparse representation of the dynamic file 2023-04-13 15:47:43 +02:00
Sébastien Villemot 170a4dce0e
dynamic_forward_model_for_simulation: turn into a local function of sim1_purely_forward 2023-04-13 15:47:43 +02:00
Sébastien Villemot 5f42e84b0b
sim1_purely_static: use the sparse representation of the dynamic file 2023-04-13 15:47:43 +02:00
Sébastien Villemot 4a793f89ff
dynamic_static_model_for_simulation: turn into a local function of sim1_purely_static 2023-04-13 15:47:43 +02:00
Sébastien Villemot 62805b7183
perfect_foresight_simulation + bksup0: remove unused functions 2023-02-17 22:01:32 -05:00
Sébastien Villemot f938014e84
bksup1: turn into a local function of sim1_lbj 2023-02-17 22:01:32 -05:00
Sébastien Villemot 65053667cf
New “homotopy_alt_starting_point” option to “perfect_foresight_solver” command 2023-02-07 14:49:00 -05:00
Sébastien Villemot be698d5f98
Perfect foresight + homotopy: add missing newline 2023-02-06 15:14:02 -05:00
Sébastien Villemot 5aca770931
perfect_foresight_with_expectation_errors_{setup,solver}: fix bugs with several exogenous
Closes: #1883
2023-01-24 15:02:07 +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 e250067959
Use sparse representation for block-decomposed perfect foresight and steady state computation
Ref. #1859
2023-01-12 16:28:02 +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 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
Johannes Pfeifer bbdcdc89a2 sim1.m: use operation that preserves sparsity 2022-11-28 16:20:44 +01:00
Johannes Pfeifer cbbbdf4b3d make_y_.m: fix interaction with steady_state_model
closes https://git.dynare.org/Dynare/dynare/-/issues/1866
2022-10-13 16:33:58 +02:00
Johannes Pfeifer cf7b06e96d perfect-foresight-models/solve_stacked_problem.m: restore compatibility with Matlab before auto expansion was introduced 2022-09-16 19:27:23 +02:00
Johannes Pfeifer 66fa6e6742 sim1_purely_backward.m: fix typo 2022-09-13 13:52:29 +02:00
Sébastien Villemot b071e85214
Merge branch 'lmmcp' of git.dynare.org:JohannesPfeifer/dynare
Ref. !2067
2022-09-12 16:58:05 +02:00
Johannes Pfeifer 0225cb23ac Path solver: trigger lmmcp flag
Solves https://git.dynare.org/Dynare/dynare/-/issues/1720 for PATH solver
2022-09-06 09:34:20 +02:00
Johannes Pfeifer 85a894efde lmmcp: display norm of residuals in homotopy 2022-09-01 13:00:09 +02:00
Stéphane Adjemian (Ryûk) ca31a087f8
Fix typo (remove trailing underscore to option variable). 2022-08-31 15:26:09 +02:00
Stéphane Adjemian (Ryûk) 9301024d71
Do not check steady state if nocheck option used in steady command...
In perfect foresight solvers with linear approximation.
2022-08-31 13:12:25 +02:00
Sébastien Villemot 06f665e231
Perfect foresight: LBJ now available under stack_solve_algo=1 (with/without block/bytecode)
Previously, LBJ was available:

– under stack_solve_algo=6 when neither block nor bytecode were present
– under stack_solve_algo=1 with either block or bytecode (but the documentation
  was not making it clear that it was LBJ)

This commit merges the two values for the option, and makes them
interchangeable. LBJ should now be invoked with stack_solve_algo=1 (but
stack_solve_algo=6 is kept for compatibility, and is a synonymous).
2022-06-15 15:06:33 +02:00
Johannes Pfeifer 74dc4f81f0 perfect_foresight_solver.m: loop over dynamic file when mex cannot be used
Closes https://git.dynare.org/Dynare/dynare/-/issues/1850
2022-05-18 08:59:39 +02:00
Sébastien Villemot 63a116fb28
New += and *= syntaxes in “endval(learnt_in=…)” blocks 2022-05-03 17:46:59 +02:00
Sébastien Villemot b084c2e931
Perfect foresight with expectation errors: move computation of terminal steady states to the setup command
This is more logical, since those values are constraints from the point of view
of the solver.

Also, this allows to have maxit and tolf options for the steady state solver,
at the level of the setup command, without a clash with the same option names
for the deterministic solver at the level of the solver command.
2022-04-29 15:56:11 +02:00
Sébastien Villemot a600336c92
New “add” and “multiply” keywords in “shocks(learnt_in=…)” block 2022-04-26 15:22:15 +02:00
Sébastien Villemot 8488674ce4
New shocks(learnt_in=…) and endval(learnt_in=…) blocks
For use with perfect_foresight_with_expectation_errors_setup.
2022-04-21 17:10:52 +02:00
Sébastien Villemot 10af04c6d8
Use Unicode copyright symbol (in UTF-8 encoding) in all source files
It is now supported by the MATLAB editor (as of R2022a).

The old ASCII notation is left in some files that we copy as-is from other
sources (e.g. in the contrib/ and m4/ subdirectories).

The particles submodule is not updated at this point, because it is in an
inconsistent state.

[skip ci]
2022-04-13 14:54:25 +02:00
Sébastien Villemot b70b864829
perfect_foresight_with_expectation_errors_setup: move terminal condition to last line of CSV file 2022-04-12 15:51:04 +02:00
Sébastien Villemot a8a9051b31
New option “constant_simulation_length” to “perfect_foresight_with_simulation_errors_solver” command 2022-04-12 15:45:50 +02:00
Stéphane Adjemian (Charybdis) f1aff2b370
Remove calls to dbstack in dynare_solve.
Adding three input parameters for maxit, tolf and tolx.

Closes #1841.
2022-04-10 20:29:57 +02:00
Stéphane Adjemian (Ryûk) 01203f7e39
Stop deterministic simulation if nonlinear solver failure.
Only for purely backward/forward models. In the case of purely static models the
solution for the previous or following period is not required.
2022-04-10 10:55:40 +02:00
Stéphane Adjemian (Ryûk) 23a72d7aaa
Use dynare_solve to simulate purely forward deterministic models. 2022-04-10 09:39:28 +02:00
Stéphane Adjemian (Ryûk) ef2bb4e669
Return and use errorcode from dynare_solve.
Note that the interpretation of the error code depends on the nonlinear solver.
2022-04-09 16:06:24 +02:00
Sébastien Villemot b4ce69db3a
Remove options_.slowc field
There was no user interface, and the feature that it provides has lost
relevance over time.

Note that algorithms for block and/or bytecode still internally use some
equivalent of this parameter, but its initial value will no longer be
modifiable (which could lead to bugs, see commit
e49e7e906f).
2022-03-31 17:39:43 +02:00
Johannes Pfeifer 1ed765b8c4 perfect_foresight_solver_core.m: fix Fortran not 2022-03-25 14:23:11 +01:00
Sébastien Villemot e49e7e906f
Forbid changing the value of “slowc” if “block” or “bytecode” is used
The code is buggy and leads to wrong results, so forbid this combination.
2022-03-25 12:36:36 +01:00
Sébastien Villemot dd1ec10ec8
Block (without bytecode): use dynatol.f as convergence criterion for perfect foresight
Was incorrectly using solve_tolf.
2022-03-23 17:25:32 +01:00
Sébastien Villemot bef8d80ba8
More conversions to logical values 2022-03-23 16:52:40 +01:00
Sébastien Villemot bb793d87cc
Block decomposition: fix deterministic simulations for block of type “Solve backward”
The results were incorrect for those two kinds of block, when not using bytecode.
2022-02-09 14:07:33 +01:00
Stéphane Adjemian (Ryûk) f5f47cd834
Add new option last_simulation_period to initval_file command.
Also adjust the periods in Simulated_time_series (output of the perfect
foresight solver in the workspace). Note that this dseries object contains the
observations for the initial condition (M_.orig_maximum_lag observations) and
for the terminal condition (M_.orig_maximum_lead observations).

See #1838.

Fix testsuite (wrong file name)
2022-01-21 17:39:47 +01:00
Stéphane Adjemian (Charybdis) 38e1cd5d4e
Do not include auxiliaries in Simulated_time_series...
And add paths for the exogenous variables.
2022-01-21 16:50:42 +01:00
Johannes Pfeifer 8cf6fe0be4 perfect_foresight_setup.m: add line skip 2021-12-30 14:27:12 +01:00
Johannes Pfeifer ce9bb2f09d make_ex_.m: gracefully exit if user attempts to set non-existent period 0 2021-12-06 15:04:30 +01:00
Stéphane Adjemian (Ryûk) 0d092a36a0
Acknowledge option trust_region_initial_step_bound_factor in matlab based trust_region routine. 2021-07-23 19:44:16 +02:00
Sébastien Villemot abd64c256e
New perfect_foresight_with_expectation_errors_{setup,solver} commands
These command solve the problem where agents think they know perfectly the
future (they behave as in perfect foresight), but make expectation errors.
Hence they can potentially be surprised in every period, and their expectations
about the future (incl. the final steady state) may change.

Currently the sequence of information sets needs to be passed through a CSV
file. Another interface may be added in the future.

The algorithm uses a sequence of (true) perfect foresight simulations (not
necessarily as many as there are periods, because if the information set does
not change between two periods, there is no need to do a new computation).

There are two possibilities for guess values:
— the default is to use the initial steady state for the simulation using the
  first-period information set; then use previously simulated values as guess
  values
— alternatively, with the terminal_steady_state_as_guess_value option, use the
  terminal steady state as guess value for all future periods (this is actually
  what the “true” perfect foresight solver does by default)
2021-07-09 18:16:46 +02:00
Johannes Pfeifer f7a232061a
Remove unused options_-output
Prevents accidentally changing something
2021-06-22 18:17:11 +02:00
Sébastien Villemot 766fff88f6
Use secure URL for link to GNU licenses 2021-06-09 17:35:05 +02:00
Stéphane Adjemian (Charybdis) 27ee801a67
Add specialized version of sim1 for static models.
Also add an integration test and fix homotopy error message.
2021-05-28 14:11:34 +02:00
Johannes Pfeifer f97c138685 sim1_purely_backward.m: for purely static model, do not use past value for first iteration
Index 0 does not exist.
2021-05-27 22:37:45 +02:00
Sébastien Villemot ec28179043
Perfect foresight: add warning when lmmcp and linear option are used together 2021-04-20 16:53:54 +02:00
Stéphane Adjemian (Charybdis) a03b65bab7
Honour option solve_algo with backward models in perfect_foresight_solver. 2021-04-08 20:31:40 +02:00
Johannes Pfeifer b5a4c0695f perfect foresight: provide debugging information for singular Jacobian
Closes https://git.dynare.org/Dynare/dynare/-/issues/1732
2021-03-17 15:02:30 +01:00
Stéphane Adjemian (Odysseus) 0e1c9312e2
Merge remote-tracking branch 'Dynare/master' into enterprise 2021-01-11 11:06:55 +01:00
Johannes Pfeifer 7bdf07631a Provide better warnings when using ramsey_constraints 2020-12-18 12:59:29 +00:00
Stéphane Adjemian (Charybdis) 12ef75314a
Apply d8ddd9ef6 to deterministic exogenous variables.
(cherry picked from commit eceba8d6da)
2020-12-09 14:59:20 +01:00
Stéphane Adjemian (Charybdis) ffa828a659
Fixed multiple periods expected shocks in the case of mshocks.
(cherry picked from commit d8ddd9ef61)
2020-12-09 14:59:20 +01:00
Stéphane Adjemian (Charybdis) a669c3765d
Cosmetic change in doc headers. 2020-12-07 22:25:54 +01:00
Stéphane Adjemian (Charybdis) eceba8d6da
Apply d8ddd9ef6 to deterministic exogenous variables. 2020-12-07 22:25:54 +01:00
Stéphane Adjemian (Charybdis) d8ddd9ef61
Fixed multiple periods expected shocks in the case of mshocks. 2020-11-24 15:04:41 +01:00
Sébastien Villemot fcb52478e4
Preprocessor: replace exogenous with lead/lags by auxiliary variables in deterministic models
Several tests need to be adapted, because they were implicitly making the
assumption that there is no auxiliary variable.

Incidentally, this closes #1731. This commit therefore also removes the
workaround introduced in 0391dbbeb1.
2020-11-09 16:34:12 +01:00
Sébastien Villemot 029ab65e68
Perfect foresight with initval_file: fix another bug when M_.orig_maximum_lag ≠ M_.maximum_lag
Similar to 95dcb5f4b7.
2020-11-05 16:08:57 +01:00
Sébastien Villemot 95dcb5f4b7
Perfect foresight with initval_file: fix bug when M_.orig_maximum_lag ≠ M_.maximum_lag
By the way, remove inexact comment about a similar code in histvalf.m
2020-11-05 15:39:55 +01:00
Sébastien Villemot 5fab01c534
Perfect foresight: fix case where max lead/lag on exo is greater than max lead/lag on endo
Bug introduced in commit e21cb1ad6b

Ref. #1720
2020-10-21 19:12:22 +02:00
Sébastien Villemot e21cb1ad6b
LMMCP: fix the purely backward and purely forward cases
Closes: #1720
2020-10-21 16:30:40 +02:00
Sébastien Villemot 4ba0f0a9c3
LMMCP: don’t report a wrong maxerror, rather put NaN 2020-10-20 18:27:19 +02:00
Sébastien Villemot 46da76c0ce
LMMCP: fix bug when periods=1
The fix in commit 24cc67e585 was incorrect.
2020-10-20 18:20:04 +02:00
Sébastien Villemot 87cc519321
LMMCP / linear perfect foresight: fix bug for models with a single equation
The routines use the find() function applied to a subset of columns of the
Jacobian, which in this case is a row vector. When passed a row vector, find()
returns row vectors (while it returns column vectors when passed a column
vector or a matrix). This case was not correctly handled.
2020-10-20 18:20:02 +02:00
Stéphane Adjemian (Odysseus) 248ad18846 Merge remote-tracking branch 'Dynare/master' into enterprise
Fixed conflicts in:

 - .gitlab-ci.yml
 - matlab/dynare_config.m
 - matlab/dynare_solve.m
 - matlab/initvalf.m
 - matlab/perfect-foresight-models/make_ex_.m
 - matlab/perfect-foresight-models/perfect_foresight_setup.m
 - mex/build/matlab/Makefile.am
 - mex/build/matlab/configure.ac
 - mex/build/octave/Makefile.am
 - mex/build/octave/configure.ac
 - mex/sources/Makefile.am
 - preprocessor
 - tests/Makefile.am
2020-09-17 14:53:32 +02:00
MichelJuillard 0391dbbeb1 fix bug with lag on exogenous variables on more than one period
(cherry picked from commit 492124ce9886e6aef4f4cefef302241d7edfe024)
2020-09-04 14:02:04 +00:00
Sébastien Villemot 41fe087106
Block decomposition: static and dynamic files are now pure wrappers around the per-block files
Systematically call top-level static/dynamic files, instead of per-block ones.
2020-06-19 18:46:56 +02:00
Sébastien Villemot 0305b427a6
Block decomposition: use same orientation convention as oo_.endo_simul for matrix of simulated paths
Improves consistency, but also efficiency (less transpose needed).
2020-06-17 18:19:35 +02:00
Sébastien Villemot 20431ed312
Block decomposition: in the dynamic file, y and T are now vectors as in non-block mode 2020-06-17 18:19:21 +02:00
Sébastien Villemot 7bec234f7f
Block decomposition: for evaluate blocks, move the iteration loop outside the dynamic file 2020-06-15 18:29:42 +02:00
Sébastien Villemot fae433fb18
Block decomposition: fix bug introduced in 0d11f8182a 2020-06-04 18:15:54 +02:00
Sébastien Villemot 0d11f8182a
Block decomposition: no longer compute deterministic simulation from dynamic.m file
By the way, fix bug where oo_ was not modified by solve_one_boundary.

Also convert oo_.deterministic_simulations.status to a boolean in the block
routines, for consistency with the non-block case.
2020-06-02 17:46:29 +02:00
Stéphane Adjemian (Charybdis) 9a66f3ebd9
Allow shocks with initval_file. 2020-05-18 12:21:43 +02:00
Michel Juillard b70d99d1b4
Refactoring of initval_file and histval_file
initval_file and hisvfal_file are now more flexible and have functionalities
similar to option datafile in estimation.

Closes: #1671
2020-05-14 16:45:54 +02:00
Michel Juillard fd09b98150 fix bug when no convergence and backward model 2020-03-31 15:40:49 +02:00
Houtan Bastani eb6ab0696a
gui: added fields to `oo_` to indicate which commands have been run 2020-03-03 11:45:46 +01:00
Johannes Pfeifer 8aad715183 det_cond_forecast.m: always set options_.qz_criterium
Closes https://git.dynare.org/Dynare/dynare/issues/1701
2020-02-02 14:15:01 +01:00
Sébastien Villemot 7e770f69e7
Remove workaround for errors in MEX files
Because at some point throwing exceptions from MEX files (with mexErrMsgTxt())
was not working under Windows 64-bit, we had designed a workaround to avoid
using exceptions.

Most MEX files were returning an error code as their first (or sometimes last)
argument, and that code would have to be checked from the MATLAB code.

Since this workaround is no longer needed, this commit removes it. As a
consequence, the interface of many MEX files is modified.

For some background, see https://www.dynare.org/pipermail/dev/2010-September/000895.html
2020-01-10 18:33:11 +01:00
Sébastien Villemot a95358accc Merge branch 'sim1' into 'master'
sim1.m: provide missing function input to nested function

See merge request Dynare/dynare!1691
2020-01-06 13:22:29 +00:00
Johannes Pfeifer 632c0a3943 sim1.m: provide missing function input to nested function 2020-01-06 09:06:18 +01:00
Sébastien Villemot 49dc997073
Global reindentation of MATLAB code (excluding submodules)
Also convert to Unix end-of-lines, and remove trailing whitespaces.
2019-12-20 16:30:27 +01:00
Sébastien Villemot efa6c6c682
“datafile” option of “perfect_foresight_setup” (and “simul”) now equivalent to “initval_file”
Ref. #1663
2019-12-19 14:58:54 +01:00
Michel Juillard d0247277f9 after check, oo_.dr isn't empty but oo_.dr.ghx + friends don't exist 2019-11-25 21:54:53 +01:00
Michel Juillard f6daa359b7 fix tolf and tolx options for sim1_purely_forward 2019-11-23 22:47:17 +01:00
Michel Juillard 2652cb0dd7 fix tolf and tolx options for sim1_purely_backward 2019-11-23 22:44:10 +01:00
Houtan Bastani 7712a02f02
add print and noprint option to perfect_foresight_solver. closes #1647 2019-09-12 14:50:14 +02:00
Houtan Bastani 3d6091b3a1
remove unused return arguments 2019-09-12 14:01:52 +02:00
Houtan Bastani e043c60903
pass M_, options_, oo_ as arguments to stoch_simul, simult_, discretionary_policy. closes dynare#1197 2019-09-12 11:57:01 +02:00
Sébastien Villemot f8af21819e
Simplify the interface to perfect_foresight_problem MEX 2019-07-09 14:33:17 +02:00
Sébastien Villemot 2ad6b31d76
Option endogenous_terminal_period is only available for stack_solve_algo=0 2019-07-04 18:37:27 +02:00
Sébastien Villemot 7d9b2a557b
perfect_foresight_problem MEX: number of threads is now configurable 2019-06-27 17:00:12 +02:00
Sébastien Villemot 5b591fac42
New perfect_foresight_problem MEX file
It constructs the stacked residuals and jacobian of the perfect foresight
problem.

It is an almost perfect replacement for the perfect_foresight_problem.m
routine, while being much more efficient.

Note however that the DLL never return complex numbers (it instead puts NaNs at
the place where there would have been complex). This may create problems for
some MOD files; the algorithms will need to be adapted to use a more
line-search method.
2019-06-24 17:53:59 +02:00
Sébastien Villemot aedc9fb2e4
Bugfix: perfect_foresight_setup safety check does not correctly index M_.lead_lag_incidence 2019-06-18 17:01:06 +02:00