Merge pull request #1104 from JohannesPfeifer/solve_algo_0
Only accept steady state when fsolve retuns with normal return code 1time-shift
commit
8f1eb47a5e
|
@ -113,8 +113,16 @@ if options.solve_algo == 0
|
|||
end;
|
||||
end
|
||||
|
||||
if exitval > 0
|
||||
if exitval == 1
|
||||
info = 0;
|
||||
elseif exitval > 1
|
||||
M=evalin('base','M_'); %get variable names from workspace
|
||||
resid = evaluate_static_model(x,varargin{:},M,options);
|
||||
if max(abs(resid)) > 1e-6
|
||||
info = 1;
|
||||
else
|
||||
info = 0;
|
||||
end
|
||||
else
|
||||
info = 1;
|
||||
end
|
||||
|
|
|
@ -118,7 +118,13 @@ for its = 1:maxit
|
|||
if check > 0
|
||||
den = max([f;0.5*nn]) ;
|
||||
if max(abs(g).*max([abs(x(j2)') ones(1,nn)])')/den < tolmin
|
||||
return
|
||||
if max(abs(x(j2)-xold(j2))./max([abs(x(j2)') ones(1,nn)])') < tolx
|
||||
disp (' ')
|
||||
disp (['SOLVE: Iteration ' num2str(its)])
|
||||
disp (['Convergence on dX.'])
|
||||
disp (x)
|
||||
return
|
||||
end
|
||||
else
|
||||
disp (' ')
|
||||
disp (['SOLVE: Iteration ' num2str(its)])
|
||||
|
@ -127,13 +133,6 @@ for its = 1:maxit
|
|||
return
|
||||
end
|
||||
|
||||
if max(abs(x(j2)-xold(j2))./max([abs(x(j2)') ones(1,nn)])') < tolx
|
||||
disp (' ')
|
||||
disp (['SOLVE: Iteration ' num2str(its)])
|
||||
disp (['Convergence on dX.'])
|
||||
disp (x)
|
||||
return
|
||||
end
|
||||
elseif max(abs(fvec)) < tolf
|
||||
return
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function [x,check] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tolx,maxiter,debug,varargin)
|
||||
function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tolx,maxiter,debug,varargin)
|
||||
% Solves systems of non linear equations of several variables, using a
|
||||
% trust-region method.
|
||||
%
|
||||
|
@ -20,12 +20,12 @@ function [x,check] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tolx,max
|
|||
% OUTPUTS
|
||||
% x: results
|
||||
% check=1: the model can not be solved
|
||||
%
|
||||
% info: detailed exitcode
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2008-2012 VZLU Prague, a.s.
|
||||
% Copyright (C) 2014 Dynare Team
|
||||
% Copyright (C) 2016 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -82,7 +82,6 @@ while (niter < maxiter && ~info)
|
|||
xdh(j2(j)) = xdh(j2(j))+dh(j) ;
|
||||
t = fcn(xdh,varargin{:});
|
||||
fjac(:,j) = (t(j1) - fvec)./dh(j) ;
|
||||
g(j) = fvec'*fjac(:,j) ;
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue