Browse Source

Optimization: inline docs

pull/489/head
Christoph Ruegg 11 years ago
committed by Erik Ovegard
parent
commit
a342a051d6
  1. 27
      src/Numerics/Optimization/LineSearch/WeakWolfeLineSearch.cs

27
src/Numerics/Optimization/LineSearch/WeakWolfeLineSearch.cs

@ -3,6 +3,19 @@ using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.Optimization.LineSearch
{
/// <summary>
/// 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
/// </summary>
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
/// <param name="startingPoint">The objective function being optimized, evaluated at the starting point of the search</param>
/// <param name="searchDirection">Search direction</param>
/// <param name="initialStep">Initial size of the step in the search direction</param>
public LineSearchResult FindConformingStep(IObjectiveFunctionEvaluation startingPoint, Vector<double> 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;

Loading…
Cancel
Save