[][src]Struct mathru::optimization::Gradient

pub struct Gradient { /* fields omitted */ }

Gradient method

It is assumed that $f \colon D \in \mathbb{R}^n \to \mathbb{R}$ The idea is, that in every iteration a step is made in direction of the anti gradient.

x_{k + 1} := x_{k} - \alpha_{k} \nabla f(x_{k})

in order that $f(x_{k + 1}) < f(x_{k})$.

input: Function $f: \mathbb{R}^n \to \mathbb{R}$, and initial approximation $x_{0} \in \mathbb{R}^{n}$

output: $x_{k}$

  1. Initialization: choose $\sigma \in (0, 1) $

    set $k := 0 $

  2. calculate antigradient $d_{k} := -\nabla f(x_{k}) $

    set $\alpha_{k} := 1$

  3. while $f(x_{k} + \alpha_{k} d_{k}) > f(x_k) - \sigma \alpha_{k} \lvert \lvert d_{k} \rvert \rvert_{2}^{2} $

    set $\alpha_{k} := \alpha_{k} /2$

  4. $x_{k + 1} := x_{k} + \alpha_{k} d_{k}$

  5. $k := k + 1$ go to 2.

Methods

impl Gradient[src]

pub fn new(sigma: f64, iters: usize) -> Gradient[src]

Construct an instance of gradient algorithm.

Parameters

sigma: learning rate > 0.0

Examples

use mathru::optimization::Gradient;

let gd = Gradient::new(0.3, 10000);

impl Gradient[src]

pub fn minimize<F: Jacobian<f64>>(
    &self,
    func: &F,
    x_0: &Vector<f64>
) -> OptimResult<Vector<f64>>
[src]

Trait Implementations

impl Clone for Gradient[src]

impl Copy for Gradient[src]

impl Debug for Gradient[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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