diff --git a/matlab/ep/extended_path.m b/matlab/ep/extended_path.m index 1e07356429172d30cc100044c173bd5d3c13565e..23c6a36d86cd45876390c8146c02cc7d2ad5a972 100644 --- a/matlab/ep/extended_path.m +++ b/matlab/ep/extended_path.m @@ -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!'); diff --git a/matlab/ep/homotopic_steps.m b/matlab/ep/homotopic_steps.m index 3801e003e417c5b50aa6d760d5f6ea3dd1838b5b..609966c4b9bee5aa4fd657a8e1924fe80c2c1285 100644 --- a/matlab/ep/homotopic_steps.m +++ b/matlab/ep/homotopic_steps.m @@ -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;