Skip to main content

MinSolution

Struct MinSolution 

Source
pub struct MinSolution { /* private fields */ }
Expand description

The outcome of a single lane: its status, its located abscissa, the objective value there, the final bracket width and the work it took.

The fields are private on purpose. The only way to get a number claimed to be an extremum is Self::extremum, which returns Option<f64> and hands back Some only for a converged lane. The raw iterate is available from Self::last_iterate, whose name is chosen so that using it as an answer is a visible decision in the calling code rather than an accident.

Abscissa versus value. Self::extremum is the argument x* — the argmin (or argmax). Self::extremal_value is the objective value f(x*) there. Mixing those two up is the classic minimisation bug, so they are named apart rather than both being called “the minimum”.

Copy, so it can be read out of a MinBatch without cloning.

§Units

Self::extremum, Self::last_iterate and Self::bracket_width are in the abscissa’s units; Self::extremal_value and Self::last_value are in the objective’s units; Self::iterations is a dimensionless count.

Implementations§

Source§

impl MinSolution

Source

pub fn extremum(&self) -> Option<f64>

The located extremum’s abscissa x*, if this lane converged.

None for every failure status. This is the accessor to reach for; the Option is the point.

§Returns

Some(x) in the abscissa’s units when Self::status is MinStatus::Converged, otherwise None. The value returned is the midpoint of the final bracket, so the worst-case distance to the true extremum of a unimodal objective is half of Self::bracket_width — but read the module-level accuracy section before believing a bracket width below sqrt(eps) * |x|.

Source

pub fn extremal_value(&self) -> Option<f64>

The objective value f(x*) at the located extremum, if this lane converged.

None for every failure status. In the objective’s units, with the caller’s own sign — nothing is negated for Sense::Maximise.

Source

pub fn last_iterate(&self) -> f64

The last abscissa the solver held, converged or not.

An extremum only when Self::status is MinStatus::Converged. For MinStatus::MaxIterations this is the midpoint of the bracket the lane ran out of iterations on, offered for diagnosis — for deciding whether the lane was close or wildly off — not as an answer. For MinStatus::InvalidBracket it is NaN, because there is no honest number to report.

Source

pub fn last_value(&self) -> f64

The objective value at Self::last_iterate, in the objective’s units.

NaN when no meaningful evaluation was reached; for MinStatus::NotFinite it is the offending non-finite value itself, which tells you whether the objective overflowed or produced a NaN.

Source

pub fn bracket_width(&self) -> f64

Width of the final bracket, in the abscissa’s units.

NaN when the lane never established a bracket. For a converged lane this bounds the abscissa error at half its value for a unimodal objective; it says nothing at all if the objective was multimodal.

Source

pub fn iterations(&self) -> u32

Iterations performed on this lane, dimensionless.

One iteration contracts the bracket by exactly GOLDEN_RATIO and costs one objective evaluation, on top of the two interior probes every lane pays up front and the one final evaluation at the returned midpoint. So a lane reporting k iterations called the objective k + 3 times, unless it stopped early on a non-finite value.

Source

pub fn status(&self) -> MinStatus

How this lane ended.

Source

pub fn converged(&self) -> bool

Whether this lane located an extremum.

Trait Implementations§

Source§

impl Clone for MinSolution

Source§

fn clone(&self) -> Self

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 MinSolution

Source§

impl Debug for MinSolution

Source§

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

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

impl PartialEq for MinSolution

Source§

fn eq(&self, other: &Self) -> 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 MinSolution

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.