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:

  1. Reflection (Parameter alpha, defaults to 1, configurable via with_alpha)
  2. Expansion (Parameter gamma, defaults to 2, configurable via with_gamma)
  3. Contraction inside or outside (Parameter rho, defaults to 0.5, configurable via with_rho)
  4. Shrink (Parameter sigma, defaults to 0.5, configurable via with_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>
where P: Clone + ArgminAdd<P, P> + ArgminSub<P, P> + ArgminMul<F, P>, F: ArgminFloat,

source

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);
source

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)?;
source

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)?;
source

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)?;
source

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)?;
source

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>

source§

fn clone(&self) -> NelderMead<P, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<P, F> Serialize for NelderMead<P, F>
where P: Serialize, F: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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>,

source§

const NAME: &'static str = "Nelder-Mead method"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, _state: &IterState<P, (), (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more

Auto Trait Implementations§

§

impl<P, F> RefUnwindSafe for NelderMead<P, F>

§

impl<P, F> Send for NelderMead<P, F>
where F: Send, P: Send,

§

impl<P, F> Sync for NelderMead<P, F>
where F: Sync, P: Sync,

§

impl<P, F> Unpin for NelderMead<P, F>
where F: Unpin, P: Unpin,

§

impl<P, F> UnwindSafe for NelderMead<P, F>
where F: UnwindSafe, P: UnwindSafe,

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> 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> ToOwned for T
where T: Clone,

§

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>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> SendAlias for T

source§

impl<T> SyncAlias for T