Commit 8b4fa7c2 authored by Johannes Pfeifer 's avatar Johannes Pfeifer
Browse files

Factorize call to solver routines under optimal policy and without

Related to #1173
parent b07adee2
......@@ -145,11 +145,7 @@ while fpar<B
end
stock_param(irun2,:) = deep;
set_parameters(deep);
if options_.discretionary_policy
[dr,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_);
else
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
[dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_);
oo_.dr = dr;
if info(1)
nosaddle = nosaddle + 1;
......
function [dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_)
% function [dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_)
% INPUTS
% - M_ [structure] Matlab's structure describing the model (M_).
% - options_ [structure] Matlab's structure describing the current options (options_).
% - oo_ [structure] Matlab's structure containing the results (oo_).
%
% OUTPUTS
% - dr [structure] Reduced form model.
% - info [integer] scalar or vector, error code.
% - M_ [structure] Matlab's structure describing the model (M_).
% - options_ [structure] Matlab's structure describing the current options (options_).
% - oo_ [structure] Matlab's structure containing the results (oo_).
% Copyright (C) 2020 Dynare Team
%
% 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/>.
if options_.discretionary_policy
[dr,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_);
else
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
......@@ -66,11 +66,7 @@ function [A,B,ys,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if DynareOptions.discretionary_policy
[dr,info,Model,DynareOptions,DynareResults] = discretionary_policy_1(DynareOptions.instruments,Model,DynareOptions,DynareResults);
else
[dr,info,Model,DynareOptions,DynareResults] = resol(0,Model,DynareOptions,DynareResults);
end
[dr,info,Model,DynareOptions,DynareResults] =compute_decision_rules(Model,DynareOptions,DynareResults);
if info(1) > 0
A = [];
......
......@@ -203,11 +203,7 @@ for b=fpar:B
M_ = set_all_parameters(deep,estim_params_,M_);
if run_smoother
if options_.discretionary_policy
[dr,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_);
else
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
[dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_);
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ...
DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
......
......@@ -115,11 +115,7 @@ if info
pdraws(i,1) = {x2(SampleAddress(i,4),:)};
if info-1
set_parameters(pdraws{i,1});
if options_.discretionary_policy
[dr,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_);
else
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
[dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_);
pdraws(i,2) = { dr };
end
old_mhfile = mhfile;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment