Fixed several bugs in OW-LQN.

git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@29 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc
This commit is contained in:
naoaki 2009-02-16 04:02:24 +00:00
parent 1cb0436e32
commit fb183a2880

View File

@ -663,10 +663,11 @@ static int line_search_backtracking_owlqn(
} }
for (;;) { for (;;) {
// Update the current point.
veccpy(x, xp, n); veccpy(x, xp, n);
vecadd(x, s, *stp, 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); owlqn_project(x, wp, param->orthantwise_start, param->orthantwise_end);
/* Evaluate the function and gradient values. */ /* Evaluate the function and gradient values. */
@ -680,18 +681,23 @@ static int line_search_backtracking_owlqn(
dgtest = 0.; dgtest = 0.;
for (i = 0;i < n;++i) { 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) { if (*f <= finit + param->ftol * dgtest) {
/* The sufficient decrease condition. */ /* The sufficient decrease condition. */
return count; return count;
} }
if (*stp < param->min_step) { if (*stp < param->min_step) {
/* The step is the minimum value. */ /* The step is the minimum value. */
ret = LBFGSERR_MINIMUMSTEP; ret = LBFGSERR_MINIMUMSTEP;
break; break;
} }
if (*stp > param->max_step) {
/* The step is the maximum value. */
return LBFGSERR_MAXIMUMSTEP;
}
if (param->max_linesearch <= count) { if (param->max_linesearch <= count) {
/* Maximum number of iteration. */ /* Maximum number of iteration. */
ret = LBFGSERR_MAXIMUMLINESEARCH; ret = LBFGSERR_MAXIMUMLINESEARCH;
@ -776,6 +782,10 @@ static int line_search_backtracking_loose(
ret = LBFGSERR_MINIMUMSTEP; ret = LBFGSERR_MINIMUMSTEP;
break; break;
} }
if (*stp > param->max_step) {
/* The step is the maximum value. */
return LBFGSERR_MAXIMUMSTEP;
}
if (param->max_linesearch <= count) { if (param->max_linesearch <= count) {
/* Maximum number of iteration. */ /* Maximum number of iteration. */
ret = LBFGSERR_MAXIMUMLINESEARCH; ret = LBFGSERR_MAXIMUMLINESEARCH;
@ -874,6 +884,10 @@ static int line_search_backtracking_strong_wolfe(
ret = LBFGSERR_MINIMUMSTEP; ret = LBFGSERR_MINIMUMSTEP;
break; break;
} }
if (*stp > param->max_step) {
/* The step is the maximum value. */
return LBFGSERR_MAXIMUMSTEP;
}
if (param->max_linesearch <= count) { if (param->max_linesearch <= count) {
/* Maximum number of iteration. */ /* Maximum number of iteration. */
ret = LBFGSERR_MAXIMUMLINESEARCH; ret = LBFGSERR_MAXIMUMLINESEARCH;