Traps for bad x values in optimizer.

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2611 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
ratto 2009-04-20 12:09:44 +00:00
parent f7c97fcebe
commit 38ba90e004
3 changed files with 22 additions and 2 deletions

View File

@ -89,7 +89,11 @@ while i<n,
h1(i)= htol/abs(dx(it))*h1(i);
xh1(i)=x(i)+h1(i);
end
try
fx = feval(func,xh1,varargin{:});
catch
fx=1.e8;
end
it=it+1;
dx(it)=(fx-f0);
h0(it)=h1(i);

View File

@ -77,7 +77,11 @@ while i<n,
hcheck=0;
dx=[];
xh1(i)=x(i)+h1(i);
[fx, ffx]=feval(func,xh1,varargin{:});
try
[fx, ffx]=feval(func,xh1,varargin{:});
catch
fx=1.e8;
end
it=1;
dx=(fx-f0);
ic=0;
@ -116,12 +120,20 @@ while i<n,
% c=mr_nlincon(xh1,varargin{:});
% ic=1;
% end
try
[fx, ffx]=feval(func,xh1,varargin{:});
catch
fx=1.e8;
end
end
if abs(dx(it))>(2*htol),
h1(i)= htol/abs(dx(it))*h1(i);
xh1(i)=x(i)+h1(i);
[fx, ffx]=feval(func,xh1,varargin{:});
try
[fx, ffx]=feval(func,xh1,varargin{:});
catch
fx=1.e8;
end
while (fx-f0)==0,
h1(i)= h1(i)*2;
xh1(i)=x(i)+h1(i);

View File

@ -197,7 +197,11 @@ while norm(gg)>gtol & check==0 & jit<nit,
end
if norm(x(:,icount)-xparam1)>1.e-12,
try
save m1 x fval0 nig -append
catch
save m1 x fval0 nig
end
[dum, gg, htol0, igg, hhg]=mr_hessian(func_hh,xparam1,flagit,htol,varargin{:});
if htol0>htol, %ftol,
%ftol=htol0;