Skip to content
Snippets Groups Projects
Commit 9dfc0d5c authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Added calls to matlab implementation of the perfect foresight solver in...

Added calls to matlab implementation of the perfect foresight solver in homotopic routine (extended path approach).
parent 133e51e6
Branches
Tags
No related merge requests found
......@@ -349,9 +349,9 @@ while (t<sample_size)
end
end% while
if ~info.convergence% If exited from the while loop without achieving convergence, use an homotopic approach
[INFO,tmp] = homotopic_steps(.5,.01);
[INFO,tmp] = homotopic_steps(.5,.01,pfm);
if (~isstruct(INFO) && isnan(INFO)) || ~INFO.convergence
[INFO,tmp] = homotopic_steps(0,.01);
[INFO,tmp] = homotopic_steps(0,.01,pfm);
if ~INFO.convergence
disp('Homotopy:: No convergence of the perfect foresight model solver!')
error('I am not able to simulate this model!');
......
function [info,tmp] = homotopic_steps(initial_weight,step_length)
function [info,tmp] = homotopic_steps(initial_weight,step_length,pfm)
global oo_ options_ M_
%Set bytecode flag
bytecode_flag = options_.ep.use_bytecode;
% Set increase and decrease factors.
increase_factor = 5.0;
decrease_factor = 0.2;
......@@ -53,7 +56,14 @@ for d=1:stochastic_extended_path_depth
if d>1
oo_.exo_simul(1:idx(d-1),:) = exxo_simul(1:idx(d-1),:);
end
[flag,tmp] = bytecode('dynamic');
if bytecode_flag
[flag,tmp] = bytecode('dynamic');
else
flag = 1;
end
if flag
[flag,tmp] = solve_perfect_foresight_model(oo_.endo_simul,oo_.exo_simul,pfm);
end
info.convergence = ~flag;% Equal to one if the perfect foresight solver converged for the current value of weight.
if verbose
if info.convergence
......@@ -117,7 +127,14 @@ for d=1:stochastic_extended_path_depth
end
if weight<1
oo_.exo_simul = exxo_simul;
[flag,tmp] = bytecode('dynamic');
if bytecode_flag
[flag,tmp] = bytecode('dynamic');
else
flag = 1;
end
if flag
[flag,tmp] = solve_perfect_foresight_model(oo_.endo_simul,oo_.exo_simul,pfm);
end
info.convergence = ~flag;
if info.convergence
oo_.endo_simul = tmp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment