Skip to content

Optimization

Optimizers, constraints and end criteria.

optimization

Runtime source shim for the native itofin.optimization submodule.

The real itofin.optimization is a compiled submodule registered into sys.modules by the extension (see crates/itofin-py/src/lib.rs); it wins at import time, so nothing here runs. This file exists only so static type checkers resolve from itofin.optimization import ... from optimization.pyi without a reportMissingModuleSource warning.

Auto-generated by scripts/gen_submodule_shims.py from optimization.pyi; do not edit or delete by hand.

LevenbergMarquardt

LevenbergMarquardt(epsfcn: float = 1e-08, xtol: float = 1e-08, gtol: float = 1e-08, use_cost_functions_jacobian: bool = False)

The least-squares optimizer used to fit model parameters.

Wraps the MINPACK lmdif routine. The Jacobian comes from a built-in forward-difference scheme by default; the cost function's own jacobian method is used instead when use_cost_functions_jacobian is set.

Initialize the optimizer; the defaults are QuantLib's.

Parameters:

Name Type Description Default
epsfcn float

The finite-difference step seed used when the Jacobian is computed by differences.

1e-08
xtol float

The tolerance on the independent variable.

1e-08
gtol float

The tolerance on the gradient.

1e-08
use_cost_functions_jacobian bool

Use the cost function's own jacobian method (a central difference, order 2 but costlier) instead of the built-in forward-difference scheme.

False

EndCriteria

EndCriteria(max_iterations: int, max_stationary_state_iterations: int | None, root_epsilon: float, function_epsilon: float, gradient_norm_epsilon: float | None)

The optimizer stopping rule.

Carries the iteration cap and the stationarity thresholds an optimization run is tested against.

Initialize the criteria.

Parameters:

Name Type Description Default
max_iterations int

The iteration count at which the run stops.

required
max_stationary_state_iterations int | None

How many consecutive stationary iterations are tolerated before the run is called converged; None defaults to min(max_iterations / 2, 100).

required
root_epsilon float

The variation of the independent variable below which an iteration counts as stationary.

required
function_epsilon float

The variation of the function value below which an iteration counts as stationary, and, for a cost function known to be positive, the value below which the run has converged.

required
gradient_norm_epsilon float | None

The gradient norm below which the run has converged; None defaults to function_epsilon.

required

Raises:

Type Description
ItofinError

Unless 1 < max_stationary_state_iterations < max_iterations, or if any epsilon is negative or non-finite.