Struct gosh_lbfgs::Problem
source · [−]pub struct Problem<'a, E> where
E: FnMut(&[f64], &mut [f64]) -> Result<f64>, {
pub x: &'a mut [f64],
pub fx: f64,
pub gx: Vec<f64>,
/* private fields */
}
Expand description
Represents an optimization problem.
Problem
holds input variables x
, gradient gx
arrays, and function value fx
.
Fields
x: &'a mut [f64]
x is an array of length n. on input it must contain the base point for the line search.
fx: f64
fx
is a variable. It must contain the value of problem f
at
x.
gx: Vec<f64>
gx
is an array of length n. It must contain the gradient of f
at
x.
Implementations
sourceimpl<'a, E> Problem<'a, E> where
E: FnMut(&[f64], &mut [f64]) -> Result<f64>,
impl<'a, E> Problem<'a, E> where
E: FnMut(&[f64], &mut [f64]) -> Result<f64>,
sourcepub fn new(x: &'a mut [f64], eval: E, owlqn: Option<Orthantwise>) -> Self
pub fn new(x: &'a mut [f64], eval: E, owlqn: Option<Orthantwise>) -> Self
Initialize problem with array length n
sourcepub fn update_search_direction(&mut self)
pub fn update_search_direction(&mut self)
Update search direction using evaluated gradient.
sourcepub fn search_direction(&self) -> &[f64]
pub fn search_direction(&self) -> &[f64]
Return a reference to current search direction vector
sourcepub fn search_direction_mut(&mut self) -> &mut [f64]
pub fn search_direction_mut(&mut self) -> &mut [f64]
Return a mutable reference to current search direction vector
sourcepub fn dg_unchecked(&self) -> f64
pub fn dg_unchecked(&self) -> f64
Compute the gradient in the search direction without sign checking.
pub fn evaluate(&mut self) -> Result<()>
sourcepub fn number_of_evaluation(&self) -> usize
pub fn number_of_evaluation(&self) -> usize
Return total number of evaluations.
sourcepub fn clone_from(&mut self, src: &Problem<'_, E>)
pub fn clone_from(&mut self, src: &Problem<'_, E>)
Copies all elements from src into self.
sourcepub fn take_line_step(&mut self, step: f64)
pub fn take_line_step(&mut self, step: f64)
Take a line step along search direction.
Compute the current value of x: x <- x + (*step) * d.
pub fn orthantwise(&self) -> bool
sourcepub fn save_state(&mut self)
pub fn save_state(&mut self)
Store the current position and gradient vectors.
sourcepub fn constrain_search_direction(&mut self)
pub fn constrain_search_direction(&mut self)
Constrain the search direction for orthant-wise updates.
pub fn update_owlqn_gradient(&mut self)
Auto Trait Implementations
impl<'a, E> RefUnwindSafe for Problem<'a, E> where
E: RefUnwindSafe,
impl<'a, E> Send for Problem<'a, E> where
E: Send,
impl<'a, E> Sync for Problem<'a, E> where
E: Sync,
impl<'a, E> Unpin for Problem<'a, E> where
E: Unpin,
impl<'a, E> !UnwindSafe for Problem<'a, E>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more