pub struct MinSettings {
pub x_tol_abs: f64,
pub x_tol_rel: f64,
pub max_iterations: u32,
}Expand description
Convergence tolerance on the bracket width, and the iteration cap.
A lane is converged when the bracket has shrunk to
x_tol_abs + x_tol_rel * |x_mid|, where x_mid is the current bracket
midpoint. There is no function-value tolerance — see the module-level
“Convergence is on the BRACKET, never on the value” section for why one would
be actively misleading here.
§Fields and valid ranges
x_tol_abs— absolute abscissa tolerance, in the abscissa’s own units. Must be>= 0. Guards the casex* ≈ 0, where a purely relative tolerance can never be met.x_tol_rel— relative abscissa tolerance, dimensionless,>= 0. Values belowSQRT_EPSILONare honoured but buy no accuracy on a smooth objective; they only cost iterations.max_iterations— hard cap. On reaching it a lane reportsMinStatus::MaxIterationsand its current bracket midpoint, whichMinSolution::extremumstill refuses to hand out. Must be>= 1.
A negative tolerance is not rejected; it simply can never be met, and the lane
will report MinStatus::MaxIterations. That is a truthful outcome rather
than a silent success.
§Defaults, and why they differ from crate::math::parallel::RootSettings
x_tol_abs = 1e-12, x_tol_rel = SQRT_EPSILON = 1.4901161193847656e-8,
max_iterations = 200.
The relative tolerance is ~10 000x looser than the root finder’s 1e-12, and
that is not a lowered standard — it is the accuracy a derivative-free
minimiser can actually deliver on a smooth objective (module docs,
“Achievable accuracy”). Defaulting to a far tighter tolerance would spend
about 30 extra iterations per lane narrowing a bracket whose midpoint does
not improve — measured 2026-08-13: 40-47 iterations at these defaults against
77 at x_tol_abs = 1e-15, x_tol_rel = 0 on the same 64-lane batch, for a
worst abscissa error that stays at 1.05e-8 either way.
The iteration cap is 200 rather than 100 because golden section contracts by a
fixed factor of GOLDEN_RATIO per iteration — it has no superlinear phase
to bail it out. Reaching a relative 1.5e-8 from a bracket 1e14 times wider
than the answer costs ln(1e-14)/ln(0.618) ≈ 67 iterations; 200 leaves room
for a caller that tightens the tolerance well past the useful floor.
§Example
use outram_foam_basic_lib::math::minimise::{MinSettings, SQRT_EPSILON};
// Struct-update syntax keeps the defaults you did not mean to change.
let s = MinSettings {
max_iterations: 500,
..MinSettings::default()
};
assert_eq!(s.x_tol_rel, SQRT_EPSILON);
assert_eq!(s.max_iterations, 500);
// The steam-tables choked-flow caller's rule -- a 1 Pa bracket -- expressed
// as an absolute tolerance with the relative part switched off.
let one_pascal = MinSettings { x_tol_abs: 1.0, x_tol_rel: 0.0, max_iterations: 100 };
assert_eq!(one_pascal.bracket_tolerance(5.0e6), 1.0);Fields§
§x_tol_abs: f64Absolute bracket-width tolerance, in the abscissa’s units. >= 0.
x_tol_rel: f64Relative bracket-width tolerance, dimensionless. >= 0.
max_iterations: u32Maximum iterations per lane before reporting
MinStatus::MaxIterations. >= 1.
Implementations§
Source§impl MinSettings
impl MinSettings
Sourcepub fn bracket_tolerance(&self, x: f64) -> f64
pub fn bracket_tolerance(&self, x: f64) -> f64
Trait Implementations§
Source§impl Clone for MinSettings
impl Clone for MinSettings
Source§fn clone(&self) -> MinSettings
fn clone(&self) -> MinSettings
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more