[][src]Struct optimization_engine::lipschitz_estimator::LipschitzEstimator

pub struct LipschitzEstimator<'a, F> where
    F: Fn(&[f64], &mut [f64]) -> Result<(), SolverError>, 
{ /* fields omitted */ }

Structure for the computation of estimates of the Lipschitz constant of mappings

Implementations

impl<'a, F> LipschitzEstimator<'a, F> where
    F: Fn(&[f64], &mut [f64]) -> Result<(), SolverError>, 
[src]

pub fn new(
    u_: &'a mut [f64],
    f_: &'a F,
    function_value_: &'a mut [f64]
) -> LipschitzEstimator<'a, F>
[src]

Creates a new instance of this structure

Arguments

  • u_ On entry: point where the Lipschitz constant is estimated, On exit: the provided slice is modified (this is why it is a mutable reference). The value of u_ at exit is slightly perturbed. If you need to keep the original value of u_, you need to make a copy of the variable before you provide it to this method.
  • f_ given closure
  • function_value_ externally allocated memory which on exit stores the value of the given function at u_, that is f_(u_)

Returns

New instance of LipschitzEstimator

pub fn with_delta(self, delta: f64) -> Self[src]

A setter method for delta

Arguments

  • delta: parameter delta (the default value is 1e-6)

Panics

The method will panic if delta is non positive

pub fn with_epsilon(self, epsilon: f64) -> Self[src]

A setter method for epsilon

Arguments

  • epsilon: parameter epsilon (the default value is 1e-6)

Panics

The method will panic if epsilon is non positive

pub fn get_function_value(&self) -> &[f64][src]

Getter method for the Jacobian

During the computation of the local lipschitz constant at u, the value of the given function at u is computed and stored internally. This method returns a pointer to that vector.

If estimate_local_lipschitz has not been computed, the result will point to a zero vector.

pub fn estimate_local_lipschitz(&mut self) -> Result<f64, SolverError>[src]

Evaluates a local Lipschitz constant of a given function

Functions are closures of type F as shown here.

Returns

  • estimate of local Lipschitz constant (at point u)

Example

use optimization_engine::SolverError;

let mut u = [1.0, 2.0, 3.0];
let mut function_value = [0.0; 3];
let f = |u: &[f64], g: &mut [f64]| -> Result<(), SolverError> {
    g[0] = 3.0 * u[0];
    g[1] = 2.0 * u[1];
    g[2] = 4.5;
    Ok(())
};
let mut lip_estimator =
    optimization_engine::lipschitz_estimator::LipschitzEstimator::new(&mut u, &f, &mut function_value);
let lip = lip_estimator.estimate_local_lipschitz();

Panics

No rust-side panics, unless the C function which is called via this interface fails.

Auto Trait Implementations

impl<'a, F> RefUnwindSafe for LipschitzEstimator<'a, F> where
    F: RefUnwindSafe

impl<'a, F> Send for LipschitzEstimator<'a, F> where
    F: Sync

impl<'a, F> Sync for LipschitzEstimator<'a, F> where
    F: Sync

impl<'a, F> Unpin for LipschitzEstimator<'a, F>

impl<'a, F> !UnwindSafe for LipschitzEstimator<'a, F>

Blanket Implementations

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

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

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

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

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

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.