pub fn least_squares_bounded(
fun: impl Fn(&[f64]) -> Vec<f64>,
jac: impl Fn(&[f64]) -> Array2<f64>,
x0: &[f64],
lb: &[f64],
ub: &[f64],
options: LeastSquaresOptions,
) -> Result<BoundedLeastSquaresResult, ErrorsJSL>Expand description
Minimises ½ Σ ρ(fᵢ(x)²) subject to lb ≤ x ≤ ub by the trust-region reflective method
(SciPy’s least_squares(method='trf', tr_solver='exact', x_scale=1)). fun returns the
residuals and jac their Jacobian (rows = residuals).
Each iteration scales the variables by the Coleman-Li vector v (the distance to the bound
that the gradient points at), so that the trust region shrinks near the bounds; solves the
scaled trust-region problem exactly through an SVD; and then takes the best of that step
truncated at the bound, its reflection off the bound, and a scaled gradient step.