Skip to content
Snippets Groups Projects
Commit 02e94962 authored by michel's avatar michel
Browse files

4.0: merged r2307, r2308 changeset from trunk (mr_hessian.m: refined search;...

4.0: merged r2307, r2308 changeset from trunk (mr_hessian.m: refined search; newrat.m: help and messages)

git-svn-id: https://www.dynare.org/svn/dynare/branches/4.0@2485 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 8fc0409a
No related branches found
Tags
No related merge requests found
...@@ -50,12 +50,16 @@ func = str2func(func); ...@@ -50,12 +50,16 @@ func = str2func(func);
[f0, ff0]=feval(func,x,varargin{:}); [f0, ff0]=feval(func,x,varargin{:});
n=size(x,1); n=size(x,1);
h2=bayestopt_.ub-bayestopt_.lb; 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),gstep_*ones(n,1))*eps^(1/3);
%h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/6); %h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/6);
if isempty(h1), if isempty(h1),
h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/4); h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/4);
end end
h1 = min(h1,0.5.*hmax);
if htol0<htol, if htol0<htol,
htol=htol0; htol=htol0;
end end
...@@ -103,6 +107,7 @@ while i<n, ...@@ -103,6 +107,7 @@ while i<n,
else else
h1(i)=2.1*h1(i); h1(i)=2.1*h1(i);
end end
h1(i) = min(h1(i),0.5*hmax(i));
xh1(i)=x(i)+h1(i); xh1(i)=x(i)+h1(i);
% c=mr_nlincon(xh1,varargin{:}); % c=mr_nlincon(xh1,varargin{:});
% while c % while c
...@@ -127,7 +132,7 @@ while i<n, ...@@ -127,7 +132,7 @@ while i<n,
it=it+1; it=it+1;
dx(it)=(fx-f0); dx(it)=(fx-f0);
h0(it)=h1(i); 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; ic=1;
hcheck=1; hcheck=1;
end end
......
function [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin) 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) % [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 % uses Chris Sims subroutine for line search
% %
% func0 = name of the function % func0 = name of the function
...@@ -125,9 +125,9 @@ while norm(gg)>gtol & check==0 & jit<nit, ...@@ -125,9 +125,9 @@ while norm(gg)>gtol & check==0 & jit<nit,
nig=[nig ig]; nig=[nig ig];
if (fval-fvala)<gibbstol*(fval0(icount)-fval), if (fval-fvala)<gibbstol*(fval0(icount)-fval),
igibbs=0; igibbs=0;
disp('Last Gibbs step, gain too small!!') disp('Last sequence of univariate step, gain too small!!')
else else
disp('Gibbs step!!') disp('Sequence of univariate steps!!')
end end
fval=fvala; fval=fvala;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment