pub struct LipschitzEstimator<'a, F>{ /* private fields */ }
Expand description
Structure for the computation of estimates of the Lipschitz constant of mappings
Implementations§
Source§impl<'a, F> LipschitzEstimator<'a, F>
impl<'a, F> LipschitzEstimator<'a, F>
Sourcepub fn new(
u_: &'a mut [f64],
f_: &'a F,
function_value_: &'a mut [f64],
) -> LipschitzEstimator<'a, F>
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 ofu_
at exit is slightly perturbed. If you need to keep the original value ofu_
, you need to make a copy of the variable before you provide it to this method.f_
given closurefunction_value_
externally allocated memory which on exit stores the value of the given function atu_
, that isf_(u_)
§Returns
New instance of LipschitzEstimator
Sourcepub fn with_delta(self, delta: f64) -> Self
pub fn with_delta(self, delta: f64) -> Self
Sourcepub fn with_epsilon(self, epsilon: f64) -> Self
pub fn with_epsilon(self, epsilon: f64) -> Self
Sourcepub fn get_function_value(&self) -> &[f64]
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.
Sourcepub fn estimate_local_lipschitz(&mut self) -> Result<f64, SolverError>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more