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
impl Sense
Sourcepub fn is_better(self, candidate: f64, incumbent: f64) -> bool
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