Commit Graph

139 Commits (7dd2dd5e24a343fbeaf3522ea5e535c27d8b9f95)

Author SHA1 Message Date
Johannes Pfeifer 3fbab4cbe0 Provisions for solving steady state with MCP-tag 2022-09-12 17:18:16 +02:00
Sébastien Villemot 13709f6853
Add “fsolve_options” option to “steady” command
Closes: #1856
2022-07-22 14:35:19 +02:00
Sébastien Villemot ceedb4869e
solve_algo=0: move to optimoptions under MATLAB, and to new options names for MATLAB⩾R2016a 2022-07-22 14:21:42 +02:00
Johannes Pfeifer 5788f1bc71 dynare_solve: deal with Dulmage-Mendelsohn decomposition returns a non-square block
Related to https://git.dynare.org/Dynare/dynare/-/issues/1851
2022-06-27 15:30:14 +02:00
Sébastien Villemot 5ccd5f2613
Revert "More explicit message when the Dulmage-Mendelsohn decomposition returns a non-square block"
This reverts commit fa71d4712d.

Ref. #1851
2022-06-16 18:05:14 +02:00
Sébastien Villemot fa71d4712d
More explicit message when the Dulmage-Mendelsohn decomposition returns a non-square block
Closes: #1851
2022-06-16 15:53:45 +02:00
Johannes Pfeifer 31ea784a5c dynare_solve.m: honor tolx in fsolve 2022-05-17 15:27:21 +02:00
Stéphane Adjemian (Charybdis) 931a9ba336
Use residuals and jacobian matrix returned by fsolve routine. 2022-04-19 19:20:20 +02:00
Sébastien Villemot ce7540747b
dynare_solve: fix bug introduced in ef2bb4e669
The feval(f, x, args{:}) call would fail under Octave because the contents of
args{:} would be appended twice (hence too many input arguments error).

The same bug would materialize under MATLAB for errorcode>1.
2022-04-19 17:52:37 +02:00
Sébastien Villemot a0e78957da
Octave 7 compatibility fix: “arguments” is a reserved keyword
This confuses the Octave 7 parser in the context of anonymous functions.

Simply rename the variable to “args”.
2022-04-15 14:32:54 +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) 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
Stéphane Adjemian (Ryûk) fe7d05f46a
Remove unnecessary condition (Octave/fsolve).
Since we already have checked that the initial guess is not a solution.
2022-04-09 16:06:24 +02:00
Stéphane Adjemian (Ryûk) 33b1827ea5
Bug fix (mixed complementarity problems). 2022-04-09 16:06:24 +02:00
Stéphane Adjemian (Ryûk) 48c41e6b0d
Return the initial guess if nonlinear system is ill-behaved...
At the initial guess, and we were not able to find another guess (randomizing).
2022-04-09 16:06:24 +02:00
Stéphane Adjemian (Ryûk) 56863d6e2f
Exit if initial guess is a solution...
Without entering in the nonlinear solvers.
2022-04-09 16:06:24 +02:00
Stéphane Adjemian (Ryûk) f2bf98ee76
Return the value of info as a third argument (block_trust_region). 2022-03-25 19:42:40 +01:00
Stéphane Adjemian (Ryûk) aa8439d4cc
New implementation of the trust region algorithm.
Main difference is the presence of traps for NaN/Inf/Complex numbers in
residuals or the Jacobian matrix. Also added new unit tests.
2022-03-25 19:42:40 +01:00
Stéphane Adjemian (Ryûk) 882091cc97
Return more info about nonlinear solver failures (solve1). 2022-03-03 22:30:38 +01:00
Stéphane Adjemian (Ryûk) 7072359241
Fix fifth output introduced in e815fb2 (exitflag was not updated). 2022-03-03 21:56:44 +01:00
Stéphane Adjemian (Ryûk) e815fb2901
Display exitflag returned by fsolve.
When the Newton fails in the simulation of backward models.
2022-03-03 18:19:33 +01:00
Johannes Pfeifer 0aadc88602 dynare_solve.m: allow turning off display of messages 2021-11-23 12:41:35 +01:00
Stéphane Adjemian (Ryûk) 873a9b1a38
Fix call to solve1 routine. 2021-07-23 22:16:43 +02: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
Stéphane Adjemian (Ryûk) e72dde69d3
Add option for trust region algorithm (mex).
trust_region_initial_step_bound_factor is determinining thye initial
step bound. Default value is 100 (previous hard coded value was 1).
2021-07-23 19:44:16 +02:00
Sébastien Villemot 766fff88f6
Use secure URL for link to GNU licenses 2021-06-09 17:35:05 +02:00
Johannes Pfeifer e546d686eb dynare_solve.m: allow calling function directly 2021-06-04 21:24:53 +02:00
Johannes Pfeifer 4e0f2bf695 dynare_solve.m: have csolve honor selected options 2021-06-02 16:21:16 +02:00
Stéphane Adjemian (Charybdis) 237aa465d2
Fix precision in perfect_foresight_solver for backward models. 2021-04-08 20:31:40 +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
Stéphane Adjemian (Charybdis) 511908e011
Factorized initialization of fields required by solve_algo={12,14}.
Closes #3.
2020-09-25 23:45:21 +02:00
Sébastien Villemot 865ab47fa9
Provide block_trust_region MEX under solve_algo 13 and 14
- block trust region solver now available under solve_algo=13
  It is essentially the same as solve_algo=4, except that Jacobian by finite
  difference is not handled. A test file is added for that case
- block trust region solver with shortcut for equations that can be evaluated
  is now available under solve_algo=14 (in replacement of the pure-MATLAB solver)

Closes: Enterprise/dynare#3
2020-09-18 18:01:56 +02:00
Sébastien Villemot 0b41d17374
dynare_solve: fix display of number of dmperm blocks 2020-09-18 17:55:58 +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
Johannes Pfeifer 607a273bb0 Correctly distinguish tolerance between steady and perfect foresight
steady uses options_.solve_tolf as a termination criterion, so subsequent checks should do the same. Similarly, solve_tolx was never used.
2020-07-06 13:11:23 +02:00
Sébastien Villemot 43ed7b2b69
Merge remote-tracking branch 'community/master' into enterprise 2020-03-27 16:28:41 +01:00
Stéphane Adjemian (Charybdis) b4db697e0f
Cosmetic change. 2020-03-11 12:47:02 +01:00
Stéphane Adjemian (Charybdis) a4519f6b86
Bug fix (solve_algo={12,14}).
Removed threshold for detecting the non zero elements in the rows of
the Jacobian matrix. Using tolf as a threshold parameter for identifying
the non zero elements leaded (not systematically) the algorithm to not
reevaluate the residuals of the dynamic model while necessary.
2020-03-11 12:38:59 +01:00
Stéphane Adjemian (Charybdis) 67b18710e8
Bug fix and efficiency change.
- Even in models where there is only one endogenous variable in the
   LHS and where all the LHS are unique, it may be that because of the
   preprocessor transformations an auxiliary variable appears in more
   than one LHS. If diff(X) is on the LHS of an equation in the original
   model, the preprocessor will create an auxiliary variable AUX_DIFF
   which will appear in the the original equation, replacing diff(X),
   and in a new equation defining the auxiliary variable. In this case
   the, the Dulmage-Mendelsohn decomposition will associate AUX_DIFF
   with the original equation and X with the equation. This was
   problematic in the previous version of the algorithm, since it was
   assumed that each equation determines the LHS variable (here AUX_DIFF
   = X - X(-1) determines a RHS variable (X).

 - Changed the expression for evaluating an LHS variable under a log.

 - Improved efficiency by not evaluating the residuals of the model if
   not required for solving the current univariate block.
2020-02-27 22:08:21 +01:00
Stéphane Adjemian (Charybdis) fa95a6347d
Added new nonlinear solvers (solve_algo 12 and 14).
These algorithms are alternative versions of 2 and 4 specialized for
models where each equation has only one endogenous variable on the
left hand side (only allowed expression on LHS is the log of an
endogenous variable). Univariate recursive blocks are then not solved
with a non linear but by evaluating the RHS expression.
2020-02-20 13:07:54 +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
Johannes Pfeifer 1b56a56e78 dynare_solve.m: return with valid solution even if Jacobian is ill-behaved
In pathological cases, the Jacobian at the initial but true steady state value is ill-behaved. In this case we should return with the valid steady state instead of trying random starting values
2019-12-12 19:08:43 +01:00
Stéphane Adjemian (Scylla) f3600b0de9
Added trap for complex residuals and jacobian in nonlinear solver. 2019-10-01 14:40:17 +02:00
Sébastien Villemot cbb59fe6f8
Merge remote-tracking branch 'community/master' into enterprise 2019-09-26 16:54:27 +02:00
Stéphane Adjemian (Charybdis) 99edfc52ed Removed unused routine. 2019-04-26 15:55:48 +02:00
Sébastien Villemot 89a3e94cbf
Use true/false instead of 1/0 for boolean options
This is more elegant, and makes it easier to distinguish them from integer
options.

Also simplify test expressions for these boolean options.
2019-03-19 15:21:16 +01:00
Stéphane Adjemian (Scylla) 2d717dbd3e Fixed returned fvec and fjac with solve_algo=3. 2017-09-29 10:29:20 +02:00
Stéphane Adjemian (Scylla) 6a2736d498 Fixed returned fvec and fjac with solve_algo=3. 2017-09-29 10:23:58 +02:00
Stéphane Adjemian (Scylla) b429a23852 Added trap for complex residuals and jacobian in nonlinear solver. 2017-09-29 10:19:54 +02:00
Stéphane Adjemian (Charybdis) 57cab69530 Try random initial guess for dynare_solve...
... If for the default initial guess we obtain NaNs or Infs in the residuals
and/or the Jacobian matrix.

(cherry picked from commit d282226100)
2017-06-14 00:01:10 +02:00