diff --git a/src/Numerics/Optimization/LineSearch/WeakWolfeLineSearch.cs b/src/Numerics/Optimization/LineSearch/WeakWolfeLineSearch.cs
index b7acf184..bf12b146 100644
--- a/src/Numerics/Optimization/LineSearch/WeakWolfeLineSearch.cs
+++ b/src/Numerics/Optimization/LineSearch/WeakWolfeLineSearch.cs
@@ -3,6 +3,19 @@ using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.Optimization.LineSearch
{
+ ///
+ /// Search for a step size alpha that satisfies the weak wolfe conditions. The weak Wolfe
+ /// Conditions are
+ /// i) Armijo Rule: f(x_k + alpha_k p_k) <= f(x_k) + c1 alpha_k p_k^T g(x_k)
+ /// ii) Curvature Condition: p_k^T g(x_k + alpha_k p_k) >= c2 p_k^T g(x_k)
+ /// where g(x) is the gradient of f(x), 0 < c1 < c2 < 1.
+ ///
+ /// Implementation is based on http://www.math.washington.edu/~burke/crs/408/lectures/L9-weak-Wolfe.pdf
+ ///
+ /// references:
+ /// http://en.wikipedia.org/wiki/Wolfe_conditions
+ /// http://www.math.washington.edu/~burke/crs/408/lectures/L9-weak-Wolfe.pdf
+ ///
public class WeakWolfeLineSearch
{
readonly double _c1;
@@ -12,15 +25,27 @@ namespace MathNet.Numerics.Optimization.LineSearch
public WeakWolfeLineSearch(double c1, double c2, double parameterTolerance, int maxIterations = 10)
{
+ if (c1 <= 0)
+ throw new ArgumentException(string.Format("c1 {0} should be greater than 0", c1));
+ if (c2 <= c1)
+ throw new ArgumentException(string.Format("c1 {0} should be less than c2 {1}", c1, c2));
+ if (c2 >= 1)
+ throw new ArgumentException(string.Format("c2 {0} should be less than 1", c2));
+
_c1 = c1;
_c2 = c2;
_parameterTolerance = parameterTolerance;
_maximumIterations = maxIterations;
}
- // Implemented following http://www.math.washington.edu/~burke/crs/408/lectures/L9-weak-Wolfe.pdf
+ /// The objective function being optimized, evaluated at the starting point of the search
+ /// Search direction
+ /// Initial size of the step in the search direction
public LineSearchResult FindConformingStep(IObjectiveFunctionEvaluation startingPoint, Vector searchDirection, double initialStep)
{
+ if (!startingPoint.IsGradientSupported)
+ throw new ArgumentException("objective function does not support gradient");
+
double lowerBound = 0.0;
double upperBound = Double.PositiveInfinity;
double step = initialStep;