Ramsey: exit with error code if solver fails at specified tolerance
Also adds penalty if steady state ventures into complex spacetime-shift
parent
c470e028e1
commit
eff52f51b7
|
@ -55,7 +55,13 @@ elseif options_.steadystate_flag
|
||||||
end
|
end
|
||||||
if inst_nbr == 1
|
if inst_nbr == 1
|
||||||
%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, info1]= csolve(nl_func,ys_init(k_inst),'',options_.solve_tolf,options_.ramsey.maxit);
|
||||||
|
if info1==1 || info1==3
|
||||||
|
check=81;
|
||||||
|
end
|
||||||
|
if info1==4
|
||||||
|
check=87;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
%solve for instrument, using multivariate solver, starting at
|
%solve for instrument, using multivariate solver, starting at
|
||||||
%initial value for instrument
|
%initial value for instrument
|
||||||
|
@ -63,10 +69,13 @@ elseif options_.steadystate_flag
|
||||||
opt.jacobian_flag = 0;
|
opt.jacobian_flag = 0;
|
||||||
[inst_val,info1] = dynare_solve(nl_func,ys_init(k_inst), ...
|
[inst_val,info1] = dynare_solve(nl_func,ys_init(k_inst), ...
|
||||||
opt);
|
opt);
|
||||||
|
if info1~=0
|
||||||
|
check=81;
|
||||||
|
end
|
||||||
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];
|
||||||
[xx,params,check] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
|
[xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
|
||||||
[junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state
|
[junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state
|
||||||
else
|
else
|
||||||
n_var = M.orig_endo_nbr;
|
n_var = M.orig_endo_nbr;
|
||||||
|
@ -110,6 +119,12 @@ if options_.steadystate_flag
|
||||||
[oo.exo_steady_state; ...
|
[oo.exo_steady_state; ...
|
||||||
oo.exo_det_steady_state], ...
|
oo.exo_det_steady_state], ...
|
||||||
M,options_,~options_.steadystate.nocheck);
|
M,options_,~options_.steadystate.nocheck);
|
||||||
|
if any(imag(x(1:M.orig_endo_nbr))) %return with penalty
|
||||||
|
resids=1+sum(abs(imag(x(1:M.orig_endo_nbr)))); %return with penalty
|
||||||
|
steady_state=NaN(endo_nbr,1);
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
xx = zeros(endo_nbr,1); %initialize steady state vector
|
xx = zeros(endo_nbr,1); %initialize steady state vector
|
||||||
|
|
|
@ -145,7 +145,6 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
|
||||||
%either if no steady state file or steady state file without problems
|
%either if no steady state file or steady state file without problems
|
||||||
[ys,params,info] = dyn_ramsey_static(ys_init,M,options,oo);
|
[ys,params,info] = dyn_ramsey_static(ys_init,M,options,oo);
|
||||||
if info
|
if info
|
||||||
info=81;%case should not happen
|
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
%check whether steady state really solves the model
|
%check whether steady state really solves the model
|
||||||
|
|
|
@ -148,6 +148,10 @@ if ~noprint
|
||||||
error(['Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial values of the instruments']);
|
error(['Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial values of the instruments']);
|
||||||
case 85
|
case 85
|
||||||
error(['Ramsey: The steady state file does not solve the static first order conditions conditional on the instruments.']);
|
error(['Ramsey: The steady state file does not solve the static first order conditions conditional on the instruments.']);
|
||||||
|
case 86
|
||||||
|
error(['Ramsey: The steady state file provides complex numbers conditional on the instruments.']);
|
||||||
|
case 87
|
||||||
|
error(['Ramsey: The maximum number of iterations has been reached. Try increasing maxit.']);
|
||||||
case 102
|
case 102
|
||||||
error('Aim: roots not correctly computed by real_schur');
|
error('Aim: roots not correctly computed by real_schur');
|
||||||
case 103
|
case 103
|
||||||
|
|
Loading…
Reference in New Issue