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
impl Method
Sourcepub const NAMES: [(&'static str, Method); 9]
pub const NAMES: [(&'static str, Method); 9]
Each method’s name, which FromStr reads, ignoring case, and Display writes.
Sourcepub fn choose(task: Task, variables: usize, bounded: bool) -> Method
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§
impl Copy for Method
impl Eq for Method
impl StructuralPartialEq for Method
Auto Trait Implementations§
impl Forget for Method
impl Freeze for Method
impl RefUnwindSafe for Method
impl Send for Method
impl Sync for Method
impl Unpin for Method
impl UnsafeUnpin for Method
impl UnwindSafe for Method
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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