From 02e94962efe0244ce4725b36f7ed96da4f6b7faa Mon Sep 17 00:00:00 2001
From: michel <michel@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Fri, 20 Mar 2009 10:41:53 +0000
Subject: [PATCH] 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
---
 matlab/mr_hessian.m | 7 ++++++-
 matlab/newrat.m     | 6 +++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/matlab/mr_hessian.m b/matlab/mr_hessian.m
index 14e7a59906..9f56e6d75f 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 7e84595f01..87d353bfb4 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
-- 
GitLab