Struct NelderMeadBuilder

Source
pub struct NelderMeadBuilder { /* private fields */ }
Expand description

Builder for NelderMead.

Implementations§

Source§

impl NelderMeadBuilder

Source

pub fn ulps(&mut self, value: i64) -> &mut Self

The required number of floating point representations that separate two numbers to consider them equal. See crate float_cmp for more information.

Source

pub fn maxiter<VALUE: Into<Option<usize>>>(&mut self, value: VALUE) -> &mut Self

The maximum number of iterations to optimize. If neither maxiter nor maxfun are given, both default to n*200 where n is the number of parameters to optimize.

Examples found in repository?
examples/simple.rs (line 14)
8pub fn main() {
9    let function =
10        |x: ArrayView1<f64>| (1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2);
11    let minimizer = NelderMeadBuilder::default()
12        .xtol(1e-6f64)
13        .ftol(1e-6f64)
14        .maxiter(50000) 
15        .build()
16        .unwrap();
17    let args = Array::from_vec(vec![3.0, -8.3]);
18    let ans = minimizer.minimize(&function, args.view());
19    println!("Final optimized arguments: {}", ans);
20}
Source

pub fn maxfun<VALUE: Into<Option<usize>>>(&mut self, value: VALUE) -> &mut Self

The maximum number of function calls used to optimize. If neither maxiter nor maxfun are given, both default to n*200 where n is the number of parameters to optimize.

Source

pub fn adaptive(&mut self, value: bool) -> &mut Self

Adapt algorithm parameters to dimensionality of the problem. Useful for high-dimensional minimization.

Source

pub fn xtol(&mut self, value: f64) -> &mut Self

Absolute error in function parameters between iterations that is acceptable for convergence.

Examples found in repository?
examples/simple.rs (line 12)
8pub fn main() {
9    let function =
10        |x: ArrayView1<f64>| (1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2);
11    let minimizer = NelderMeadBuilder::default()
12        .xtol(1e-6f64)
13        .ftol(1e-6f64)
14        .maxiter(50000) 
15        .build()
16        .unwrap();
17    let args = Array::from_vec(vec![3.0, -8.3]);
18    let ans = minimizer.minimize(&function, args.view());
19    println!("Final optimized arguments: {}", ans);
20}
Source

pub fn ftol(&mut self, value: f64) -> &mut Self

Absolute error in function values between iterations that is acceptable for convergence.

Examples found in repository?
examples/simple.rs (line 13)
8pub fn main() {
9    let function =
10        |x: ArrayView1<f64>| (1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2);
11    let minimizer = NelderMeadBuilder::default()
12        .xtol(1e-6f64)
13        .ftol(1e-6f64)
14        .maxiter(50000) 
15        .build()
16        .unwrap();
17    let args = Array::from_vec(vec![3.0, -8.3]);
18    let ans = minimizer.minimize(&function, args.view());
19    println!("Final optimized arguments: {}", ans);
20}
Source

pub fn build(&self) -> Result<NelderMead, String>

Builds a new NelderMead.

§Errors

If a required field has not been initialized.

Examples found in repository?
examples/simple.rs (line 15)
8pub fn main() {
9    let function =
10        |x: ArrayView1<f64>| (1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2);
11    let minimizer = NelderMeadBuilder::default()
12        .xtol(1e-6f64)
13        .ftol(1e-6f64)
14        .maxiter(50000) 
15        .build()
16        .unwrap();
17    let args = Array::from_vec(vec![3.0, -8.3]);
18    let ans = minimizer.minimize(&function, args.view());
19    println!("Final optimized arguments: {}", ans);
20}

Trait Implementations§

Source§

impl Clone for NelderMeadBuilder

Source§

fn clone(&self) -> NelderMeadBuilder

Returns a duplicate 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 Default for NelderMeadBuilder

Source§

fn default() -> NelderMeadBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

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

Source§

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.