Skip to content
Snippets Groups Projects
Verified Commit 4aadc533 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Efficiency change. Update initial condition of SEP auxiliary model...

In each iteration using the solution from previous step. Previously
the initial guess for the auxiliary stochastic perfect forsight model
was the steady state in all periods and (future) worlds.
parent cea9a851
No related branches found
No related tags found
No related merge requests found
......@@ -68,23 +68,25 @@ while (t <= samplesize)
initialguess = [];
end
if t>2
[endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths] = extended_path_core(innovations.positive_var_indx, ...
[endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths, y] = extended_path_core(innovations.positive_var_indx, ...
spfm_exo_simul, ...
endogenous_variables_paths(:,t-1), ...
pfm, ...
M_, ...
options_, ...
oo_, ...
initialguess);
initialguess, ...
y);
else
[endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths, pfm, options_] = extended_path_core(innovations.positive_var_indx, ...
[endogenous_variables_paths(:,t), info_convergence, endogenousvariablespaths, y, pfm, options_] = extended_path_core(innovations.positive_var_indx, ...
spfm_exo_simul, ...
endogenous_variables_paths(:,t-1), ...
pfm, ...
M_, ...
options_, ...
oo_, ...
initialguess);
initialguess, ...
[]);
end
if ~info_convergence
msg = sprintf('No convergence of the (stochastic) perfect foresight solver (in period %s)!', int2str(t));
......
function [y, info_convergence, endogenousvariablespaths, pfm, options_] = extended_path_core(positive_var_indx, ...
function [y1, info_convergence, endogenousvariablespaths, y, pfm, options_] = extended_path_core(positive_var_indx, ...
exo_simul, ...
initial_conditions ,...
pfm, ...
M_, ...
options_, ...
oo_, ...
initialguess)
initialguess, ...
y)
% Copyright © 2016-2025 Dynare Team
%
......@@ -41,7 +42,7 @@ stack_solve_algo = ep.stack_solve_algo;
if init% Compute first order solution (Perturbation)...
endo_simul = simult_(M_,options_,initial_conditions,oo_.dr,exo_simul(2:end,:),1);
else
if nargin==8 && ~isempty(initialguess)
if nargin>7 && ~isempty(initialguess)
% Note that the first column of initialguess should be equal to initial_conditions.
endo_simul = initialguess;
else
......@@ -49,6 +50,10 @@ else
end
end
if nargin~=9
y = [];
end
oo_.endo_simul = endo_simul;
if debug
......@@ -77,17 +82,17 @@ else
switch(algo)
case 0
% Full tree of future trajectories.
if nargout>3
[flag, endogenousvariablespaths, errorcode, ~, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, options_, M_, pfm);
if nargout>4
[flag, endogenousvariablespaths, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, y, options_, M_, pfm);
else
[flag, endogenousvariablespaths, errorcode] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, options_, M_, pfm);
[flag, endogenousvariablespaths, errorcode, y] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, y, options_, M_, pfm);
end
case 1
% Sparse tree of future histories.
if nargout>3
[flag, endogenousvariablespaths, errorcode, ~, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options_, M_, pfm);
if nargout>4
[flag, endogenousvariablespaths, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, y, options_, M_, pfm);
else
[flag, endogenousvariablespaths, errorcode] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options_, M_, pfm);
[flag, endogenousvariablespaths, errorcode, y] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, y, options_, M_, pfm);
end
end
info_convergence = ~flag;
......@@ -98,7 +103,7 @@ if ~info_convergence && ~options_.no_homotopy
end
if info_convergence
y = endogenousvariablespaths(:,2);
y1 = endogenousvariablespaths(:,2);
else
y = NaN(size(endo_nbr,1));
y1 = NaN(size(endo_nbr,1));
end
function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, options_, M_, pfm)
function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_0(endo_simul, exo_simul, y, options_, M_, pfm)
% Copyright © 2025 Dynare Team
%
......@@ -148,7 +148,9 @@ end
pfm.Y = repmat(endo_simul(:),1,pfm.world_nbr);
y = repmat(pfm.steady_state, pfm.dimension/pfm.ny, 1);
if isempty(y)
y = repmat(pfm.steady_state, pfm.dimension/pfm.ny, 1);
end
if update_options_struct
% Set algorithm
......
function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options_, M_, pfm)
function [errorflag, endo_simul, errorcode, y, pfm, options_] = solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, y, options_, M_, pfm)
% Copyright © 2012-2025 Dynare Team
%
......@@ -113,7 +113,9 @@ if update_pfm_struct
end
y = repmat(pfm.steady_state, pfm.block_nbr, 1);
if isempty(y)
y = repmat(pfm.steady_state, pfm.block_nbr, 1);
end
if update_options_struct
% Set algorithm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment