From e0475fd4ef5011ea38de6260ec2ef8717ae2e05c Mon Sep 17 00:00:00 2001 From: Michel Juillard Date: Tue, 31 May 2016 12:09:23 +0200 Subject: [PATCH] extended path: use deterministic_simulation.status instead of maxerror --- matlab/ep/extended_path_core.m | 4 ++-- matlab/ep/extended_path_homotopy.m | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/matlab/ep/extended_path_core.m b/matlab/ep/extended_path_core.m index 303e20660..da7953250 100644 --- a/matlab/ep/extended_path_core.m +++ b/matlab/ep/extended_path_core.m @@ -57,8 +57,8 @@ if flag options.lmmcp = olmmcp; options.solve_algo = solve_algo; options.stack_solve_algo = stack_solve_algo; - [tmp, maxerror] = perfect_foresight_solver_core(M, options, oo); - if maxerror>options.dynatol.f + tmp = perfect_foresight_solver_core(M, options, oo); + if ~tmp.deterministic_simulation.status info_convergence = false; else info_convergence = true; diff --git a/matlab/ep/extended_path_homotopy.m b/matlab/ep/extended_path_homotopy.m index 577f51ced..7736a2c35 100644 --- a/matlab/ep/extended_path_homotopy.m +++ b/matlab/ep/extended_path_homotopy.m @@ -18,10 +18,8 @@ function [info_convergence, endo_simul] = extended_path_homotopy(endo_simul, exo % along with Dynare. If not, see . +endo_simul0 = endo_simul; if ismember(method, [1, 2]) - if isequal(method, 2) - endo_simul0 = endo_simul; - end noconvergence = true; iteration = 0; weight = .1; @@ -34,9 +32,10 @@ if ismember(method, [1, 2]) while noconvergence iteration = iteration + 1; oo.endo_simul = endo_simul; + oo.endo_simul(:,1) = oo.steady_state + weight*(endo_simul0(:,1) - oo.steady_state); oo.exo_simul = bsxfun(@plus, weight*exo_simul, (1-weight)*transpose(oo.exo_steady_state)); if order==0 - [tmp, maxerror] = perfect_foresight_solver_core(M, options, oo); + tmp = perfect_foresight_solver_core(M, options, oo); else switch(algo) case 0 @@ -49,7 +48,7 @@ if ismember(method, [1, 2]) end if isequal(order, 0) % Logical variable flag is false iff the solver fails. - flag = ~(maxerror>options.dynatol.f); + flag = ~tmp.deterministic_simulation.status; else % Fix convention issue on the value of flag. flag = ~flag; @@ -105,7 +104,7 @@ if isequal(method, 3) || (isequal(method, 2) && noconvergence) oo.endo_simul = endo_simul; oo.exo_simul = bsxfun(@plus, weight*exo_simul, (1-weight)*transpose(oo.exo_steady_state)); if order==0 - [tmp, maxerror] = perfect_foresight_solver_core(M, options, oo); + tmp = perfect_foresight_solver_core(M, options, oo); else switch(algo) case 0 @@ -118,7 +117,7 @@ if isequal(method, 3) || (isequal(method, 2) && noconvergence) end if isequal(order, 0) % Logical variable flag is false iff the solver fails. - flag = ~(maxerror>options.dynatol.f); + flag = ~tmp.deterministic_simulation.status; else % Fix convention issue on the value of flag. flag = ~flag;