diff scripts/optimization/fminunc.m @ 9633:ecc2c556f844

simplify damped BFGS formula
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 11 Sep 2009 08:47:25 +0200
parents 00958d0c4e3c
children 09da0bd91412
line wrap: on
line diff
--- a/scripts/optimization/fminunc.m	Wed Sep 09 19:41:29 2009 -0400
+++ b/scripts/optimization/fminunc.m	Fri Sep 11 08:47:25 2009 +0200
@@ -170,11 +170,7 @@
       sBs = sumsq (w);
       Bs = hesr'*w;
       sy = y'*s;
-      if (sy >= 0.2*sBs)
-        theta = 1;
-      else
-        theta = 0.8*sBs / (sBs - sy);
-      endif
+      theta = 0.8 / max (1 - sy / sBs, 0.8);
       r = theta * y + (1-theta) * Bs;
       hesr = cholupdate (hesr, r / sqrt (s'*r), "+");
       [hesr, info] = cholupdate (hesr, Bs / sqrt (sBs), "-");