[−][src]Struct mathru::optimization::Gradient
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}
$
-
Initialization: choose $
\sigma \in (0, 1)
$set $
k := 0
$ -
calculate antigradient $
d_{k} := -\nabla f(x_{k})
$set $
\alpha_{k} := 1
$ -
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}
$ -
$
k := k + 1
$ go to 2.
Implementations
impl<T> Gradient<T> where
T: Real,
[src]
T: Real,
pub fn new(sigma: T, iters: usize) -> Gradient<T>
[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<T> Gradient<T> where
T: Real,
[src]
T: Real,
pub fn minimize<F>(&self, func: &F, x_0: &Vector<T>) -> OptimResult<Vector<T>> where
F: Optim<T>,
[src]
F: Optim<T>,
Trait Implementations
impl<T: Clone> Clone for Gradient<T>
[src]
impl<T: Copy> Copy for Gradient<T>
[src]
impl<T: Debug> Debug for Gradient<T>
[src]
impl<'de, T> Deserialize<'de> for Gradient<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T> Serialize for Gradient<T> where
T: Serialize,
[src]
T: Serialize,
Auto Trait Implementations
impl<T> RefUnwindSafe for Gradient<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Gradient<T> where
T: Send,
T: Send,
impl<T> Sync for Gradient<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Gradient<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Gradient<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,