From fb183a2880c50820eecd9ec61377a8e7ac114eae Mon Sep 17 00:00:00 2001 From: naoaki Date: Mon, 16 Feb 2009 04:02:24 +0000 Subject: [PATCH] Fixed several bugs in OW-LQN. git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@29 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc --- lib/lbfgs.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/lbfgs.c b/lib/lbfgs.c index d463ca9..c668a38 100644 --- a/lib/lbfgs.c +++ b/lib/lbfgs.c @@ -663,10 +663,11 @@ static int line_search_backtracking_owlqn( } for (;;) { + // Update the current point. veccpy(x, xp, n); vecadd(x, s, *stp, n); - /* The current point is projected onto the orthant of the initial one. */ + /* The current point is projected onto the orthant. */ owlqn_project(x, wp, param->orthantwise_start, param->orthantwise_end); /* Evaluate the function and gradient values. */ @@ -680,18 +681,23 @@ static int line_search_backtracking_owlqn( dgtest = 0.; for (i = 0;i < n;++i) { - dgtest += (x[i] - xp[i]) * g[i]; + dgtest += (x[i] - xp[i]) * gp[i]; } if (*f <= finit + param->ftol * dgtest) { /* The sufficient decrease condition. */ return count; } + if (*stp < param->min_step) { /* The step is the minimum value. */ ret = LBFGSERR_MINIMUMSTEP; break; } + if (*stp > param->max_step) { + /* The step is the maximum value. */ + return LBFGSERR_MAXIMUMSTEP; + } if (param->max_linesearch <= count) { /* Maximum number of iteration. */ ret = LBFGSERR_MAXIMUMLINESEARCH; @@ -776,6 +782,10 @@ static int line_search_backtracking_loose( ret = LBFGSERR_MINIMUMSTEP; break; } + if (*stp > param->max_step) { + /* The step is the maximum value. */ + return LBFGSERR_MAXIMUMSTEP; + } if (param->max_linesearch <= count) { /* Maximum number of iteration. */ ret = LBFGSERR_MAXIMUMLINESEARCH; @@ -874,6 +884,10 @@ static int line_search_backtracking_strong_wolfe( ret = LBFGSERR_MINIMUMSTEP; break; } + if (*stp > param->max_step) { + /* The step is the maximum value. */ + return LBFGSERR_MAXIMUMSTEP; + } if (param->max_linesearch <= count) { /* Maximum number of iteration. */ ret = LBFGSERR_MAXIMUMLINESEARCH;