Skip to main content

MinSettings

Struct MinSettings 

Source
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 case x* ≈ 0, where a purely relative tolerance can never be met.
  • x_tol_rel — relative abscissa tolerance, dimensionless, >= 0. Values below SQRT_EPSILON are honoured but buy no accuracy on a smooth objective; they only cost iterations.
  • max_iterations — hard cap. On reaching it a lane reports MinStatus::MaxIterations and its current bracket midpoint, which MinSolution::extremum still 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: f64

Absolute bracket-width tolerance, in the abscissa’s units. >= 0.

§x_tol_rel: f64

Relative bracket-width tolerance, dimensionless. >= 0.

§max_iterations: u32

Maximum iterations per lane before reporting MinStatus::MaxIterations. >= 1.

Implementations§

Source§

impl MinSettings

Source

pub fn bracket_tolerance(&self, x: f64) -> f64

The bracket-width tolerance at abscissa x: x_tol_abs + x_tol_rel * |x|.

§Arguments
  • x — the abscissa at which to evaluate the tolerance, in the abscissa’s units. The kernel passes the current bracket midpoint.
§Returns

A width in the abscissa’s units.

Trait Implementations§

Source§

impl Clone for MinSettings

Source§

fn clone(&self) -> MinSettings

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MinSettings

Source§

impl Debug for MinSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MinSettings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for MinSettings

Source§

fn eq(&self, other: &MinSettings) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MinSettings

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.