linesearch

Linesearch functions.

Once we have a direction to step, for example, the negative gradient direction in a gradient descent algorithm, then we need to know how big of a step to take. If we take too large or small a step, we may not find the minumum of the object function along the line we are stepping. A linesearch attempts to find the optimal step size in a given direction with minimal gradient and objective evaluations.

mr_utils.optimization.linesearch.linesearch(obj, x0, a0, s)[source]

More sophisticated linesearch.

Parameters:
  • obj (callable) – Objective function.
  • x0 (array_like) – Current location.
  • a0 (float) – Current guess at stepsize.
  • s (array_like) – Search direction.
Returns:

a – Stepsize for the current step.

Return type:

float

mr_utils.optimization.linesearch.linesearch_quad(f, x, a, s)[source]

Simple quadratic linesearch.

Parameters:
  • f (callable) – Objective function.
  • x (array_like) – Current location.
  • a (float) – Guess for stepsize.
  • s (array_like) – Search direction.
Returns:

a – Stepsize for the current step.

Return type:

float