Merge pull request #458 from JohannesPfeifer/stoch_solver_debug
Filter out Inf in Jacobian to get rid of most cryptic errors about Lapack function dggestime-shift
commit
c1def96019
|
@ -64,7 +64,9 @@ if ~noprint
|
|||
error(['The Jacobian contains NaNs'])
|
||||
end
|
||||
case 9
|
||||
error(['k_order_pert was unable to compute the solution'])
|
||||
error(['k_order_pert was unable to compute the solution'])
|
||||
case 10
|
||||
error(['The Jacobian or the dynamic model contains Inf. For more information, use options_.debug.'])
|
||||
case 19
|
||||
error('The steadystate file did not compute the steady state')
|
||||
case 20
|
||||
|
|
|
@ -106,10 +106,38 @@ elseif options_.order == 2
|
|||
end
|
||||
end
|
||||
|
||||
[infrow,infcol]=find(isinf(jacobia_));
|
||||
|
||||
if options_.debug
|
||||
if ~isempty(infrow)
|
||||
for ii=1:length(infrow)
|
||||
[var_row,var_index]=find(M_.lead_lag_incidence==infcol(ii));
|
||||
if var_row==2
|
||||
type_string='';
|
||||
elseif var_row==1
|
||||
type_string='lag of';
|
||||
elseif var_row==3;
|
||||
type_string='lead of';
|
||||
end
|
||||
if var_index<=M_.orig_endo_nbr
|
||||
fprintf('STOCHASTIC_SOLVER: Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n',infrow(ii),type_string,deblank(M_.endo_names(var_index,:)),deblank(M_.endo_names(var_index,:)),dr.ys(var_index))
|
||||
else %auxiliary vars
|
||||
orig_var_index=M.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
|
||||
fprintf('STOCHASTIC_SOLVER: Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n',infrow(ii),type_string,deblank(M_.endo_names(orig_var_index,:)),deblank(M_.endo_names(orig_var_index,:)),dr.ys(orig_var_index))
|
||||
end
|
||||
end
|
||||
fprintf('\nSTOCHASTIC_SOLVER: The problem most often occurs, because a variable with\n')
|
||||
fprintf('STOCHASTIC_SOLVER: exponent smaller than 1 has been initialized to 0. Taking the derivative\n')
|
||||
fprintf('STOCHASTIC_SOLVER: and evaluating it at the steady state then results in a division by 0.\n')
|
||||
end
|
||||
save([M_.fname '_debug.mat'],'jacobia_')
|
||||
end
|
||||
|
||||
if ~isempty(infrow)
|
||||
info(1)=10;
|
||||
return
|
||||
end
|
||||
|
||||
if ~isreal(jacobia_)
|
||||
if max(max(abs(imag(jacobia_)))) < 1e-15
|
||||
jacobia_ = real(jacobia_);
|
||||
|
|
Loading…
Reference in New Issue