[][src]Struct proximal_optimize::ProximalOptimizer

pub struct ProximalOptimizer { /* fields omitted */ }

A hill-climbing optimizer that works by systematically testing nearby candidates.

This optimizer works even when the objective function (for which a maximum or minimum value is sought) is not differentiable, so that a gradient magnitude cannot be calculated. Any function may be optimized, provided its parameters are (or can be converted from) a &[f64] and its output implments PartialOrd.

Here's an example optimization, using the Rosenbrock function.

use proximal_optimize::ProximalOptimizer;

let mut po = ProximalOptimizer::new(2);
po.iterations(10000);
let initial_position = vec![-1.2, 1.0];
let optimized = po.optimize(&initial_position, |x: &[f64]| {
      ((1.0 - x[0]) * (1.0 - x[0])
    + 100.0 * (x[1] - x[0] * x[0]) * (x[1] - x[0] * x[0]))
}).unwrap();
println!("Optimized values is: {:?}", &optimized);
assert_eq!(optimized, vec![0.999208314861111, 0.998416214890118]);

Methods

impl ProximalOptimizer[src]

pub fn new(num_parameters: usize) -> ProximalOptimizer[src]

Creates a new proximal optimizer with default values for step sizing and the number of iterations.

pub fn get_num_parameters(&self) -> usize[src]

Returns the number of parameters expected by this optimizer.

pub fn maximize(&mut self)[src]

Set the optimizer to find input parameters that maximize the objective function, not minimize it.

pub fn minimize(&mut self)[src]

Set the optimizer to find input parameters that minimize the objective function. This is the default.

pub fn iterations(&mut self, iterations: usize)[src]

Sets the maximum number of iterations that the optimizer will perform before returning the optimized parameters.

pub fn get_iterations(&self) -> usize[src]

Returns the number of iterations the optimizer will perform before returning the optimized parameters.

pub fn initial_step_size(&mut self, step_size: f64)[src]

Sets the initial step distance for all parameters to step_size.

pub fn initial_step_sizes(
    &mut self,
    step_sizes: &[f64]
) -> Result<(), ProximalOptimizerErr>
[src]

Sets the initial step sizes for each parameter to the value specified by step_sizes.

pub fn step_expansion_ratio(&mut self, step_expansion_ratio: f64)[src]

Sets the step growth ratio for all parameters to step_expansion_ratio.

pub fn step_expansion_ratios(
    &mut self,
    step_expansion_ratio: &[f64]
) -> Result<(), ProximalOptimizerErr>
[src]

Sets the step growth ratio for each parameter to the value specified by step_expansion_ratio.

pub fn step_compression_ratio(&mut self, step_compression_ratio: f64)[src]

Sets the step compression ratio for all parameters to step_compression_ratio.

pub fn step_decrease_ratios(
    &mut self,
    step_compression_ratios: &[f64]
) -> Result<(), ProximalOptimizerErr>
[src]

Sets the step compression ratio for each parameter to the value specified by step_increase_ratios.

pub fn optimize<F, T>(
    &self,
    start: &[f64],
    func: F
) -> Result<Vec<f64>, ProximalOptimizerErr> where
    F: FnMut(&[f64]) -> T,
    T: PartialOrd + Debug
[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]