Skip to main content

Module optimization

Module optimization 

Source
Expand description

Multi-dimensional optimization for model calibration, one algorithm per file. This is the fitting layer for every parametric model — Heston today (equity::heston::calibrate), SABR / Nelson-Siegel or any other least-squares fit tomorrow — so the machinery lives in one place, like solvers does for 1-D root finding.

Gradient-based (analytic gradient optional — central finite differences fill in when absent):

  • [steepest_descent]: robust baseline, linear convergence;
  • [conjugate_gradient]: nonlinear CG (Polak-Ribiere with restarts);
  • [bfgs]: quasi-Newton with the inverse-Hessian update — the default choice for smooth unconstrained problems;
  • [levenberg_marquardt]: for least squares min sum r_i(x)^2 specifically — the standard calibration workhorse.

Gradient-free:

  • [nelder_mead]: the simplex method, for noisy or non-smooth objectives;
  • [differential_evolution]: seeded, bounded global search for multimodal landscapes (e.g. a cold-start calibration before a gradient polish).

Every algorithm can be called directly, or through the pluggable minimize with a Method enum and a Problem description:

use rustyqlib::core::optimization::{minimize, Method, OptimConfig, Problem};
let rosenbrock = |x: &[f64]| {
    (1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0] * x[0]).powi(2)
};
let problem = Problem::scalar(&rosenbrock, vec![-1.2, 1.0]);
let fit = minimize(&OptimConfig::default(), Method::Bfgs, &problem).unwrap();
assert!((fit.x[0] - 1.0).abs() < 1e-5 && (fit.x[1] - 1.0).abs() < 1e-5);

Re-exports§

pub use bfgs::bfgs;
pub use conjugate_gradient::conjugate_gradient;
pub use differential_evolution::differential_evolution;
pub use levenberg_marquardt::levenberg_marquardt;
pub use nelder_mead::nelder_mead;
pub use steepest_descent::steepest_descent;

Modules§

bfgs
BFGS quasi-Newton: builds an inverse-Hessian approximation from gradient differences, giving superlinear convergence on smooth problems. The default choice for unconstrained smooth calibration.
conjugate_gradient
Nonlinear conjugate gradient (Polak-Ribiere+): steepest descent’s cost per iteration with far better search directions on ill- conditioned valleys, no matrix storage.
differential_evolution
Differential evolution (DE/rand/1/bin): seeded, bounded global search. The tool for multimodal calibration landscapes — find the basin globally, then polish with BFGS or Levenberg-Marquardt.
levenberg_marquardt
Levenberg-Marquardt: the standard damped Gauss-Newton method for nonlinear least squares min sum r_i(x)^2 — the calibration workhorse (Heston, SABR, Nelson-Siegel, curve and surface fits).
nelder_mead
Nelder-Mead simplex: gradient-free local search by reflecting, expanding and contracting a simplex of n + 1 points. The tool for noisy or non-smooth objectives where gradients mislead.
steepest_descent
Steepest descent: follow -gradient with a backtracking line search. Linear convergence — the robust baseline, and the reference the fancier methods are tested against.

Structs§

OptimConfig
Optimizer configuration: convergence tolerance and iteration cap.
OptimResult
Result of an optimization run.
Problem
An optimization problem: a scalar objective or a residual vector (least squares), whatever derivatives are available, a start, and optional bounds.

Enums§

Method
The pluggable algorithm choice for minimize.

Functions§

minimize
Minimize problem with the chosen Method.