ganesh

Struct Minimizer

Source
pub struct Minimizer<U, E> {
    pub status: Status,
    /* private fields */
}
Expand description

The main struct used for running Algorithms on Functions.

Fields§

§status: Status

The Status of the Minimizer, usually read after minimization.

Implementations§

Source§

impl<U, E> Minimizer<U, E>

Source

pub fn new<A: Algorithm<U, E> + 'static>( algorithm: &A, dimension: usize, ) -> Self

Creates a new Minimizer with the given Algorithm and dimension set to the number of free parameters in the minimization problem.

Source

pub fn new_from_box( algorithm: Box<dyn Algorithm<U, E>>, dimension: usize, ) -> Self

Creates a new Minimizer with the given (boxed) Algorithm and dimension set to the number of free parameters in the minimization problem.

Source

pub fn with_algorithm<A: Algorithm<U, E> + 'static>(self, algorithm: &A) -> Self

Set the Algorithm used by the Minimizer.

Source

pub const fn with_max_steps(self, max_steps: usize) -> Self

Set the maximum number of steps to perform before failure (default: 4000).

Source

pub fn with_observers(self, observers: Vec<Box<dyn Observer<U>>>) -> Self

Sets the current list of Observers of the Minimizer.

Source

pub fn with_observer<O>(self, observer: O) -> Self
where O: Observer<U> + 'static,

Adds a single Observer to the Minimizer.

Source

pub fn with_bounds(self, bounds: Option<Vec<(Float, Float)>>) -> Self

Sets all Bounds of the Minimizer. This can be None for an unbounded problem, or Some [Vec<(T, T)>] with length equal to the number of free parameters. Individual upper or lower bounds can be unbounded by setting them equal to T::infinity() or T::neg_infinity() (e.g. f64::INFINITY and f64::NEG_INFINITY).

§Panics

This function will panic if the number of bounds is not equal to the number of free parameters.

Source

pub fn with_bound(self, index: usize, bound: Option<(Float, Float)>) -> Self

Sets the Bound of the parameter at the given index.

Source

pub fn minimize( &mut self, func: &dyn Function<U, E>, x0: &[Float], user_data: &mut U, ) -> Result<(), E>

Minimize the given Function starting at the point x0.

This method first runs Algorithm::initialize, then runs Algorithm::step in a loop, terminating if Algorithm::check_for_termination returns true or if the maximum number of allowed steps is exceeded. Each step will be followed by a sequential call to all given Observers’ callback functions. Finally, regardless of convergence, Algorithm::postprocessing is called. If the algorithm did not converge in the given step limit, the Status::message will be set to "MAX EVALS" at termination.

§Errors

Returns an Err(E) if the evaluation fails. See Function::evaluate for more information.

§Panics

This method will panic if the length of x0 is not equal to the dimension of the problem (number of free parameters) or if any values of x0 are outside the Bounds given to the Minimizer.

Trait Implementations§

Source§

impl<U, E> Display for Minimizer<U, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<U, E> Freeze for Minimizer<U, E>

§

impl<U, E> !RefUnwindSafe for Minimizer<U, E>

§

impl<U, E> !Send for Minimizer<U, E>

§

impl<U, E> !Sync for Minimizer<U, E>

§

impl<U, E> Unpin for Minimizer<U, E>

§

impl<U, E> !UnwindSafe for Minimizer<U, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.