diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index b45fce6ad8f8082c6d96a3e18826cd1b882cf5cc..4eee8396bf10d19f3c0e2ed78e5eaa8c28b30889 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -5309,6 +5309,13 @@ which is described below. rate or a model with irreversible investment). For specifying the necessary complementarity conditions, see :opt:`lmmcp`. + .. option:: use_first_order_solution + + Utilize the model simulation based on a first-order local + approximation as the initial guess for the nonlinear solver in + each period. If this is not applied, solution in previous + period is used. + Typology and ordering of variables ---------------------------------- diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index a1d501d980702871ec3c5b698f2e98cda5b330e1..300b4c6114fdac8e970ca01769904bd75ffda4bd 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -12,7 +12,7 @@ function options_ = default_option_values(M_) % SPECIAL REQUIREMENTS % none -% Copyright © 2018-2024 Dynare Team +% Copyright © 2018-2025 Dynare Team % % This file is part of Dynare. % @@ -195,8 +195,7 @@ ep.use_bytecode = 0; % Initialization of the perfect foresight equilibrium paths % * init=0, previous solution is used. % * init=1, a path generated with the first order reduced form is used. -% * init=2, mix of cases 0 and 1. -ep.init = 0; +ep.use_first_order_solution_as_initial_guess = false; % Maximum number of iterations for the deterministic solver. ep.maxit = 500; % Number of periods for the perfect foresight model. diff --git a/matlab/ep/euler_equation_error.m b/matlab/ep/euler_equation_error.m index 3bb304a5697dfe7a67b054bb6ed844da3960deb0..c8b04725fabaf6415b0df3e8e4ab487bc0facd2b 100644 --- a/matlab/ep/euler_equation_error.m +++ b/matlab/ep/euler_equation_error.m @@ -1,7 +1,7 @@ function e = euler_equation_error(y0,x,innovations,M_,options_,oo_,pfm,nodes,weights) % e = euler_equation_error(y0,x,innovations,M_,options_,oo_,pfm,nodes,weights) -% Copyright © 2016-2023 Dynare Team +% Copyright © 2016-2025 Dynare Team % % This file is part of Dynare. % @@ -23,7 +23,7 @@ ep = options_.ep; y1 = extended_path_core(ep.periods, ... M_.endo_nbr, M_.exo_nbr, ... innovations.positive_var_indx, ... - x, ep.init, y0, oo_.steady_state, ... + x, ep.use_first_order_solution_as_initial_guess, y0, oo_.steady_state, ... 0, ... ep.stochastic.order, M_, ... pfm, ep.stochastic.algo, ... @@ -38,7 +38,7 @@ for i=1:length(nodes) x2 = x1; x2(2,:) = x2(2,:) + nodes(i,:); y2 = extended_path_core(ep.periods, M_.endo_nbr, M_.exo_nbr, ... - innovations.positive_var_indx, x2, ep.init, ... + innovations.positive_var_indx, x2, ep.use_first_order_solution_as_initial_guess, ... y1, oo_.steady_state, 0, ... ep.stochastic.order, M_, pfm, ep.stochastic.algo, ... ep.solve_algo, ep.stack_solve_algo, options_.lmmcp, ... diff --git a/matlab/ep/extended_path.m b/matlab/ep/extended_path.m index fe1bf640ef13e7db0067614db43aff715e320612..2b807d36f8b3de236ab821cbd7284f85cac94f1e 100644 --- a/matlab/ep/extended_path.m +++ b/matlab/ep/extended_path.m @@ -19,7 +19,7 @@ function [ts,oo_] = extended_path(initialconditions, samplesize, exogenousvariab % % SPECIAL REQUIREMENTS -% Copyright © 2009-2023 Dynare Team +% Copyright © 2009-2025 Dynare Team % % This file is part of Dynare. % @@ -68,7 +68,7 @@ while (t <= samplesize) initialguess = []; end [endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths] = extended_path_core(ep.periods, M_.endo_nbr, M_.exo_nbr, innovations.positive_var_indx, ... - spfm_exo_simul, ep.init, endogenous_variables_paths(:,t-1), ... + spfm_exo_simul, ep.use_first_order_solution_as_initial_guess, endogenous_variables_paths(:,t-1), ... oo_.steady_state, ... verbosity, ep.stochastic.order, ... M_, pfm, ep.stochastic.algo, ep.solve_algo, ep.stack_solve_algo, ... @@ -106,4 +106,4 @@ if any(isnan(endogenous_variables_paths(:))) end ts = dseries(transpose(endogenous_variables_paths), initial_period, M_.endo_names); -oo_.endo_simul = transpose(ts.data); \ No newline at end of file +oo_.endo_simul = transpose(ts.data); diff --git a/matlab/ep/extended_path_initialization.m b/matlab/ep/extended_path_initialization.m index 362788dec98ee0ca319c1a1338614a02fff9a562..0359b9ee23ad5f1f61e4e29ebb5271def398ba89 100644 --- a/matlab/ep/extended_path_initialization.m +++ b/matlab/ep/extended_path_initialization.m @@ -16,7 +16,7 @@ function [initial_conditions, innovations, pfm, ep, verbosity, options_, oo_] = % % SPECIAL REQUIREMENTS -% Copyright © 2016-2024 Dynare Team +% Copyright © 2016-2025 Dynare Team % % This file is part of Dynare. % @@ -71,7 +71,7 @@ options_.stack_solve_algo = ep.stack_solve_algo; % Compute the first order reduced form if needed. dr = struct(); -if ep.init +if ep.use_first_order_solution_as_initial_guess options_.order = 1; oo_.dr=set_state_space(dr,M_); [oo_.dr,info,M_.params] = resol(0,M_,options_,oo_.dr,oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state); diff --git a/matlab/ep/extended_path_mc.m b/matlab/ep/extended_path_mc.m index fcfe284b54c0270eea6db5b74443ca5db2a81a73..b49f4bcbba5c3ca689a5d392352b08a5204c0845 100644 --- a/matlab/ep/extended_path_mc.m +++ b/matlab/ep/extended_path_mc.m @@ -19,7 +19,7 @@ function Simulations = extended_path_mc(initialconditions, samplesize, replic, e % % SPECIAL REQUIREMENTS -% Copyright © 2016-2023 Dynare Team +% Copyright © 2016-2025 Dynare Team % % This file is part of Dynare. % @@ -81,8 +81,8 @@ if ep.parallel spfm_exo_simul(2,:) = shocks(t-1,:); exogenous_variables_paths(:,t) = shocks(t-1,:); [endogenous_variables_paths(:,t), info_convergence] = extended_path_core(ep.periods, M_.endo_nbr, M_.exo_nbr, innovations_.positive_var_indx, ... - spfm_exo_simul, ep.init, endogenous_variables_paths(:,t-1), ... - oo__.steady_state, ... + spfm_exo_simul, ep.use_first_order_solution_as_initial_guess, endogenous_variables_paths(:,t-1), ... + oo__.steady_state, ... ep.verbosity, ep.stochastic.order, ... M_, pfm,ep.stochastic.algo, ep.solve_algo, ep.stack_solve_algo, ... options_.lmmcp, options_, oo__); @@ -110,8 +110,8 @@ else spfm_exo_simul(2,:) = shocks(t-1,:); exogenous_variables_paths(:,t) = shocks(t-1,:); [endogenous_variables_paths(:,t), info_convergence] = extended_path_core(ep.periods, M_.endo_nbr, M_.exo_nbr, innovations.positive_var_indx, ... - spfm_exo_simul, ep.init, endogenous_variables_paths(:,t-1), ... - oo_.steady_state, ... + spfm_exo_simul, ep.use_first_order_solution_as_initial_guess, endogenous_variables_paths(:,t-1), ... + oo_.steady_state, ... ep.verbosity, ep.stochastic.order, ... M_, pfm,ep.stochastic.algo, ep.solve_algo, ep.stack_solve_algo, ... options_.lmmcp, options_, oo_); diff --git a/preprocessor b/preprocessor index 86822b5e6e8b5fc3f98673d6e6d21eed8051e2d4..991759b2c7c60b59a41e1079cdfcf938170d716c 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 86822b5e6e8b5fc3f98673d6e6d21eed8051e2d4 +Subproject commit 991759b2c7c60b59a41e1079cdfcf938170d716c