Fixed bugs highlighted by Junior, occurring when some constraint is violated when computing gradients.

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2857 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
ratto 2009-08-13 06:59:36 +00:00
parent 0ed63ac01a
commit d2b3beb3e7
1 changed files with 11 additions and 3 deletions

View File

@ -165,7 +165,11 @@ while i<n,
% end
% end
f1(:,i)=fx;
ff1=ffx;
if any(isnan(ffx)),
ff1=ones(size(ff0)).*fx/length(ff0);
else
ff1=ffx;
end
if hflag, % two point based derivatives
xh1(i)=x(i)-h1(i);
% c=mr_nlincon(xh1,varargin{:});
@ -178,7 +182,11 @@ while i<n,
% end
[fx, ffx]=feval(func,xh1,varargin{:});
f_1(:,i)=fx;
ff_1=ffx;
if any(isnan(ffx)),
ff_1=ones(size(ff0)).*fx/length(ff0);
else
ff_1=ffx;
end
% if ic,
% xh1(i)=x(i)+h1(i);
% [f1(:,i), ff1]=feval(func,xh1,varargin{:});
@ -307,7 +315,7 @@ if hflag<2,
hessian_mat=hh_mat0(:);
end
if isnan(hessian_mat),
if any(isnan(hessian_mat)),
hh_mat0=eye(length(hh_mat0));
ihh=hh_mat0;
hessian_mat=hh_mat0(:);