Skip to main content

MinProblem

Struct MinProblem 

Source
pub struct MinProblem {
    pub lo: f64,
    pub hi: f64,
}
Expand description

One bracketed 1-D extremum problem: an interval believed to contain a single interior extremum of the objective.

§Fields and valid ranges

  • lo, hi — the bracket. Both must be finite, or the lane reports MinStatus::InvalidBracket. They may be given in either order; the kernel normalises, exactly as crate::math::parallel::RootProblem does. A degenerate bracket (lo == hi) converges immediately at that point with zero iterations, which is truthful: a zero-width bracket has already met any non-negative tolerance.

§The precondition golden section cannot check

The objective must be unimodal on [lo, hi] — one interior extremum, no second basin. This is a precondition on the caller, not something the kernel verifies; see the module-level warning. Note that a monotone objective on the bracket is a benign special case: the contraction walks to the appropriate endpoint and converges there, which is the intended behaviour when the real extremum lies just outside. It is the multimodal case that is dangerous, because the answer looks exactly like a correct one.

There is no guess field, unlike crate::math::parallel::RootProblem. Golden section is driven entirely by the bracket and has nowhere to put a starting iterate; a method that could use one (Brent’s parabolic interpolation) is deliberately not implemented here — again, see the module docs.

§Units

Dimensionless f64 in whatever units the caller’s abscissa carries — pascals for a choke-pressure search, dimensionless for a blend factor. See the module-level “Units” section.

§Example

use outram_foam_basic_lib::math::minimise::MinProblem;

let p = MinProblem::new(0.0, 1.0);
assert_eq!(p.width(), 1.0);

// Either order is accepted; the width is still positive.
let q = MinProblem::new(1.0, 0.0);
assert_eq!(q.width(), 1.0);

Fields§

§lo: f64

One end of the bracket. Finite; need not be less than hi.

§hi: f64

The other end of the bracket. Finite; need not be greater than lo.

Implementations§

Source§

impl MinProblem

Source

pub fn new(lo: f64, hi: f64) -> Self

A problem bracketed on [lo, hi].

§Arguments
  • lo, hi — the bracket ends, finite, in either order.
Source

pub fn width(&self) -> f64

The bracket width |hi - lo|, in the abscissa’s units.

NaN if either end is NaN; infinite if either end is infinite. Both of those cases are rejected as MinStatus::InvalidBracket by the kernel.

Trait Implementations§

Source§

impl Clone for MinProblem

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 MinProblem

Source§

impl Debug for MinProblem

Source§

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

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

impl PartialEq for MinProblem

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 MinProblem

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.