diff --git a/lib/lbfgs.c b/lib/lbfgs.c index 1ef0ca7..47ec347 100644 --- a/lib/lbfgs.c +++ b/lib/lbfgs.c @@ -561,6 +561,7 @@ int lbfgs( vecncpy(d, g, n); } else { owlqn_direction(d, x, g, param.orthantwise_c, param.orthantwise_start, param.orthantwise_end); + veccpy(w, d, n); } j = end; @@ -586,6 +587,17 @@ int lbfgs( j = (j + 1) % m; /* if (++j == m) j = 0; */ } + /* + Constrain the search direction for orthant-wise updates. + */ + if (param.orthantwise_c != 0.) { + for (i = param.orthantwise_start;i < param.orthantwise_end;++i) { + if (d[i] * w[i] <= 0) { + d[i] = 0; + } + } + } + /* Now the search direction d is ready. We try step = 1 first. */