r2rs_stats/funcs/opt/
mod.rs1mod brent;
7mod cgmin;
8mod fminfn;
9mod fmingr;
10mod hessian;
11mod lbfgsb;
12mod nmmin;
13mod samin;
14mod vmmin;
15
16use std::error::Error;
17
18pub use cgmin::CG;
19pub use lbfgsb::L_BFGS_B;
20pub use nmmin::NelderMead;
21pub use samin::SANN;
22pub use vmmin::BFGS;
23
24pub struct OptimOptions {
25 pub parscale: Option<Vec<f64>>,
26 pub fnscale: f64,
27 pub abstol: f64,
28 pub reltol: f64,
29 pub maxit: usize,
30}
31
32#[derive(Clone, Debug)]
33pub struct OptimResponse<T> {
34 pub parameters: T,
35 pub value: f64,
36 pub function_count: usize,
37 pub gradient_count: usize,
38 pub convergence: bool,
39}
40
41pub trait Optim {
42 type ParameterType;
43 fn optim(
44 &mut self,
45 par: Self::ParameterType,
46 min_func: &dyn Fn(Self::ParameterType) -> f64,
47 ) -> Result<OptimResponse<Self::ParameterType>, Box<dyn Error>>;
48}
49
50#[cfg(test)]
51mod tests;
52
53#[cfg(all(test, feature = "enable_proptest"))]
54mod proptests;
55
56#[cfg(all(test, feature = "enable_covtest"))]
57mod covtests;