Added calls to matlab implementation of the perfect foresight solver in homotopic routine (extended path approach).

time-shift
Stéphane Adjemian (Charybdis) 2012-02-04 18:52:03 +01:00
parent 133e51e6d6
commit 9dfc0d5c08
2 changed files with 22 additions and 5 deletions

View File

@ -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!');

View File

@ -1,6 +1,9 @@
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;