2016-04-29 23:23:07 +02:00
|
|
|
function [y, info_convergence, endogenousvariablespaths] = extended_path_core(periods,endo_nbr,exo_nbr,positive_var_indx, ...
|
2017-05-16 15:10:20 +02:00
|
|
|
exo_simul,init,initial_conditions,...
|
|
|
|
steady_state, ...
|
|
|
|
debug,bytecode_flag,order,M,pfm,algo,solve_algo,stack_solve_algo,...
|
|
|
|
olmmcp,options,oo,initialguess)
|
2016-03-05 15:55:22 +01:00
|
|
|
|
2017-05-18 18:36:38 +02:00
|
|
|
% Copyright (C) 2016-2017 Dynare Team
|
2016-03-05 15:55:22 +01:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
ep = options.ep;
|
2016-05-03 15:50:02 +02:00
|
|
|
|
2016-03-05 15:55:22 +01:00
|
|
|
if init% Compute first order solution (Perturbation)...
|
|
|
|
endo_simul = simult_(initial_conditions,oo.dr,exo_simul(2:end,:),1);
|
|
|
|
else
|
2016-04-29 23:23:07 +02:00
|
|
|
if nargin==20 && ~isempty(initialguess)
|
|
|
|
% Note that the first column of initialguess should be equal to initial_conditions.
|
|
|
|
endo_simul = initialguess;
|
|
|
|
else
|
|
|
|
endo_simul = [initial_conditions repmat(steady_state,1,periods+1)];
|
|
|
|
end
|
2016-03-05 15:55:22 +01:00
|
|
|
end
|
2016-04-29 23:23:07 +02:00
|
|
|
|
2016-03-05 15:55:22 +01:00
|
|
|
oo.endo_simul = endo_simul;
|
2016-04-29 23:23:07 +02:00
|
|
|
|
|
|
|
if debug
|
2016-09-26 11:00:41 +02:00
|
|
|
save ep_test_1.mat endo_simul exo_simul
|
2016-03-05 15:55:22 +01:00
|
|
|
end
|
2016-04-29 23:23:07 +02:00
|
|
|
|
2016-03-05 15:55:22 +01:00
|
|
|
if bytecode_flag && ~ep.stochastic.order
|
2016-05-03 15:50:02 +02:00
|
|
|
[flag, tmp] = bytecode('dynamic', endo_simul, exo_simul, M_.params, endo_simul, periods);
|
2016-03-05 15:55:22 +01:00
|
|
|
else
|
2016-05-03 15:50:02 +02:00
|
|
|
flag = true;
|
2016-03-05 15:55:22 +01:00
|
|
|
end
|
2016-04-29 23:23:07 +02:00
|
|
|
|
2016-03-05 15:55:22 +01:00
|
|
|
if flag
|
|
|
|
if order == 0
|
|
|
|
options.periods = periods;
|
|
|
|
options.block = pfm.block;
|
|
|
|
oo.endo_simul = endo_simul;
|
|
|
|
oo.exo_simul = exo_simul;
|
|
|
|
oo.steady_state = steady_state;
|
|
|
|
options.bytecode = bytecode_flag;
|
|
|
|
options.lmmcp = olmmcp;
|
|
|
|
options.solve_algo = solve_algo;
|
|
|
|
options.stack_solve_algo = stack_solve_algo;
|
2016-05-31 12:09:23 +02:00
|
|
|
tmp = perfect_foresight_solver_core(M, options, oo);
|
2017-05-16 15:10:20 +02:00
|
|
|
if ~tmp.deterministic_simulation.status
|
2016-05-04 14:33:49 +02:00
|
|
|
info_convergence = false;
|
2016-04-19 11:34:49 +02:00
|
|
|
else
|
2016-05-04 14:33:49 +02:00
|
|
|
info_convergence = true;
|
2016-04-19 11:34:49 +02:00
|
|
|
end
|
2016-03-05 15:55:22 +01:00
|
|
|
else
|
|
|
|
switch(algo)
|
|
|
|
case 0
|
2016-05-04 14:33:49 +02:00
|
|
|
[flag, tmp.endo_simul] = ...
|
2016-05-03 15:50:02 +02:00
|
|
|
solve_stochastic_perfect_foresight_model(endo_simul, exo_simul, pfm, ep.stochastic.quadrature.nodes, ep.stochastic.order);
|
2016-03-05 15:55:22 +01:00
|
|
|
case 1
|
2016-05-04 14:33:49 +02:00
|
|
|
[flag, tmp.endo_simul] = ...
|
2016-05-03 15:50:02 +02:00
|
|
|
solve_stochastic_perfect_foresight_model_1(endo_simul, exo_simul, options, pfm, ep.stochastic.order);
|
2016-03-05 15:55:22 +01:00
|
|
|
end
|
|
|
|
info_convergence = ~flag;
|
|
|
|
end
|
|
|
|
end
|
2016-05-03 15:50:02 +02:00
|
|
|
|
2016-05-04 14:33:49 +02:00
|
|
|
if ~info_convergence && ~options.no_homotopy
|
|
|
|
[info_convergence, tmp.endo_simul] = extended_path_homotopy(endo_simul, exo_simul, M, options, oo, pfm, ep, order, algo, 2, debug);
|
|
|
|
end
|
|
|
|
|
2016-03-05 15:55:22 +01:00
|
|
|
if info_convergence
|
|
|
|
y = tmp.endo_simul(:,2);
|
|
|
|
else
|
|
|
|
y = NaN(size(endo_nbr,1));
|
|
|
|
end
|
2016-05-04 14:33:49 +02:00
|
|
|
|
|
|
|
endogenousvariablespaths = tmp.endo_simul;
|