Problem

Struct 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§

Source§

impl<'a, E> Problem<'a, E>
where E: FnMut(&[f64], &mut [f64]) -> Result<f64>,

Source

pub fn new(x: &'a mut [f64], eval: E, owlqn: Option<Orthantwise>) -> Self

Initialize problem with array length n

Source

pub fn dginit(&self) -> Result<f64>

Compute the initial gradient in the search direction.

Source

pub fn update_search_direction(&mut self)

Update search direction using evaluated gradient.

Source

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

Return a reference to current search direction vector

Source

pub fn search_direction_mut(&mut self) -> &mut [f64]

Return a mutable reference to current search direction vector

Source

pub fn dg_unchecked(&self) -> f64

Compute the gradient in the search direction without sign checking.

Source

pub fn evaluate(&mut self) -> Result<()>

Source

pub fn number_of_evaluation(&self) -> usize

Return total number of evaluations.

Source

pub fn evaluated(&self) -> bool

Test if Problem has been evaluated or not

Source

pub fn clone_from(&mut self, src: &Problem<'_, E>)

Copies all elements from src into self.

Source

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.

Source

pub fn gnorm(&self) -> f64

Return gradient vector norm: ||gx||

Source

pub fn xnorm(&self) -> f64

Return position vector norm: ||x||

Source

pub fn orthantwise(&self) -> bool

Source

pub fn revert(&mut self)

Revert to previous step

Source

pub fn save_state(&mut self)

Store the current position and gradient vectors.

Source

pub fn constrain_search_direction(&mut self)

Constrain the search direction for orthant-wise updates.

Source

pub fn update_owlqn_gradient(&mut self)

Auto Trait Implementations§

§

impl<'a, E> Freeze for Problem<'a, E>
where E: Freeze,

§

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§

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.