Skip to main content

Method

Enum Method 

Source
pub enum Method {
    Brent,
    NelderMead,
    Powell,
    Lbfgs,
    Evolution,
    LevenbergMarquardt,
    Cg,
    Minres,
    Gmres,
}
Expand description

The methods minimize, solve and solve_linear run.

Variants§

§

Brent

Brent’s method, for one variable. Minimizing, it brackets a minimum with growing steps from the start, which stop at a bound, then takes golden-section steps, and parabolic steps where they shrink the interval fast enough. Solving one equation, it takes finite bounds as its bracket. Otherwise it steps outward from the start, extending the end whose value is nearer zero by 1.6 times the bracket’s width, until the values’ signs differ. A step that lands where the value is NaN moves halfway back toward its end until the value is defined. A side stops stepping at a bound, or where it can’t step to a defined value. Inverse quadratic interpolation and secant steps then shrink the bracket, with bisection wherever they don’t shrink it fast enough.

§

NelderMead

Nelder–Mead’s simplex, with Gao and Han’s coefficients for the number of variables. It restarts from its best point until a restart no longer lowers the value.

§

Powell

Powell’s 1964 method of conjugate directions: Brent’s method along each direction in turn, then along the step they made together, which replaces the direction of largest decrease where Powell’s test accepts it.

§

Lbfgs

L-BFGS with the last 10 steps and a strong Wolfe line search, for an objective with a gradient. It takes no bounds.

§

Evolution

Differential evolution within finite bounds, rand/1/bin with crossover 0.7 and a mutation factor drawn from 0.5 to 1 each generation. The start is one member, and the rest are uniform within the bounds. It stops when the members’ values lie within 1% of the best, or their points within 1% of the bounds’ width in every variable. Powell’s method then polishes the best point.

§

LevenbergMarquardt

Levenberg–Marquardt, for a zero or least-squares solution of nonlinear equations. Each step solves the linear least-squares problem of the Jacobian, damped with Marquardt’s scale for each variable, through linalg::lstsq. Nielsen’s rule adjusts the damping after each step. The Jacobian comes from Mapping::jacobian, or else from forward differences, at one evaluation for each variable. It stops when a step moves the point by less than tolerance, relative, or when the values are orthogonal to every column of the Jacobian within tolerance. It fails where the values are infinite or the Jacobian isn’t finite. It takes no bounds.

§

Cg

Conjugate gradients, for a symmetric positive definite matrix. On the normal equations of least squares it gives the iterates of CGLS, which match Paige and Saunders’ LSQR.

§

Minres

MINRES, for a symmetric matrix, definite or not. On the normal equations of least squares it gives the iterates of Fong and Saunders’ LSMR.

§

Gmres

GMRES, restarted every GMRES_RESTART steps, for any square matrix.

Implementations§

Source§

impl Method

Source

pub const NAMES: [(&'static str, Method); 9]

Each method’s name, which FromStr reads, ignoring case, and Display writes.

Source

pub fn choose(task: Task, variables: usize, bounded: bool) -> Method

The method a front runs for task on variables variables when Options::method is None. Minimizing, that’s Brent’s method for one variable, L-BFGS for an objective with a gradient and no bounds, Powell’s method within bounds, and Nelder–Mead otherwise. Solving, it’s Brent’s method for one equation in one variable, and Levenberg–Marquardt otherwise. Solving linear equations, it’s MINRES for least squares, and GMRES for a square system.

Trait Implementations§

Source§

impl Clone for Method

Source§

fn clone(&self) -> Method

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Method

Source§

impl Debug for Method

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Method

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Method

Source§

impl FromStr for Method

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(name: &str) -> Result<Method, <Method as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Method

Source§

fn eq(&self, other: &Method) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Method

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.