Skip to content

linesearch⚓︎

Line-search-based deterministic optimization methods.

This module implements gradient-based algorithms that share a common line search interface, including gradient descent, BFGS, and Newton-CG.

LineSearch ⚓︎

Bases: OptimizerBase

Line-search optimizer compatible with OptimizerBase.

The class supports gradient descent, BFGS, and Newton-CG search directions, together with either Wolfe or backtracking line search. It can operate with bounds, optional state transformations, logging, result persistence, and restart checkpoints.

__init__(x0, fun, method='GD', jac=None, hess=None, args=(), bounds=None, callback=None, **options) ⚓︎

Initialize a line-search optimizer instance.

Parameters:

Name Type Description Default
x0 ndarray

Initial parameter vector.

required
fun callable

Objective function.

required
method (GD, BFGS, Newton - CG)

Search-direction method.

'GD'
jac callable

Gradient function.

None
hess callable

Hessian function, required by Newton-CG.

None
args tuple

Extra positional arguments passed to the wrapped callables.

()
bounds sequence

Lower and upper bounds for each state variable.

None
callback callable

Callback invoked after successful updates.

None
**options

Line-search configuration, plus everything :class:OptimizerBase takes. - step_size: Initial step size (default: None, auto-scaled). - step_size_max: Maximum step size (default: 1e5). - step_size_adapt: Step size adaptation strategy (0: none, 1: function-based, 2: gradient-based). Default is 1 (function-based). - c1: Armijo condition constant (default: 1e-4). - c2: Curvature condition constant (default: 0.9). - rho: Step size reduction factor for backtracking (default: 0.5). - lsmaxiter: Maximum line search iterations (default: 10). - lsmethod: Line search method (0: backtracking, 1: Wolfe, default: 1). - normalize: Whether to normalize the search direction (default: False). - recompute_jac: Number of gradient recomputation attempts on line search failure (default: 0). - hess0_inv: Initial inverse-Hessian approximation for BFGS (default: identity).

{}

log_columns() ⚓︎

The row of the iteration log: iteration, objective, gradient infinity norm, step length taken.

update_step() ⚓︎

Perform one optimization step.

The method computes a search direction, performs a line search, and commits the new iterate on success. When enabled, it can recompute the gradient and retry if the line search fails.