Struct argmin::solver::goldensectionsearch::GoldenSectionSearch
source · pub struct GoldenSectionSearch<F> { /* private fields */ }
Expand description
Golden-section search
The golden-section search is a technique for finding an extremum (minimum or maximum) of a function inside a specified interval.
The method operates by successively narrowing the range of values on the specified interval, which makes it relatively slow, but very robust. The technique derives its name from the fact that the algorithm maintains the function values for four points whose three interval widths are in the ratio 2-φ:2φ-3:2-φ where φ is the golden ratio. These ratios are maintained for each iteration and are maximally efficient.
The min_bound
and max_bound
arguments define values that bracket the expected minimum.
Requires an initial guess which is to be provided via Executor
s
configure
method.
Requirements on the optimization problem
The optimization problem is required to implement CostFunction
.
Reference
Implementations§
source§impl<F> GoldenSectionSearch<F>where
F: ArgminFloat,
impl<F> GoldenSectionSearch<F>where F: ArgminFloat,
sourcepub fn new(min_bound: F, max_bound: F) -> Result<Self, Error>
pub fn new(min_bound: F, max_bound: F) -> Result<Self, Error>
Construct a new instance of GoldenSectionSearch
.
The min_bound
and max_bound
arguments define values that bracket the expected minimum.
Example
let gss = GoldenSectionSearch::new(-2.5f64, 3.0f64)?;
sourcepub fn with_tolerance(self, tolerance: F) -> Result<Self, Error>
pub fn with_tolerance(self, tolerance: F) -> Result<Self, Error>
Set tolerance.
Must be larger than 0
and defaults to 0.01
.
Example
let gss = GoldenSectionSearch::new(-2.5f64, 3.0f64)?.with_tolerance(0.0001)?;
Trait Implementations§
source§impl<F: Clone> Clone for GoldenSectionSearch<F>
impl<F: Clone> Clone for GoldenSectionSearch<F>
source§fn clone(&self) -> GoldenSectionSearch<F>
fn clone(&self) -> GoldenSectionSearch<F>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de, F> Deserialize<'de> for GoldenSectionSearch<F>where
F: Deserialize<'de>,
impl<'de, F> Deserialize<'de> for GoldenSectionSearch<F>where F: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<F> Serialize for GoldenSectionSearch<F>where
F: Serialize,
impl<F> Serialize for GoldenSectionSearch<F>where F: Serialize,
source§impl<O, F> Solver<O, IterState<F, (), (), (), F>> for GoldenSectionSearch<F>where
O: CostFunction<Param = F, Output = F>,
F: ArgminFloat,
impl<O, F> Solver<O, IterState<F, (), (), (), F>> for GoldenSectionSearch<F>where O: CostFunction<Param = F, Output = F>, F: ArgminFloat,
source§const NAME: &'static str = "Golden-section search"
const NAME: &'static str = "Golden-section search"
source§fn init(
&mut self,
problem: &mut Problem<O>,
state: IterState<F, (), (), (), F>
) -> Result<(IterState<F, (), (), (), F>, Option<KV>), Error>
fn init( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), F> ) -> Result<(IterState<F, (), (), (), F>, Option<KV>), Error>
source§fn next_iter(
&mut self,
problem: &mut Problem<O>,
state: IterState<F, (), (), (), F>
) -> Result<(IterState<F, (), (), (), F>, Option<KV>), Error>
fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), F> ) -> Result<(IterState<F, (), (), (), F>, Option<KV>), Error>
state
and optionally a KV
which holds key-value pairs used in
Observers.source§fn terminate(
&mut self,
_state: &IterState<F, (), (), (), F>
) -> TerminationStatus
fn terminate( &mut self, _state: &IterState<F, (), (), (), F> ) -> TerminationStatus
terminate_internal
. Read more