Merge remote-tracking branch 'rattoma/deterministic'
commit
b5262ca1e8
|
@ -165,6 +165,11 @@ for iter = 1:options.simul.maxit
|
||||||
dy = -lin_solve( A, res, verbose );
|
dy = -lin_solve( A, res, verbose );
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if (any(~isreal(dy)) || any(isnan(dy)) || any(isinf(dy)) ,
|
||||||
|
if verbose
|
||||||
|
display_critical_variables(reshape(dy,[ny periods])', M);
|
||||||
|
end
|
||||||
|
end
|
||||||
Y(i_upd) = Y(i_upd) + dy;
|
Y(i_upd) = Y(i_upd) + dy;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -184,33 +189,12 @@ if stop
|
||||||
if verbose
|
if verbose
|
||||||
skipline()
|
skipline()
|
||||||
disp(sprintf('Total time of simulation: %s.', num2str(etime(clock,h1))))
|
disp(sprintf('Total time of simulation: %s.', num2str(etime(clock,h1))))
|
||||||
dyy=reshape(dy,[size(endogenousvariables,1) periods])';
|
|
||||||
if ~isreal(res) || ~isreal(Y)
|
if ~isreal(res) || ~isreal(Y)
|
||||||
disp('Simulation terminated with imaginary parts in the residuals or endogenous variables.')
|
disp('Simulation terminated with imaginary parts in the residuals or endogenous variables.')
|
||||||
if any(~isreal(dy))
|
|
||||||
indx = find(any(~isreal(dyy)));
|
|
||||||
endo_names=cellstr(M.endo_names(indx,:));
|
|
||||||
disp('Newton algorithm provided complex number for variables:')
|
|
||||||
fprintf('%s, ', endo_names{:});
|
|
||||||
skipline()
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
disp('Simulation terminated with NaN or Inf in the residuals or endogenous variables.')
|
disp('Simulation terminated with NaN or Inf in the residuals or endogenous variables.')
|
||||||
if any(isnan(dy))
|
|
||||||
indx = find(any(isnan(dyy)));
|
|
||||||
endo_names=cellstr(M.endo_names(indx,:));
|
|
||||||
disp('Newton algorithm provided NaN for variables:')
|
|
||||||
fprintf('%s, ',endo_names{:});
|
|
||||||
skipline()
|
|
||||||
end
|
|
||||||
if any(isinf(dy))
|
|
||||||
indx = find(any(isinf(dyy)));
|
|
||||||
endo_names=cellstr(M.endo_names(indx,:));
|
|
||||||
disp('Newton algorithm diverged (Inf) for variables:')
|
|
||||||
fprintf('%s, ',endo_names{:});
|
|
||||||
skipline()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
display_critical_variables(reshape(dy,[ny periods])', M);
|
||||||
disp('There is most likely something wrong with your model. Try model_diagnostics or another simulation method.')
|
disp('There is most likely something wrong with your model. Try model_diagnostics or another simulation method.')
|
||||||
printline(105)
|
printline(105)
|
||||||
end
|
end
|
||||||
|
@ -323,3 +307,29 @@ function [ x, flag, relres ] = lin_solve_robust( A, b , verbose)
|
||||||
if flag ~= 0 && verbose
|
if flag ~= 0 && verbose
|
||||||
fprintf( 'WARNING : Failed to find a solution to the linear system\n' );
|
fprintf( 'WARNING : Failed to find a solution to the linear system\n' );
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function display_critical_variables(dyy, M)
|
||||||
|
|
||||||
|
if any(isnan(dyy))
|
||||||
|
indx = find(any(isnan(dyy)));
|
||||||
|
endo_names=cellstr(M.endo_names(indx,:));
|
||||||
|
disp('Last iteration provided NaN for the following variables:')
|
||||||
|
fprintf('%s, ',endo_names{:}),
|
||||||
|
fprintf('\n'),
|
||||||
|
end
|
||||||
|
if any(isinf(dyy))
|
||||||
|
indx = find(any(isinf(dyy)));
|
||||||
|
endo_names=cellstr(M.endo_names(indx,:));
|
||||||
|
disp('Last iteration diverged (Inf) for the following variables:')
|
||||||
|
fprintf('%s, ',endo_names{:}),
|
||||||
|
fprintf('\n'),
|
||||||
|
end
|
||||||
|
if any(~isreal(dyy))
|
||||||
|
indx = find(any(~isreal(dyy)));
|
||||||
|
endo_names=cellstr(M.endo_names(indx,:));
|
||||||
|
disp('Last iteration provided complex number for the following variables:')
|
||||||
|
fprintf('%s, ',endo_names{:}),
|
||||||
|
fprintf('\n'),
|
||||||
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue