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>
impl<const C: usize, const D: usize, const K: usize> Optimizer<C, D, K>
sourcepub fn new(
obj: fn(_: Vector<C>, _: Vector<D>) -> f64,
gradient: Option<fn(_: Vector<C>) -> Vector<C>>,
hessian: Option<fn(_: Vector<C>) -> Matrix<C>>
) -> Self
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
.
sourcepub fn objective(&self, continuous: Vector<C>, discrete: Vector<D>) -> f64
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
.
sourcepub fn gradient(&self, continuous: Vector<C>, discrete: Vector<D>) -> Vector<C>
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
.
sourcepub fn hessian(&self, continuous: Vector<C>, discrete: Vector<D>) -> Matrix<C>
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
.
sourcepub fn step(&self, continuous: Vector<C>, discrete: Vector<D>) -> Vector<C>
pub fn step(&self, continuous: Vector<C>, discrete: Vector<D>) -> Vector<C>
Given an input vector, return a step vector.
sourcepub fn update(
&self,
iter: usize,
continuous: [Vector<C>; K],
discrete: [Vector<D>; K],
permitted: &[f64]
) -> ([Vector<C>; K], [Vector<D>; K])
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.
sourcepub fn sort(
&self,
continuous: [Vector<C>; K],
discrete: [Vector<D>; K]
) -> ([Vector<C>; K], [Vector<D>; K])
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more