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
sourceimpl<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
sourceimpl<F: Clone> Clone for GoldenSectionSearch<F>
impl<F: Clone> Clone for GoldenSectionSearch<F>
sourcefn clone(&self) -> GoldenSectionSearch<F>
fn clone(&self) -> GoldenSectionSearch<F>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'de, F> Deserialize<'de> for GoldenSectionSearch<F> where
F: Deserialize<'de>,
impl<'de, F> Deserialize<'de> for GoldenSectionSearch<F> where
F: Deserialize<'de>,
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<F> Serialize for GoldenSectionSearch<F> where
F: Serialize,
impl<F> Serialize for GoldenSectionSearch<F> where
F: Serialize,
sourceimpl<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,
sourceconst NAME: &'static str = "Golden-section search"
const NAME: &'static str = "Golden-section search"
Name of the solver. Mainly used in Observers.
sourcefn 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>
Initializes the algorithm. Read more
sourcefn 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>
sourcefn terminate(
&mut self,
_state: &IterState<F, (), (), (), F>
) -> TerminationReason
fn terminate(
&mut self,
_state: &IterState<F, (), (), (), F>
) -> TerminationReason
Used to implement stopping criteria, in particular criteria which are not covered by
(terminate_internal
. Read more
sourcefn terminate_internal(&mut self, state: &I) -> TerminationReason
fn terminate_internal(&mut self, state: &I) -> TerminationReason
Checks whether basic termination reasons apply. Read more
Auto Trait Implementations
impl<F> RefUnwindSafe for GoldenSectionSearch<F> where
F: RefUnwindSafe,
impl<F> Send for GoldenSectionSearch<F> where
F: Send,
impl<F> Sync for GoldenSectionSearch<F> where
F: Sync,
impl<F> Unpin for GoldenSectionSearch<F> where
F: Unpin,
impl<F> UnwindSafe for GoldenSectionSearch<F> where
F: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more