Struct qopt::Optimizer

source ·
pub struct Optimizer<const C: usize, const D: usize, const K: usize> {
    pub print_every: usize,
    pub maxtemp: f64,
    pub stdev: f64,
    /* private fields */
}
Expand description

Stores information about an optimizer.

Fields§

§print_every: usize§maxtemp: f64§stdev: f64

Implementations§

source§

impl<const C: usize, const D: usize, const K: usize> Optimizer<C, D, K>

source

pub fn new( obj: fn(_: Vector<C>, _: Vector<D>) -> f64, gradient: Option<fn(_: Vector<C>) -> Vector<C>>, hessian: Option<fn(_: Vector<C>) -> Matrix<C>> ) -> Self

Given a function, construct an Optimizer.

source

pub fn objective(&self, continuous: Vector<C>, discrete: Vector<D>) -> f64

Computes the objective of the function to be optimized, accounting for constraints.

When a constraint is hit, return f64::NAN.

source

pub fn gradient(&self, continuous: Vector<C>, discrete: Vector<D>) -> Vector<C>

Computes the gradient of the function to be optimized, accounting for constraints.

When a constraint is hit, return a vector with each element set to f64::NAN.

source

pub fn hessian(&self, continuous: Vector<C>, discrete: Vector<D>) -> Matrix<C>

Computes the hessian of the function to be optimized, accounting for constraints.

When a constraint is hit, return a matrix with each element set tof64::NAN.

source

pub fn step(&self, continuous: Vector<C>, discrete: Vector<D>) -> Vector<C>

Given an input vector, return a step vector.

source

pub fn update( &self, iter: usize, continuous: [Vector<C>; K], discrete: [Vector<D>; K], permitted: &[f64] ) -> ([Vector<C>; K], [Vector<D>; K])

Given an input population, return an updated (more optimal) population, enforcing discretized values where appropriate.

source

pub fn sort( &self, continuous: [Vector<C>; K], discrete: [Vector<D>; K] ) -> ([Vector<C>; K], [Vector<D>; K])

Sorts a population vector by increasing objective.

source

pub fn get_best( &self, continuous: [Vector<C>; K], discrete: [Vector<D>; K] ) -> (Vector<C>, Vector<D>)

Gets the best element in this population.

source

pub fn optimize( &self, continuous: Vector<C>, discrete: Vector<D>, permitted: &[f64] ) -> (Vector<C>, Vector<D>)

Optimize using a mixed approach given an input continuous vector, input discrete vector, and a list of permitted values.

Auto Trait Implementations§

§

impl<const C: usize, const D: usize, const K: usize> RefUnwindSafe for Optimizer<C, D, K>

§

impl<const C: usize, const D: usize, const K: usize> Send for Optimizer<C, D, K>

§

impl<const C: usize, const D: usize, const K: usize> Sync for Optimizer<C, D, K>

§

impl<const C: usize, const D: usize, const K: usize> Unpin for Optimizer<C, D, K>

§

impl<const C: usize, const D: usize, const K: usize> UnwindSafe for Optimizer<C, D, K>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V