pub struct ConvexFunction {
pub name: String,
pub lipschitz_grad: Option<f64>,
pub strong_convexity: Option<f64>,
/* private fields */
}Expand description
Represents a convex function f : ℝ^n → ℝ with optional gradient.
Fields§
§name: StringName of the function.
lipschitz_grad: Option<f64>Lipschitz constant of gradient (if known).
strong_convexity: Option<f64>Strong convexity modulus (if known).
Implementations§
Source§impl ConvexFunction
impl ConvexFunction
Sourcepub fn new(
name: impl Into<String>,
eval_fn: fn(&[f64]) -> f64,
grad_fn: Option<fn(&[f64]) -> Vec<f64>>,
) -> Self
pub fn new( name: impl Into<String>, eval_fn: fn(&[f64]) -> f64, grad_fn: Option<fn(&[f64]) -> Vec<f64>>, ) -> Self
Construct a new convex function.
Sourcepub fn gradient(&self, x: &[f64]) -> Vec<f64>
pub fn gradient(&self, x: &[f64]) -> Vec<f64>
Compute gradient of f at x (finite differences if no exact gradient provided).
Sourcepub fn fenchel_conjugate_approx(
&self,
y: &[f64],
radius: f64,
steps: usize,
) -> f64
pub fn fenchel_conjugate_approx( &self, y: &[f64], radius: f64, steps: usize, ) -> f64
Compute the Fenchel conjugate f*(y) = sup_x {⟨y,x⟩ - f(x)} approximately
via grid search on [-R, R]^n with resolution steps.
Sourcepub fn in_epigraph(&self, x: &[f64], t: f64) -> bool
pub fn in_epigraph(&self, x: &[f64], t: f64) -> bool
Compute epigraph membership: (x, t) ∈ epi(f) iff f(x) ≤ t.
Sourcepub fn in_level_set(&self, x: &[f64], alpha: f64) -> bool
pub fn in_level_set(&self, x: &[f64], alpha: f64) -> bool
Compute level set membership: x ∈ lev_α(f) iff f(x) ≤ α.
Trait Implementations§
Source§impl Clone for ConvexFunction
impl Clone for ConvexFunction
Source§fn clone(&self) -> ConvexFunction
fn clone(&self) -> ConvexFunction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConvexFunction
impl RefUnwindSafe for ConvexFunction
impl Send for ConvexFunction
impl Sync for ConvexFunction
impl Unpin for ConvexFunction
impl UnsafeUnpin for ConvexFunction
impl UnwindSafe for ConvexFunction
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