diff --git a/matlab/mr_hessian.m b/matlab/mr_hessian.m index 14e7a59906c97282b34a192ff54fccd486a35d62..9f56e6d75f350e662495cdaa74d00def151358a1 100644 --- a/matlab/mr_hessian.m +++ b/matlab/mr_hessian.m @@ -50,12 +50,16 @@ func = str2func(func); [f0, ff0]=feval(func,x,varargin{:}); n=size(x,1); h2=bayestopt_.ub-bayestopt_.lb; +hmax=bayestopt_.ub-x; +hmax=min(hmax,x-bayestopt_.lb); %h1=max(abs(x),gstep_*ones(n,1))*eps^(1/3); %h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/6); if isempty(h1), h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/4); end +h1 = min(h1,0.5.*hmax); + if htol0<htol, htol=htol0; end @@ -103,6 +107,7 @@ while i<n, else h1(i)=2.1*h1(i); end + h1(i) = min(h1(i),0.5*hmax(i)); xh1(i)=x(i)+h1(i); % c=mr_nlincon(xh1,varargin{:}); % while c @@ -127,7 +132,7 @@ while i<n, it=it+1; dx(it)=(fx-f0); h0(it)=h1(i); - if h1(i)<1.e-12*min(1,h2(i)), + if h1(i)<1.e-12*min(1,h2(i)) & h1(i)<0.5*hmax(i), ic=1; hcheck=1; end diff --git a/matlab/newrat.m b/matlab/newrat.m index 7e84595f013b1555f2ec784628f74f55a0973037..87d353bfb4858fef7c662eecde9938f9bfca7549 100644 --- a/matlab/newrat.m +++ b/matlab/newrat.m @@ -1,7 +1,7 @@ function [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin) % [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin) % -% Optimiser with outer product gradient and 'Gibbs type' steps +% Optimiser with outer product gradient and with sequences of univariate steps % uses Chris Sims subroutine for line search % % func0 = name of the function @@ -125,9 +125,9 @@ while norm(gg)>gtol & check==0 & jit<nit, nig=[nig ig]; if (fval-fvala)<gibbstol*(fval0(icount)-fval), igibbs=0; - disp('Last Gibbs step, gain too small!!') + disp('Last sequence of univariate step, gain too small!!') else - disp('Gibbs step!!') + disp('Sequence of univariate steps!!') end fval=fvala; end