Struct LevenbergMarquardt

Source
pub struct LevenbergMarquardt<F> { /* private fields */ }
Expand description

Levenberg-Marquardt optimization algorithm.

See the module documentation for a usage example.

The runtime and termination behavior can be controlled by various hyperparameters.

Implementations§

Source§

impl<F: RealField + Float> LevenbergMarquardt<F>

Source

pub fn new() -> Self

Source

pub fn with_ftol(self, ftol: F) -> Self

Set the relative error desired in the objective function $f$.

Termination occurs when both the actual and predicted relative reductions for $f$ are at most ftol.

§Panics

Panics if $\mathtt{ftol} < 0$.

Source

pub fn with_xtol(self, xtol: F) -> Self

Set relative error between last two approximations.

Termination occurs when the relative error between two consecutive iterates is at most xtol.

§Panics

Panics if $\mathtt{xtol} < 0$.

Source

pub fn with_gtol(self, gtol: F) -> Self

Set orthogonality desired between the residual vector and its derivative.

Termination occurs when the cosine of the angle between the residual vector $\vec{r}$ and any column of the Jacobian $\mathbf{J}$ is at most gtol in absolute value.

With other words, the algorithm will terminate if

  \cos\bigl(\sphericalangle (\mathbf{J}\vec{e}_i, \vec{r})\bigr) =
  \frac{|(\mathbf{J}^\top \vec{r})_i|}{\|\mathbf{J}\vec{e}_i\|\|\vec{r}\|} \leq \texttt{gtol}
  \quad\text{for all }i=1,\ldots,n.

This is based on the fact that those vectors are orthogonal near the optimum (gradient is zero). The angle check is scale invariant, whereas checking that $\nabla f(\vec{x})\approx \vec{0}$ is not.

§Panics

Panics if $\mathtt{gtol} < 0$.

Source

pub fn with_tol(self, tol: F) -> Self

Shortcut to set tol as in MINPACK LMDER1.

Sets ftol = xtol = tol and gtol = 0.

§Panics

Panics if $\mathtt{tol} \leq 0$.

Source

pub fn with_stepbound(self, stepbound: F) -> Self

Set factor for the initial step bound.

This bound is set to $\mathtt{stepbound}\cdot\|\mathbf{D}\vec{x}\|$ if nonzero, or else to stepbound itself. In most cases stepbound should lie in the interval $[0.1,100]$.

§Panics

Panics if $\mathtt{stepbound} \leq 0$.

Source

pub fn with_patience(self, patience: usize) -> Self

Set factor for the maximal number of function evaluations.

The maximal number of function evaluations is set to $\texttt{patience}\cdot(n + 1)$.

§Panics

Panics if $\mathtt{patience} \leq 0$.

Source

pub fn with_scale_diag(self, scale_diag: bool) -> Self

Enable or disable whether the variables will be rescaled internally.

Source

pub fn minimize<N, M, O>(&self, target: O) -> (O, MinimizationReport<F>)
where N: Dim, M: DimMin<N> + DimMax<N>, O: LeastSquaresProblem<F, M, N>, DefaultAllocator: Allocator<N> + Reallocator<F, M, N, DimMaximum<M, N>, N>,

Try to solve the given least squares problem.

The parameters of the problem which are set when this function is called are used as the initial guess for $\vec{x}$.

Trait Implementations§

Source§

impl<F: Clone> Clone for LevenbergMarquardt<F>

Source§

fn clone(&self) -> LevenbergMarquardt<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<F: Debug> Debug for LevenbergMarquardt<F>

Source§

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

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

impl<F: RealField + Float> Default for LevenbergMarquardt<F>

Source§

fn default() -> Self

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

impl<F: PartialEq> PartialEq for LevenbergMarquardt<F>

Source§

fn eq(&self, other: &LevenbergMarquardt<F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: Copy> Copy for LevenbergMarquardt<F>

Source§

impl<F: Eq> Eq for LevenbergMarquardt<F>

Source§

impl<F> StructuralPartialEq for LevenbergMarquardt<F>

Auto Trait Implementations§

§

impl<F> Freeze for LevenbergMarquardt<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for LevenbergMarquardt<F>
where F: RefUnwindSafe,

§

impl<F> Send for LevenbergMarquardt<F>
where F: Send,

§

impl<F> Sync for LevenbergMarquardt<F>
where F: Sync,

§

impl<F> Unpin for LevenbergMarquardt<F>
where F: Unpin,

§

impl<F> UnwindSafe for LevenbergMarquardt<F>
where F: 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,