Struct argmin::solver::neldermead::NelderMead
source · pub struct NelderMead<P, F> { /* private fields */ }
Expand description
§Nelder-Mead method
The Nelder-Mead method a heuristic search method for nonlinear optimization problems which does not require derivatives.
The method is based on simplices which consist of n+1 vertices for an optimization problem with n dimensions. The function to be optimized is evaluated at all vertices. Based on these cost function values the behavior of the cost function is extrapolated in order to find the next point to be evaluated.
The following actions are possible:
- Reflection (Parameter
alpha
, defaults to1
, configurable viawith_alpha
) - Expansion (Parameter
gamma
, defaults to2
, configurable viawith_gamma
) - Contraction inside or outside (Parameter
rho
, defaults to0.5
, configurable viawith_rho
) - Shrink (Parameter
sigma
, defaults to0.5
, configurable viawith_sigma
)
§Requirements on the optimization problem
The optimization problem is required to implement CostFunction
.
§References
https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method
http://www.scholarpedia.org/article/Nelder-Mead_algorithm#Simplex_transformation_algorithm
Implementations§
source§impl<P, F> NelderMead<P, F>
impl<P, F> NelderMead<P, F>
sourcepub fn new(params: Vec<P>) -> Self
pub fn new(params: Vec<P>) -> Self
Construct a new instance of NelderMead
Takes a vector of parameter vectors. The number of parameter vectors must be n + 1
where
n
is the number of optimization parameters.
§Example
let nm: NelderMead<Vec<f64>, f64> = NelderMead::new(vec_of_parameters);
sourcepub fn with_sd_tolerance(self, tol: F) -> Result<Self, Error>
pub fn with_sd_tolerance(self, tol: F) -> Result<Self, Error>
Set sample standard deviation tolerance
Must be non-negative and defaults to EPSILON
.
§Example
let nm: NelderMead<Vec<f64>, f64> =
NelderMead::new(vec_of_parameters).with_sd_tolerance(1e-6)?;
sourcepub fn with_alpha(self, alpha: F) -> Result<Self, Error>
pub fn with_alpha(self, alpha: F) -> Result<Self, Error>
Set alpha parameter for reflection
Must be larger than 0 and defaults to 1.
§Example
let nm: NelderMead<Vec<f64>, f64> =
NelderMead::new(vec_of_parameters).with_alpha(0.9)?;
sourcepub fn with_gamma(self, gamma: F) -> Result<Self, Error>
pub fn with_gamma(self, gamma: F) -> Result<Self, Error>
Set gamma for expansion
Must be larger than 1 and defaults to 2.
§Example
let nm: NelderMead<Vec<f64>, f64> =
NelderMead::new(vec_of_parameters).with_gamma(1.9)?;
sourcepub fn with_rho(self, rho: F) -> Result<Self, Error>
pub fn with_rho(self, rho: F) -> Result<Self, Error>
Set rho for contraction
Must be in (0, 0.5] and defaults to 0.5.
§Example
let nm: NelderMead<Vec<f64>, f64> =
NelderMead::new(vec_of_parameters).with_rho(0.4)?;
sourcepub fn with_sigma(self, sigma: F) -> Result<Self, Error>
pub fn with_sigma(self, sigma: F) -> Result<Self, Error>
Set sigma for shrinking
Must be in (0, 1] and defaults to 0.5.
§Example
let nm: NelderMead<Vec<f64>, f64> =
NelderMead::new(vec_of_parameters).with_sigma(0.4)?;
Trait Implementations§
source§impl<P: Clone, F: Clone> Clone for NelderMead<P, F>
impl<P: Clone, F: Clone> Clone for NelderMead<P, F>
source§fn clone(&self) -> NelderMead<P, F>
fn clone(&self) -> NelderMead<P, F>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de, P, F> Deserialize<'de> for NelderMead<P, F>where
P: Deserialize<'de>,
F: Deserialize<'de>,
impl<'de, P, F> Deserialize<'de> for NelderMead<P, F>where
P: Deserialize<'de>,
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<P, F> Serialize for NelderMead<P, F>
impl<P, F> Serialize for NelderMead<P, F>
source§impl<O, P, F> Solver<O, IterState<P, (), (), (), (), F>> for NelderMead<P, F>where
O: CostFunction<Param = P, Output = F>,
P: Clone + ArgminSub<P, P> + ArgminAdd<P, P> + ArgminMul<F, P>,
F: ArgminFloat + Sum<F>,
impl<O, P, F> Solver<O, IterState<P, (), (), (), (), F>> for NelderMead<P, F>where
O: CostFunction<Param = P, Output = F>,
P: Clone + ArgminSub<P, P> + ArgminAdd<P, P> + ArgminMul<F, P>,
F: ArgminFloat + Sum<F>,
source§fn init(
&mut self,
problem: &mut Problem<O>,
state: IterState<P, (), (), (), (), F>
) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>
fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>
source§fn next_iter(
&mut self,
problem: &mut Problem<O>,
state: IterState<P, (), (), (), (), F>
) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>
fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>
state
and optionally a KV
which holds key-value pairs used in
Observers.source§fn terminate(
&mut self,
_state: &IterState<P, (), (), (), (), F>
) -> TerminationStatus
fn terminate( &mut self, _state: &IterState<P, (), (), (), (), F> ) -> TerminationStatus
terminate_internal
. Read more