fix calls to dynare_solve() when Jacobian of function must be computed

numerically. Fix call to dynare_solve() in simulation_core()
time-shift
Michel Juillard 2015-05-26 15:50:55 +02:00
parent 025e7a13c3
commit 1b822a9105
4 changed files with 16 additions and 6 deletions

View File

@ -53,8 +53,12 @@ elseif options_.steadystate_flag
%solve for instrument, using univariate solver, starting at initial value for instrument %solve for instrument, using univariate solver, starting at initial value for instrument
inst_val = csolve(nl_func,ys_init(k_inst),'',options_.solve_tolf,100); inst_val = csolve(nl_func,ys_init(k_inst),'',options_.solve_tolf,100);
else else
%solve for instrument, using multivariate solver, starting at initial value for instrument %solve for instrument, using multivariate solver, starting at
[inst_val,info1] = dynare_solve(nl_func,ys_init(k_inst),options_); %initial value for instrument
opt = options_;
opt.jacobian_flag = 0;
[inst_val,info1] = dynare_solve(nl_func,ys_init(k_inst), ...
opt);
end end
ys_init(k_inst) = inst_val; ys_init(k_inst) = inst_val;
exo_ss = [oo.exo_steady_state oo.exo_det_steady_state]; exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
@ -63,7 +67,9 @@ elseif options_.steadystate_flag
else else
n_var = M.orig_endo_nbr; n_var = M.orig_endo_nbr;
xx = oo.steady_state(1:n_var); xx = oo.steady_state(1:n_var);
[xx,check] = dynare_solve(nl_func,xx,options_); opt = options_;
opt.jacobian_flag = 0;
[xx,check] = dynare_solve(nl_func,xx,opt);
[junk,junk,steady_state] = nl_func(xx); [junk,junk,steady_state] = nl_func(xx);
end end

View File

@ -89,7 +89,9 @@ else
% nonlinear models % nonlinear models
if max(abs(feval(fh,dr.ys,[oo_.exo_steady_state; ... if max(abs(feval(fh,dr.ys,[oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params))) > options_.dynatol.f oo_.exo_det_steady_state], M_.params))) > options_.dynatol.f
[dr.ys,check1] = dynare_solve(fh,dr.ys,options_,... opt = options_;
opt.jacobian_flag = 0;
[dr.ys,check1] = dynare_solve(fh,dr.ys,opt,...
[oo_.exo_steady_state; ... [oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params); oo_.exo_det_steady_state], M_.params);
end end

View File

@ -87,7 +87,9 @@ if options_.ramsey_policy && options_.ACES_solver == 0
end end
old_solve_algo = options_.solve_algo; old_solve_algo = options_.solve_algo;
% options_.solve_algo = 1; % options_.solve_algo = 1;
oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,options_,M_,options_,oo_,it_); opt = options_;
opt.jacobian_flag = 0;
oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_);
options_.solve_algo = old_solve_algo; options_.solve_algo = old_solve_algo;
[junk,junk,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_); [junk,junk,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
[jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_); [jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);

View File

@ -79,7 +79,7 @@ else
illi = illi(:,2:3); illi = illi(:,2:3);
[i_cols_J1,junk,i_cols_1] = find(illi(:)); [i_cols_J1,junk,i_cols_1] = find(illi(:));
i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
[y,info] = dynare_solve(@perfect_foresight_problem,z(:),1, ... [y,info] = dynare_solve(@perfect_foresight_problem,z(:),options_, ...
str2func([M_.fname '_dynamic']),y0,yT, ... str2func([M_.fname '_dynamic']),y0,yT, ...
oo_.exo_simul,M_.params,oo_.steady_state, ... oo_.exo_simul,M_.params,oo_.steady_state, ...
options_.periods,M_.endo_nbr,i_cols, ... options_.periods,M_.endo_nbr,i_cols, ...