Skip to main content

Sense

Enum Sense 

Source
pub enum Sense {
    Minimise,
    Maximise,
}
Expand description

Whether golden_section_batch should locate a minimum or a maximum.

Golden section is indifferent: it compares two interior probes and keeps the sub-bracket containing the better one, and “better” is the only thing this switch changes. Nothing is negated internally, so the values a solution reports are the caller’s own objective values with their own sign.

Maximise exists because the workspace’s production golden-section caller — the homogeneous-equilibrium choked-flow solver in tampines-steam-tables — maximises a mass flux. A module that only minimised would force that caller to negate at the boundary, which is exactly the kind of avoidable sign bug a uom-typed codebase is trying to design out.

§Units

Dimensionless — a mode selector, not a quantity.

Variants§

§

Minimise

Locate the abscissa where the objective is smallest. The default.

§

Maximise

Locate the abscissa where the objective is largest.

Implementations§

Source§

impl Sense

Source

pub fn is_better(self, candidate: f64, incumbent: f64) -> bool

Whether candidate is the better of two objective values under this sense.

Strict comparison, so a tie resolves the same way on every run and on every backend: the incumbent is kept. That matters more than it looks — a plateau in the objective is common (a guard clause returning 0.0, a clamped property table) and a non-strict comparison would make the surviving bracket depend on evaluation order.

§Arguments
  • candidate, incumbent — objective values, in the objective’s units. Both must be finite; the kernel rejects non-finite values before reaching here.
§Example
use outram_foam_basic_lib::math::minimise::Sense;

assert!(Sense::Minimise.is_better(1.0, 2.0));
assert!(Sense::Maximise.is_better(2.0, 1.0));
assert!(!Sense::Minimise.is_better(1.0, 1.0)); // a tie is not better
Source

pub fn label(self) -> &'static str

A short human-readable label, for log lines and failure reports.

Trait Implementations§

Source§

impl Clone for Sense

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 Sense

Source§

impl Debug for Sense

Source§

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

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

impl Default for Sense

Source§

fn default() -> Self

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

impl Eq for Sense

Source§

impl Hash for Sense

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Sense

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 Sense

Auto Trait Implementations§

§

impl Freeze for Sense

§

impl RefUnwindSafe for Sense

§

impl Send for Sense

§

impl Sync for Sense

§

impl Unpin for Sense

§

impl UnsafeUnpin for Sense

§

impl UnwindSafe for Sense

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.