Commit a6395a76 authored by Davis King's avatar Davis King

More robustness improvements to line_search(). Mostly just parameter tweaks.

parent e03fea5e
...@@ -306,8 +306,9 @@ namespace dlib ...@@ -306,8 +306,9 @@ namespace dlib
// the book Practical Methods of Optimization by R. Fletcher. The sectioning // the book Practical Methods of Optimization by R. Fletcher. The sectioning
// phase is an implementation of 2.6.4 from the same book. // phase is an implementation of 2.6.4 from the same book.
// 1 < tau1a < tau1b. Controls the alpha jump size during the search // 1 <= tau1a < tau1b. Controls the alpha jump size during the bracketing phase of
const double tau1a = 2.0; // the search.
const double tau1a = 1.4;
const double tau1b = 9; const double tau1b = 9;
// it must be the case that 0 < tau2 < tau3 <= 1/2 for the algorithm to function // it must be the case that 0 < tau2 < tau3 <= 1/2 for the algorithm to function
...@@ -317,7 +318,7 @@ namespace dlib ...@@ -317,7 +318,7 @@ namespace dlib
// Stop right away and return a step size of 0 if the gradient is 0 at the starting point // Stop right away and return a step size of 0 if the gradient is 0 at the starting point
if (std::abs(d0) < std::numeric_limits<double>::epsilon()) if (std::abs(d0) <= std::abs(f0)*std::numeric_limits<double>::epsilon())
return 0; return 0;
// Stop right away if the current value is good enough according to min_f // Stop right away if the current value is good enough according to min_f
...@@ -397,12 +398,18 @@ namespace dlib ...@@ -397,12 +398,18 @@ namespace dlib
const double temp = alpha; const double temp = alpha;
// Pick a larger range [first, last]. We will pick the next alpha in that // Pick a larger range [first, last]. We will pick the next alpha in that
// range. // range.
double first = alpha + tau1a*(alpha - last_alpha); double first, last;
double last;
if (mu > 0) if (mu > 0)
last = std::min(mu, alpha + tau1b*(alpha - last_alpha)); {
first = std::min(mu, alpha + tau1a*(alpha - last_alpha));
last = std::min(mu, alpha + tau1b*(alpha - last_alpha));
}
else else
last = std::max(mu, alpha + tau1b*(alpha - last_alpha)); {
first = std::max(mu, alpha + tau1a*(alpha - last_alpha));
last = std::max(mu, alpha + tau1b*(alpha - last_alpha));
}
// pick a point between first and last by doing some kind of interpolation // pick a point between first and last by doing some kind of interpolation
...@@ -462,7 +469,7 @@ namespace dlib ...@@ -462,7 +469,7 @@ namespace dlib
// looks like the first derivative is discontinuous and stop if so. The // looks like the first derivative is discontinuous and stop if so. The
// current alpha is plenty good enough in this case. // current alpha is plenty good enough in this case.
const double second_der = std::abs(a_val_der-b_val_der)/std::abs(a-b); const double second_der = std::abs(a_val_der-b_val_der)/std::abs(a-b);
if (second_der > 1e5) if (std::abs(a-b) < 1e-8 && second_der > 1e7)
return alpha; return alpha;
if ( (b-a)*val_der >= 0) if ( (b-a)*val_der >= 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment