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;
|
||||||
end
|
end
|
||||||
|
|
||||||
if exitval > 0
|
if exitval == 1
|
||||||
info = 0;
|
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
|
else
|
||||||
info = 1;
|
info = 1;
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,7 +118,13 @@ for its = 1:maxit
|
||||||
if check > 0
|
if check > 0
|
||||||
den = max([f;0.5*nn]) ;
|
den = max([f;0.5*nn]) ;
|
||||||
if max(abs(g).*max([abs(x(j2)') ones(1,nn)])')/den < tolmin
|
if max(abs(g).*max([abs(x(j2)') ones(1,nn)])')/den < tolmin
|
||||||
|
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
|
return
|
||||||
|
end
|
||||||
else
|
else
|
||||||
disp (' ')
|
disp (' ')
|
||||||
disp (['SOLVE: Iteration ' num2str(its)])
|
disp (['SOLVE: Iteration ' num2str(its)])
|
||||||
|
@ -127,13 +133,6 @@ for its = 1:maxit
|
||||||
return
|
return
|
||||||
end
|
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
|
elseif max(abs(fvec)) < tolf
|
||||||
return
|
return
|
||||||
end
|
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
|
% Solves systems of non linear equations of several variables, using a
|
||||||
% trust-region method.
|
% trust-region method.
|
||||||
%
|
%
|
||||||
|
@ -20,12 +20,12 @@ function [x,check] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tolx,max
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% x: results
|
% x: results
|
||||||
% check=1: the model can not be solved
|
% check=1: the model can not be solved
|
||||||
%
|
% info: detailed exitcode
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
|
||||||
% Copyright (C) 2008-2012 VZLU Prague, a.s.
|
% Copyright (C) 2008-2012 VZLU Prague, a.s.
|
||||||
% Copyright (C) 2014 Dynare Team
|
% Copyright (C) 2016 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -82,7 +82,6 @@ while (niter < maxiter && ~info)
|
||||||
xdh(j2(j)) = xdh(j2(j))+dh(j) ;
|
xdh(j2(j)) = xdh(j2(j))+dh(j) ;
|
||||||
t = fcn(xdh,varargin{:});
|
t = fcn(xdh,varargin{:});
|
||||||
fjac(:,j) = (t(j1) - fvec)./dh(j) ;
|
fjac(:,j) = (t(j1) - fvec)./dh(j) ;
|
||||||
g(j) = fvec'*fjac(:,j) ;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue