Struct LipschitzEstimator

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

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

Implementations§

Source§

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

Source

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

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

Source

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

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

Source

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

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

Source

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

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.

Source

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

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> Freeze for LipschitzEstimator<'a, F>

§

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§

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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V