Commit d2b3beb3 authored by ratto's avatar ratto
Browse files

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

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
parent 0ed63ac0
......@@ -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(:);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment